Mercurial > hg > xemacs-beta
comparison src/scrollbar-x.c @ 70:131b0175ea99 r20-0b30
Import from CVS: tag r20-0b30
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:02:59 +0200 |
parents | 28a7c63c7e1e |
children | 6a378aca36af |
comparison
equal
deleted
inserted
replaced
69:804d1389bcd6 | 70:131b0175ea99 |
---|---|
39 static void x_update_vertical_scrollbar_callback (Widget widget, LWLIB_ID id, | 39 static void x_update_vertical_scrollbar_callback (Widget widget, LWLIB_ID id, |
40 XtPointer client_data); | 40 XtPointer client_data); |
41 static void x_update_horizontal_scrollbar_callback (Widget widget, LWLIB_ID id, | 41 static void x_update_horizontal_scrollbar_callback (Widget widget, LWLIB_ID id, |
42 XtPointer client_data); | 42 XtPointer client_data); |
43 | 43 |
44 /* Used to prevent changing the size of the slider while drag | 44 /* Used to prevent changing the size of the thumb while drag |
45 scrolling, under Motif. This is necessary because the Motif | 45 scrolling, under Motif. This is necessary because the Motif |
46 scrollbar is incredibly stupid about updating the slider and causes | 46 scrollbar is incredibly stupid about updating the thumb and causes |
47 lots of flicker if it is done too often. */ | 47 lots of flicker if it is done too often. */ |
48 static int inhibit_slider_size_change; | 48 static int inhibit_thumb_size_change; |
49 int stupid_vertical_scrollbar_drag_hack; | 49 |
50 | |
51 /* Doesn't work with athena */ | |
52 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) | 50 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
53 static int vertical_drag_in_progress; | 51 static int vertical_drag_in_progress; |
54 #endif | 52 #endif |
55 | 53 |
56 | 54 |
57 /* A device method. */ | 55 /* A device method. */ |
58 static int | 56 static int |
59 x_inhibit_scrollbar_slider_size_change (void) | 57 x_inhibit_scrollbar_thumb_size_change (void) |
60 { | 58 { |
61 /* Doesn't work with Athena */ | |
62 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) | 59 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
63 return inhibit_slider_size_change; | 60 return inhibit_thumb_size_change; |
64 #else | 61 #else |
65 return 0; | 62 return 0; |
66 #endif | 63 #endif |
67 } | 64 } |
68 | 65 |
104 instance->scrollbar_data = malloc_type_and_zero (struct x_scrollbar_data); | 101 instance->scrollbar_data = malloc_type_and_zero (struct x_scrollbar_data); |
105 | 102 |
106 SCROLLBAR_X_ID (instance) = new_lwlib_id (); | 103 SCROLLBAR_X_ID (instance) = new_lwlib_id (); |
107 sprintf (buffer, "scrollbar_%d", SCROLLBAR_X_ID (instance)); | 104 sprintf (buffer, "scrollbar_%d", SCROLLBAR_X_ID (instance)); |
108 SCROLLBAR_X_NAME (instance) = xstrdup (buffer); | 105 SCROLLBAR_X_NAME (instance) = xstrdup (buffer); |
109 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \ | 106 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
110 defined (LWLIB_SCROLLBARS_ATHENA3D) | |
111 SCROLLBAR_X_VDRAG_ORIG_VALUE (instance) = -1; | 107 SCROLLBAR_X_VDRAG_ORIG_VALUE (instance) = -1; |
112 #endif | 108 #endif |
113 | 109 |
114 if (vertical) | 110 if (vertical) |
115 { | 111 { |
127 NULL, FRAME_X_CONTAINER_WIDGET (f), 0, | 123 NULL, FRAME_X_CONTAINER_WIDGET (f), 0, |
128 x_update_horizontal_scrollbar_callback, NULL, NULL); | 124 x_update_horizontal_scrollbar_callback, NULL, NULL); |
129 } | 125 } |
130 } | 126 } |
131 | 127 |
132 #define UPDATE_DATA_FIELD(field) \ | 128 #define UPDATE_DATA_FIELD(field) \ |
133 if (new_##field >= 0 && \ | 129 if (new_##field >= 0 && \ |
134 SCROLLBAR_X_POS_DATA (inst).field != new_##field) { \ | 130 SCROLLBAR_X_POS_DATA (inst).field != new_##field) { \ |
135 SCROLLBAR_X_POS_DATA (inst).field = new_##field; \ | 131 SCROLLBAR_X_POS_DATA (inst).field = new_##field; \ |
136 inst->scrollbar_instance_changed = 1; \ | 132 inst->scrollbar_instance_changed = 1; \ |
137 } | 133 } |
138 | 134 |
139 /* A device method. */ | 135 /* A device method. */ |
140 /* #### The -1 check is such a hack. */ | 136 /* #### The -1 check is such a hack. */ |
141 static void | 137 static void |
159 UPDATE_DATA_FIELD (scrollbar_width); | 155 UPDATE_DATA_FIELD (scrollbar_width); |
160 UPDATE_DATA_FIELD (scrollbar_height); | 156 UPDATE_DATA_FIELD (scrollbar_height); |
161 UPDATE_DATA_FIELD (scrollbar_x); | 157 UPDATE_DATA_FIELD (scrollbar_x); |
162 UPDATE_DATA_FIELD (scrollbar_y); | 158 UPDATE_DATA_FIELD (scrollbar_y); |
163 | 159 |
164 /* This doesn't work with Athena, why? */ | |
165 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) | 160 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
166 if (w && !vertical_drag_in_progress) | 161 if (w && !vertical_drag_in_progress) |
167 { | 162 { |
168 int new_vov = SCROLLBAR_X_POS_DATA (inst).slider_position; | 163 int new_vov = SCROLLBAR_X_POS_DATA (inst).slider_position; |
169 int new_vows = marker_position (w->start[CURRENT_DISP]); | 164 int new_vows = marker_position (w->start[CURRENT_DISP]); |
247 static void | 242 static void |
248 x_update_scrollbar_instance_status (struct window *w, int active, int size, | 243 x_update_scrollbar_instance_status (struct window *w, int active, int size, |
249 struct scrollbar_instance *instance) | 244 struct scrollbar_instance *instance) |
250 { | 245 { |
251 struct frame *f = XFRAME (w->frame); | 246 struct frame *f = XFRAME (w->frame); |
252 Boolean managed = XtIsManaged (SCROLLBAR_X_WIDGET (instance)); | 247 char managed = XtIsManaged (SCROLLBAR_X_WIDGET (instance)); |
253 | 248 |
254 if (active && size) | 249 if (active && size) |
255 { | 250 { |
256 widget_value *wv = scrollbar_instance_to_widget_value (instance); | 251 widget_value *wv = scrollbar_instance_to_widget_value (instance); |
257 | 252 |
285 wv->scrollbar_data = 0; | 280 wv->scrollbar_data = 0; |
286 free_widget_value (wv); | 281 free_widget_value (wv); |
287 } | 282 } |
288 else if (managed) | 283 else if (managed) |
289 { | 284 { |
290 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) | |
291 /* This isn't needed with Athena Scrollbars. It might not be needed */ | |
292 /* with Motif scrollbars (it is apparently needed with Lesstif). */ | |
293 XtUngrabKeyboard (SCROLLBAR_X_WIDGET (instance), CurrentTime); | |
294 #endif | |
295 XtUnmanageChild (SCROLLBAR_X_WIDGET (instance)); | 285 XtUnmanageChild (SCROLLBAR_X_WIDGET (instance)); |
296 } | 286 } |
297 } | 287 } |
298 | 288 |
299 /* A device method. */ | 289 /* A device method. */ |
540 | 530 |
541 /* The Athena scrollbar paging behavior is that of xterms. | 531 /* The Athena scrollbar paging behavior is that of xterms. |
542 Depending on where you click the size of the page varies. | 532 Depending on where you click the size of the page varies. |
543 Motif always does a standard Emacs page. */ | 533 Motif always does a standard Emacs page. */ |
544 case SCROLLBAR_PAGE_UP: | 534 case SCROLLBAR_PAGE_UP: |
545 #if !defined (LWLIB_SCROLLBARS_MOTIF) && !defined (LWLIB_SCROLLBARS_LUCID) && \ | 535 #if !defined (LWLIB_SCROLLBARS_MOTIF) && !defined (LWLIB_SCROLLBARS_LUCID) |
546 !defined (LWLIB_SCROLLBARS_ATHENA3D) | |
547 { | 536 { |
548 double tmp = ((double) data->slider_value / | 537 double tmp = ((double) data->slider_value / |
549 (double) SCROLLBAR_X_POS_DATA(instance).scrollbar_height); | 538 (double) SCROLLBAR_X_POS_DATA(instance).scrollbar_height); |
550 double line = tmp * | 539 double line = tmp * |
551 (double) window_displayed_height (XWINDOW (win)); | 540 (double) window_displayed_height (XWINDOW (win)); |
560 Fcons (win, Qnil)); | 549 Fcons (win, Qnil)); |
561 #endif | 550 #endif |
562 break; | 551 break; |
563 | 552 |
564 case SCROLLBAR_PAGE_DOWN: | 553 case SCROLLBAR_PAGE_DOWN: |
565 #if !defined (LWLIB_SCROLLBARS_MOTIF) && !defined (LWLIB_SCROLLBARS_LUCID) && \ | 554 #if !defined (LWLIB_SCROLLBARS_MOTIF) && !defined (LWLIB_SCROLLBARS_LUCID) |
566 !defined (LWLIB_SCROLLBARS_ATHENA3D) | |
567 { | 555 { |
568 double tmp = ((double) data->slider_value / | 556 double tmp = ((double) data->slider_value / |
569 (double) SCROLLBAR_X_POS_DATA(instance).scrollbar_height); | 557 (double) SCROLLBAR_X_POS_DATA(instance).scrollbar_height); |
570 double line = tmp * | 558 double line = tmp * |
571 (double) window_displayed_height (XWINDOW (win)); | 559 (double) window_displayed_height (XWINDOW (win)); |
594 signal_special_Xt_user_event (win, Qscrollbar_to_bottom, win); | 582 signal_special_Xt_user_event (win, Qscrollbar_to_bottom, win); |
595 break; | 583 break; |
596 | 584 |
597 | 585 |
598 case SCROLLBAR_CHANGE: | 586 case SCROLLBAR_CHANGE: |
599 inhibit_slider_size_change = 0; | 587 inhibit_thumb_size_change = 0; |
600 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) | 588 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
601 vertical_drag_in_progress = 0; | 589 vertical_drag_in_progress = 0; |
602 SCROLLBAR_X_VDRAG_ORIG_VALUE (instance) = data->slider_value; | 590 SCROLLBAR_X_VDRAG_ORIG_VALUE (instance) = data->slider_value; |
603 SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance) = | 591 SCROLLBAR_X_VDRAG_ORIG_WINDOW_START (instance) = |
604 XINT (Fwindow_start (win)); | 592 XINT (Fwindow_start (win)); |
605 #else | |
606 stupid_vertical_scrollbar_drag_hack = 0; | |
607 #endif | 593 #endif |
608 break; | 594 break; |
609 | 595 |
610 case SCROLLBAR_DRAG: | 596 case SCROLLBAR_DRAG: |
611 { | 597 { |
612 int value; | 598 int value; |
613 | 599 |
614 inhibit_slider_size_change = 1; | 600 inhibit_thumb_size_change = 1; |
615 | 601 |
616 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) | 602 #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) |
617 /* Doing drags with Motif-like scrollbars is a mess, since we | 603 /* Doing drags with Motif-like scrollbars is a mess, since we |
618 want to avoid having the window position jump when you | 604 want to avoid having the window position jump when you |
619 first grab the scrollbar, but we also want to ensure that | 605 first grab the scrollbar, but we also want to ensure that |
679 - SCROLLBAR_X_POS_DATA (instance).slider_size | 665 - SCROLLBAR_X_POS_DATA (instance).slider_size |
680 - SCROLLBAR_X_VDRAG_ORIG_VALUE (instance)))); | 666 - SCROLLBAR_X_VDRAG_ORIG_VALUE (instance)))); |
681 } | 667 } |
682 } | 668 } |
683 #else | 669 #else |
684 stupid_vertical_scrollbar_drag_hack = 0; | |
685 value = data->slider_value; | 670 value = data->slider_value; |
686 #endif | 671 #endif |
687 | 672 |
688 if (value >= SCROLLBAR_X_POS_DATA (instance).maximum) | 673 if (value >= SCROLLBAR_X_POS_DATA (instance).maximum) |
689 value = SCROLLBAR_X_POS_DATA (instance).maximum - 1; | 674 value = SCROLLBAR_X_POS_DATA (instance).maximum - 1; |
745 break; | 730 break; |
746 case SCROLLBAR_BOTTOM: | 731 case SCROLLBAR_BOTTOM: |
747 signal_special_Xt_user_event (win, Qscrollbar_to_right, win); | 732 signal_special_Xt_user_event (win, Qscrollbar_to_right, win); |
748 break; | 733 break; |
749 case SCROLLBAR_CHANGE: | 734 case SCROLLBAR_CHANGE: |
750 inhibit_slider_size_change = 0; | 735 inhibit_thumb_size_change = 0; |
751 break; | 736 break; |
752 case SCROLLBAR_DRAG: | 737 case SCROLLBAR_DRAG: |
753 inhibit_slider_size_change = 1; | 738 inhibit_thumb_size_change = 1; |
754 /* #### Fix the damn toolkit code so they all work the same way. | 739 /* #### Fix the damn toolkit code so they all work the same way. |
755 Lucid is the one mostly wrong.*/ | 740 Lucid is the one mostly wrong.*/ |
756 #if defined (LWLIB_SCROLLBARS_LUCID) || defined (LWLIB_SCROLLBARS_ATHENA3D) | 741 #if defined (LWLIB_SCROLLBARS_LUCID) |
757 signal_special_Xt_user_event (win, Qscrollbar_horizontal_drag, | 742 signal_special_Xt_user_event (win, Qscrollbar_horizontal_drag, |
758 (Fcons | 743 (Fcons |
759 (win, make_int (data->slider_value)))); | 744 (win, make_int (data->slider_value)))); |
760 #else | 745 #else |
761 signal_special_Xt_user_event (win, Qscrollbar_horizontal_drag, | 746 signal_special_Xt_user_event (win, Qscrollbar_horizontal_drag, |
837 /************************************************************************/ | 822 /************************************************************************/ |
838 | 823 |
839 void | 824 void |
840 console_type_create_scrollbar_x (void) | 825 console_type_create_scrollbar_x (void) |
841 { | 826 { |
842 CONSOLE_HAS_METHOD (x, inhibit_scrollbar_slider_size_change); | 827 CONSOLE_HAS_METHOD (x, inhibit_scrollbar_thumb_size_change); |
843 CONSOLE_HAS_METHOD (x, free_scrollbar_instance); | 828 CONSOLE_HAS_METHOD (x, free_scrollbar_instance); |
844 CONSOLE_HAS_METHOD (x, release_scrollbar_instance); | 829 CONSOLE_HAS_METHOD (x, release_scrollbar_instance); |
845 CONSOLE_HAS_METHOD (x, create_scrollbar_instance); | 830 CONSOLE_HAS_METHOD (x, create_scrollbar_instance); |
846 CONSOLE_HAS_METHOD (x, update_scrollbar_instance_values); | 831 CONSOLE_HAS_METHOD (x, update_scrollbar_instance_values); |
847 CONSOLE_HAS_METHOD (x, update_scrollbar_instance_status); | 832 CONSOLE_HAS_METHOD (x, update_scrollbar_instance_status); |
861 #elif defined (LWLIB_SCROLLBARS_MOTIF) | 846 #elif defined (LWLIB_SCROLLBARS_MOTIF) |
862 Fprovide (intern ("motif-scrollbars")); | 847 Fprovide (intern ("motif-scrollbars")); |
863 #elif defined (LWLIB_SCROLLBARS_ATHENA) | 848 #elif defined (LWLIB_SCROLLBARS_ATHENA) |
864 Fprovide (intern ("athena-scrollbars")); | 849 Fprovide (intern ("athena-scrollbars")); |
865 #endif | 850 #endif |
866 stupid_vertical_scrollbar_drag_hack = 1; | 851 } |
867 } |