Mercurial > hg > xemacs-beta
comparison src/scrollbar.c @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | cc15677e0335 |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
93 } | 93 } |
94 | 94 |
95 static void | 95 static void |
96 free_window_mirror_scrollbars (struct window_mirror *mir) | 96 free_window_mirror_scrollbars (struct window_mirror *mir) |
97 { | 97 { |
98 struct frame *f = mir->frame; | 98 free_scrollbar_instance (mir->scrollbar_vertical_instance, mir->frame); |
99 free_scrollbar_instance (mir->scrollbar_vertical_instance, f); | |
100 mir->scrollbar_vertical_instance = 0; | 99 mir->scrollbar_vertical_instance = 0; |
101 free_scrollbar_instance (mir->scrollbar_horizontal_instance, f); | 100 |
101 free_scrollbar_instance (mir->scrollbar_horizontal_instance, mir->frame); | |
102 mir->scrollbar_horizontal_instance = 0; | 102 mir->scrollbar_horizontal_instance = 0; |
103 } | 103 } |
104 | 104 |
105 static struct window_mirror * | 105 static struct window_mirror * |
106 free_scrollbars_loop (Lisp_Object window, struct window_mirror *mir) | 106 free_scrollbars_loop (Lisp_Object window, struct window_mirror *mir) |
107 { | 107 { |
108 struct window_mirror *retval = NULL; | 108 struct window_mirror *retval = NULL; |
109 | 109 |
110 while (mir) | 110 while (mir) |
111 { | 111 { |
112 struct scrollbar_instance *vinst = mir->scrollbar_vertical_instance; | |
113 struct scrollbar_instance *hinst = mir->scrollbar_horizontal_instance; | |
114 struct frame *f; | |
115 | |
116 assert (!NILP (window)); | 112 assert (!NILP (window)); |
117 f = XFRAME (XWINDOW (window)->frame); | |
118 | 113 |
119 if (mir->vchild) | 114 if (mir->vchild) |
120 { | 115 { |
121 retval = free_scrollbars_loop (XWINDOW (window)->vchild, | 116 retval = free_scrollbars_loop (XWINDOW (window)->vchild, |
122 mir->vchild); | 117 mir->vchild); |
128 } | 123 } |
129 | 124 |
130 if (retval != NULL) | 125 if (retval != NULL) |
131 return retval; | 126 return retval; |
132 | 127 |
133 if (hinst || vinst) | 128 if (mir->scrollbar_vertical_instance || |
129 mir->scrollbar_horizontal_instance) | |
134 free_window_mirror_scrollbars (mir); | 130 free_window_mirror_scrollbars (mir); |
135 | 131 |
136 mir = mir->next; | 132 mir = mir->next; |
137 window = XWINDOW (window)->next; | 133 window = XWINDOW (window)->next; |
138 } | 134 } |
139 | 135 |
140 return NULL; | 136 return NULL; |
141 } | 137 } |
142 | 138 |
143 /* Destroy all scrollbars associated with FRAME. Only called from | 139 /* Destroy all scrollbars associated with FRAME. Only called from |
144 delete_frame_internal. | 140 delete_frame_internal. */ |
145 */ | |
146 #define FREE_FRAME_SCROLLBARS_INTERNAL(cache) \ | |
147 do { \ | |
148 while (FRAME_SB_##cache (f)) \ | |
149 { \ | |
150 struct scrollbar_instance *tofree = FRAME_SB_##cache (f); \ | |
151 FRAME_SB_##cache (f) = FRAME_SB_##cache (f)->next; \ | |
152 tofree->next = NULL; \ | |
153 free_scrollbar_instance (tofree, f); \ | |
154 } \ | |
155 } while (0) | |
156 | |
157 void | 141 void |
158 free_frame_scrollbars (struct frame *f) | 142 free_frame_scrollbars (struct frame *f) |
159 { | 143 { |
160 if (!HAS_FRAMEMETH_P (f, create_scrollbar_instance)) | 144 if (!HAS_FRAMEMETH_P (f, create_scrollbar_instance)) |
161 return; | 145 return; |
163 if (f->mirror_dirty) | 147 if (f->mirror_dirty) |
164 update_frame_window_mirror (f); | 148 update_frame_window_mirror (f); |
165 | 149 |
166 free_scrollbars_loop (f->root_window, f->root_mirror); | 150 free_scrollbars_loop (f->root_window, f->root_mirror); |
167 | 151 |
168 FREE_FRAME_SCROLLBARS_INTERNAL (VCACHE); | 152 while (FRAME_SB_VCACHE (f)) |
169 FREE_FRAME_SCROLLBARS_INTERNAL (HCACHE); | 153 { |
170 } | 154 struct scrollbar_instance *tofree = FRAME_SB_VCACHE (f); |
171 #undef FREE_FRAME_SCROLLBARS_INTERNAL | 155 FRAME_SB_VCACHE (f) = FRAME_SB_VCACHE (f)->next; |
156 tofree->next = NULL; | |
157 free_scrollbar_instance (tofree, f); | |
158 } | |
159 | |
160 while (FRAME_SB_HCACHE (f)) | |
161 { | |
162 struct scrollbar_instance *tofree = FRAME_SB_HCACHE (f); | |
163 FRAME_SB_HCACHE (f) = FRAME_SB_HCACHE (f)->next; | |
164 tofree->next = NULL; | |
165 free_scrollbar_instance (tofree, f); | |
166 } | |
167 } | |
172 | 168 |
173 | 169 |
174 static struct scrollbar_instance * | 170 static struct scrollbar_instance * |
175 create_scrollbar_instance (struct frame *f, int vertical) | 171 create_scrollbar_instance (struct frame *f, int vertical) |
176 { | 172 { |
351 MAYBE_DEVMETH (d, release_scrollbar_instance, | 347 MAYBE_DEVMETH (d, release_scrollbar_instance, |
352 (mir->scrollbar_horizontal_instance)); | 348 (mir->scrollbar_horizontal_instance)); |
353 } | 349 } |
354 mir->scrollbar_horizontal_instance = 0; | 350 mir->scrollbar_horizontal_instance = 0; |
355 } | 351 } |
356 | |
357 /* This check needs to be done in the device-specific side. */ | |
358 #define UPDATE_DATA_FIELD(field, value) \ | |
359 if (instance->field != value) {\ | |
360 instance->field = value;\ | |
361 instance->scrollbar_instance_changed = 1;\ | |
362 }\ | |
363 | 352 |
364 /* | 353 /* |
365 * If w->sb_point is on the top line then return w->sb_point else | 354 * If w->sb_point is on the top line then return w->sb_point else |
366 * return w->start. If flag, then return beginning point of line | 355 * return w->start. If flag, then return beginning point of line |
367 * which w->sb_point lies on. | 356 * which w->sb_point lies on. |
596 { | 585 { |
597 /* Hold on your cerebella guys. If we always show the dividers, | 586 /* Hold on your cerebella guys. If we always show the dividers, |
598 changing scrollbar affects only how the text and scrollbar are | 587 changing scrollbar affects only how the text and scrollbar are |
599 laid out in the window. If we do not want the dividers to show up | 588 laid out in the window. If we do not want the dividers to show up |
600 always, then we mark more drastic change, because changing | 589 always, then we mark more drastic change, because changing |
601 divider appearane changes lotta things. Although we actually need | 590 divider appearance changes lotta things. Although we actually need |
602 to do this only if the scrollbar has appeared or disappeared | 591 to do this only if the scrollbar has appeared or disappeared |
603 completely at either window edge, we do this always, as users | 592 completely at either window edge, we do this always, as users |
604 usually do not reposition scrollbars 200 times a second or so. Do | 593 usually do not reposition scrollbars 200 times a second or so. Do |
605 you? */ | 594 you? */ |
606 if (NILP (w->vertical_divider_always_visible_p)) | 595 if (NILP (w->vertical_divider_always_visible_p)) |
870 else | 859 else |
871 hscroll = XINT (value); | 860 hscroll = XINT (value); |
872 | 861 |
873 /* Can't allow this out of set-window-hscroll's acceptable range. */ | 862 /* Can't allow this out of set-window-hscroll's acceptable range. */ |
874 /* #### What hell on the earth this code limits scroll size to the | 863 /* #### What hell on the earth this code limits scroll size to the |
875 machine-dependant SHORT size? -- kkm */ | 864 machine-dependent SHORT size? -- kkm */ |
876 if (hscroll < 0) | 865 if (hscroll < 0) |
877 hscroll = 0; | 866 hscroll = 0; |
878 else if (hscroll >= (1 << (SHORTBITS - 1)) - 1) | 867 else if (hscroll >= (1 << (SHORTBITS - 1)) - 1) |
879 hscroll = (1 << (SHORTBITS - 1)) - 1; | 868 hscroll = (1 << (SHORTBITS - 1)) - 1; |
880 | 869 |
1000 slot_offset (struct frame, | 989 slot_offset (struct frame, |
1001 vertical_scrollbar_visible_p), | 990 vertical_scrollbar_visible_p), |
1002 frame_size_slipped); | 991 frame_size_slipped); |
1003 | 992 |
1004 DEFVAR_SPECIFIER ("scrollbar-on-left-p", &Vscrollbar_on_left_p /* | 993 DEFVAR_SPECIFIER ("scrollbar-on-left-p", &Vscrollbar_on_left_p /* |
1005 *Whether the verical scrollbar is on the left side of window or frame. | 994 *Whether the vertical scrollbar is on the left side of window or frame. |
1006 This is a specifier; use `set-specifier' to change it. | 995 This is a specifier; use `set-specifier' to change it. |
1007 */ ); | 996 */ ); |
1008 Vscrollbar_on_left_p = Fmake_specifier (Qboolean); | 997 Vscrollbar_on_left_p = Fmake_specifier (Qboolean); |
1009 | 998 |
1010 { | 999 { |
1011 /* Klugde. Under X, we want athena scrollbars on the left, | 1000 /* Kludge. Under X, we want athena scrollbars on the left, |
1012 while all other scrollbars go on the right by default. */ | 1001 while all other scrollbars go on the right by default. */ |
1013 Lisp_Object fallback = list1 (Fcons (Qnil, Qnil)); | 1002 Lisp_Object fallback = list1 (Fcons (Qnil, Qnil)); |
1014 #if defined (HAVE_X_WINDOWS) \ | 1003 #if defined (HAVE_X_WINDOWS) \ |
1015 && !defined (LWLIB_SCROLLBARS_MOTIF) \ | 1004 && !defined (LWLIB_SCROLLBARS_MOTIF) \ |
1016 && !defined (LWLIB_SCROLLBARS_LUCID) \ | 1005 && !defined (LWLIB_SCROLLBARS_LUCID) \ |
1028 slot_offset (struct frame, | 1017 slot_offset (struct frame, |
1029 scrollbar_on_left_p), | 1018 scrollbar_on_left_p), |
1030 frame_size_slipped); | 1019 frame_size_slipped); |
1031 | 1020 |
1032 DEFVAR_SPECIFIER ("scrollbar-on-top-p", &Vscrollbar_on_top_p /* | 1021 DEFVAR_SPECIFIER ("scrollbar-on-top-p", &Vscrollbar_on_top_p /* |
1033 *Whether the verical scrollbar is on the top side of window or frame. | 1022 *Whether the horizontal scrollbar is on the top side of window or frame. |
1034 This is a specifier; use `set-specifier' to change it. | 1023 This is a specifier; use `set-specifier' to change it. |
1035 */ ); | 1024 */ ); |
1036 Vscrollbar_on_top_p = Fmake_specifier (Qboolean); | 1025 Vscrollbar_on_top_p = Fmake_specifier (Qboolean); |
1037 set_specifier_fallback (Vscrollbar_on_top_p, | 1026 set_specifier_fallback (Vscrollbar_on_top_p, |
1038 list1 (Fcons (Qnil, Qnil))); | 1027 list1 (Fcons (Qnil, Qnil))); |