Mercurial > hg > xemacs-beta
annotate src/scrollbar-gtk.c @ 5169:6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-03-24 Ben Wing <ben@xemacs.org>
* array.h:
* array.h (XD_LISP_DYNARR_DESC):
* dumper.c (pdump_register_sub):
* dumper.c (pdump_store_new_pointer_offsets):
* dumper.c (pdump_reloc_one_mc):
* elhash.c:
* gc.c (lispdesc_one_description_line_size):
* gc.c (kkcc_marking):
* lrecord.h:
* lrecord.h (IF_NEW_GC):
* lrecord.h (enum memory_description_type):
* lrecord.h (enum data_description_entry_flags):
* lrecord.h (struct opaque_convert_functions):
Rename XD_LISP_OBJECT_BLOCK_PTR to XD_INLINE_LISP_OBJECT_BLOCK_PTR
and document it in lrecord.h.
* data.c:
* data.c (finish_marking_weak_lists):
* data.c (continue_marking_ephemerons):
* data.c (finish_marking_ephemerons):
* elhash.c (MARK_OBJ):
* gc.c:
* gc.c (lispdesc_indirect_count_1):
* gc.c (struct):
* gc.c (kkcc_bt_push):
* gc.c (kkcc_gc_stack_push):
* gc.c (kkcc_gc_stack_push_lisp_object):
* gc.c (kkcc_gc_stack_repush_dirty_object):
* gc.c (KKCC_DO_CHECK_FREE):
* gc.c (mark_object_maybe_checking_free):
* gc.c (mark_struct_contents):
* gc.c (mark_lisp_object_block_contents):
* gc.c (register_for_finalization):
* gc.c (mark_object):
* gc.h:
* lisp.h:
* profile.c:
* profile.c (mark_profiling_info_maphash):
Clean up KKCC code related to DEBUG_XEMACS. Rename
kkcc_backtrace() to kkcc_backtrace_1() and add two params: a
`size' arg to control how many stack elements to print and a
`detailed' arg to control whether Lisp objects are printed using
`debug_print()'. Create front-ends to kkcc_backtrace_1() --
kkcc_detailed_backtrace(), kkcc_short_backtrace(),
kkcc_detailed_backtrace_full(), kkcc_short_backtrace_full(), as
well as shortened versions kbt(), kbts(), kbtf(), kbtsf() -- to
call it with various parameter values. Add an `is_lisp' field to
the stack and backtrace structures and use it to keep track of
whether an object pushed onto the stack is a Lisp object or a
non-Lisp structure; in kkcc_backtrace_1(), don't try to print a
non-Lisp structure as a Lisp object.
* elhash.c:
* extents.c:
* file-coding.c:
* lrecord.h:
* lrecord.h (IF_NEW_GC):
* marker.c:
* marker.c (Fmarker_buffer):
* mule-coding.c:
* number.c:
* rangetab.c:
* specifier.c:
New macros IF_OLD_GC(), IF_NEW_GC() to simplify declaration of
Lisp objects when a finalizer may exist in one but not the other.
Use them appropriately.
* extents.c (finalize_extent_info):
Don't zero out data->soe and data->extents before trying to free,
else we get memory leaks.
* lrecord.h (enum lrecord_type):
Make the first lrecord type have value 1 not 0 so that 0 remains
without implementation and attempts to interpret zeroed memory
as a Lisp object will be more obvious.
* array.c (Dynarr_free):
* device-msw.c (msprinter_delete_device):
* device-tty.c (free_tty_device_struct):
* device-tty.c (tty_delete_device):
* dialog-msw.c (handle_directory_dialog_box):
* dialog-x.c:
* emacs.c (free_argc_argv):
* emodules.c (attempt_module_delete):
* file-coding.c (chain_finalize_coding_stream_1):
* file-coding.c (chain_finalize_coding_stream):
* glyphs-eimage.c:
* glyphs-eimage.c (jpeg_instantiate_unwind):
* glyphs-eimage.c (gif_instantiate_unwind):
* glyphs-eimage.c (png_instantiate_unwind):
* glyphs-eimage.c (tiff_instantiate_unwind):
* imgproc.c:
* imgproc.c (build_EImage_quantable):
* insdel.c (uninit_buffer_text):
* mule-coding.c (iso2022_finalize_detection_state):
* objects-tty.c (tty_finalize_color_instance):
* objects-tty.c (tty_finalize_font_instance):
* objects-tty.c (tty_font_list):
* process.c:
* process.c (finalize_process):
* redisplay.c (add_propagation_runes):
* scrollbar-gtk.c:
* scrollbar-gtk.c (gtk_free_scrollbar_instance):
* scrollbar-gtk.c (gtk_release_scrollbar_instance):
* scrollbar-msw.c:
* scrollbar-msw.c (mswindows_free_scrollbar_instance):
* scrollbar-msw.c (unshow_that_mofo):
* scrollbar-x.c (x_free_scrollbar_instance):
* scrollbar-x.c (x_release_scrollbar_instance):
* select-x.c:
* select-x.c (x_handle_selection_request):
* syntax.c:
* syntax.c (uninit_buffer_syntax_cache):
* text.h (eifree):
If possible, whenever we call xfree() on a field in a structure,
set the field to 0 afterwards. A lot of code is written so that
it checks the value being freed to see if it is non-zero before
freeing it -- doing this and setting the value to 0 afterwards
ensures (a) we won't try to free twice if the cleanup code is
called twice; (b) if the object itself stays around, KKCC won't
crash when attempting to mark the freed field.
* rangetab.c:
Add a finalization method when not NEW_GC to avoid memory leaks.
(#### We still get memory leaks when NEW_GC; need to convert gap
array to Lisp object).
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Mar 2010 01:22:51 -0500 |
parents | 1fae11d56ad2 |
children | 5ddbab03b0e6 |
rev | line source |
---|---|
2168 | 1 /* scrollbar implementation -- GTK interface. |
462 | 2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. |
3 Copyright (C) 1994 Amdhal Corporation. | |
4 Copyright (C) 1995 Sun Microsystems, Inc. | |
5 Copyright (C) 1995 Darrell Kindred <dkindred+@cmu.edu>. | |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
6 Copyright (C) 2010 Ben Wing. |
462 | 7 |
8 This file is part of XEmacs. | |
9 | |
10 XEmacs is free software; you can redistribute it and/or modify it | |
11 under the terms of the GNU General Public License as published by the | |
12 Free Software Foundation; either version 2, or (at your option) any | |
13 later version. | |
14 | |
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
21 along with XEmacs; see the file COPYING. If not, write to | |
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 Boston, MA 02111-1307, USA. */ | |
24 | |
25 /* Synched up with: Not in FSF. */ | |
26 /* Gtk version by William M. Perry */ | |
27 | |
28 #include <config.h> | |
29 #include "lisp.h" | |
30 | |
872 | 31 #include "frame-impl.h" |
32 #include "window.h" | |
33 | |
34 #include "console-gtk-impl.h" | |
462 | 35 #include "glyphs-gtk.h" |
36 #include "scrollbar-gtk.h" | |
37 | |
38 static gboolean scrollbar_cb (GtkAdjustment *adj, gpointer user_data); | |
39 | |
40 /* Used to prevent changing the size of the slider while drag | |
41 scrolling, under Motif. This is necessary because the Motif | |
42 scrollbar is incredibly stupid about updating the slider and causes | |
43 lots of flicker if it is done too often. */ | |
44 static int inhibit_slider_size_change; | |
45 | |
46 static int vertical_drag_in_progress; | |
47 | |
48 | |
49 /* A device method. */ | |
50 static int | |
51 gtk_inhibit_scrollbar_slider_size_change (void) | |
52 { | |
53 return inhibit_slider_size_change; | |
54 } | |
55 | |
56 /* A device method. */ | |
57 static void | |
58 gtk_free_scrollbar_instance (struct scrollbar_instance *instance) | |
59 { | |
3482 | 60 if (instance->scrollbar_data) |
462 | 61 { |
3482 | 62 if (SCROLLBAR_GTK_WIDGET (instance)) |
63 { | |
64 gtk_widget_hide_all (SCROLLBAR_GTK_WIDGET (instance)); | |
65 gtk_widget_destroy (SCROLLBAR_GTK_WIDGET (instance)); | |
66 } | |
67 | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
3482
diff
changeset
|
68 xfree (instance->scrollbar_data); |
5169
6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
69 instance->scrollbar_data = 0; |
462 | 70 } |
71 } | |
72 | |
73 /* A device method. */ | |
74 static void | |
75 gtk_release_scrollbar_instance (struct scrollbar_instance *instance) | |
76 { | |
77 /* It won't hurt to hide it all the time, will it? */ | |
78 gtk_widget_hide_all (SCROLLBAR_GTK_WIDGET (instance)); | |
79 } | |
80 | |
81 static gboolean | |
2286 | 82 scrollbar_drag_hack_cb (GtkWidget *UNUSED (w), GdkEventButton *UNUSED (ev), |
83 gpointer v) | |
462 | 84 { |
85 vertical_drag_in_progress = (int) v; | |
86 inhibit_slider_size_change = (int) v; | |
87 return (FALSE); | |
88 } | |
89 | |
90 /* A device method. */ | |
91 static void | |
92 gtk_create_scrollbar_instance (struct frame *f, int vertical, | |
93 struct scrollbar_instance *instance) | |
94 { | |
95 GtkAdjustment *adj = GTK_ADJUSTMENT (gtk_adjustment_new (0,0,0,0,0,0)); | |
96 GtkScrollbar *sb = NULL; | |
97 | |
98 /* initialize the X specific data section. */ | |
99 instance->scrollbar_data = xnew_and_zero (struct gtk_scrollbar_data); | |
100 | |
101 SCROLLBAR_GTK_ID (instance) = new_gui_id (); | |
102 SCROLLBAR_GTK_VDRAG_ORIG_VALUE (instance) = -1; | |
103 SCROLLBAR_GTK_LAST_VALUE (instance) = adj->value; | |
104 | |
2168 | 105 gtk_object_set_data (GTK_OBJECT (adj), GTK_DATA_GUI_IDENTIFIER, (void *) SCROLLBAR_GTK_ID (instance)); |
106 gtk_object_set_data (GTK_OBJECT (adj), GTK_DATA_FRAME_IDENTIFIER, f); | |
462 | 107 |
108 sb = GTK_SCROLLBAR (vertical ? gtk_vscrollbar_new (adj) : gtk_hscrollbar_new (adj)); | |
109 SCROLLBAR_GTK_WIDGET (instance) = GTK_WIDGET (sb); | |
110 | |
111 gtk_signal_connect (GTK_OBJECT (adj),"value-changed", | |
112 GTK_SIGNAL_FUNC (scrollbar_cb), (gpointer) vertical); | |
113 | |
114 gtk_signal_connect (GTK_OBJECT (sb), "button-press-event", | |
115 GTK_SIGNAL_FUNC (scrollbar_drag_hack_cb), (gpointer) 1); | |
116 gtk_signal_connect (GTK_OBJECT (sb), "button-release-event", | |
117 GTK_SIGNAL_FUNC (scrollbar_drag_hack_cb), (gpointer) 0); | |
118 | |
119 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), SCROLLBAR_GTK_WIDGET (instance), 0, 0); | |
525 | 120 |
121 /* | |
122 ** With gtk version > 1.2.8 the scrollbars in gtk-xemacs and xemacs | |
123 ** from CVS are invisible. In fact they are not invisible but very | |
124 ** thin (0 pixels wide). This is so, because the new gtk code does | |
125 ** not call gtk_widget_request_size() on the newly created | |
126 ** scrollbars anymore. this change was done to allow the theme | |
127 ** engines to manipulate the scrollbar width. This patch calls | |
128 ** gtk_widget_request_size with the newly created scollbars. Maybe | |
129 ** it is better to postpone this call just before the | |
130 ** gtk_widget_show() call is done on the scrolbar. | |
131 */ | |
132 gtk_widget_size_request(GTK_WIDGET(sb), &(GTK_WIDGET(sb)->requisition)); | |
133 | |
462 | 134 gtk_widget_hide (SCROLLBAR_GTK_WIDGET (instance)); |
135 } | |
136 | |
137 #define UPDATE_DATA_FIELD(field) \ | |
138 if (new_##field >= 0 && \ | |
139 SCROLLBAR_GTK_POS_DATA (inst).field != new_##field) { \ | |
140 SCROLLBAR_GTK_POS_DATA (inst).field = new_##field; \ | |
141 inst->scrollbar_instance_changed = 1; \ | |
142 } | |
143 | |
144 /* A device method. */ | |
145 /* #### The -1 check is such a hack. */ | |
146 static void | |
147 gtk_update_scrollbar_instance_values (struct window *w, | |
148 struct scrollbar_instance *inst, | |
149 int new_line_increment, | |
150 int new_page_increment, | |
151 int new_minimum, int new_maximum, | |
152 int new_slider_size, | |
153 int new_slider_position, | |
154 int new_scrollbar_width, | |
155 int new_scrollbar_height, | |
156 int new_scrollbar_x, int new_scrollbar_y) | |
157 { | |
158 UPDATE_DATA_FIELD (line_increment); | |
159 UPDATE_DATA_FIELD (page_increment); | |
160 UPDATE_DATA_FIELD (minimum); | |
161 UPDATE_DATA_FIELD (maximum); | |
162 UPDATE_DATA_FIELD (slider_size); | |
163 UPDATE_DATA_FIELD (slider_position); | |
164 UPDATE_DATA_FIELD (scrollbar_width); | |
165 UPDATE_DATA_FIELD (scrollbar_height); | |
166 UPDATE_DATA_FIELD (scrollbar_x); | |
167 UPDATE_DATA_FIELD (scrollbar_y); | |
168 | |
169 if (w && !vertical_drag_in_progress) | |
170 { | |
171 int new_vov = SCROLLBAR_GTK_POS_DATA (inst).slider_position; | |
172 int new_vows = marker_position (w->start[CURRENT_DISP]); | |
173 | |
174 if (SCROLLBAR_GTK_VDRAG_ORIG_VALUE (inst) != new_vov) | |
175 { | |
176 SCROLLBAR_GTK_VDRAG_ORIG_VALUE (inst) = new_vov; | |
177 inst->scrollbar_instance_changed = 1; | |
178 } | |
179 if (SCROLLBAR_GTK_VDRAG_ORIG_WINDOW_START (inst) != new_vows) | |
180 { | |
181 SCROLLBAR_GTK_VDRAG_ORIG_WINDOW_START (inst) = new_vows; | |
182 inst->scrollbar_instance_changed = 1; | |
183 } | |
184 } | |
185 } | |
186 | |
187 /* Used by gtk_update_scrollbar_instance_status. */ | |
188 static void | |
189 update_one_widget_scrollbar_pointer (struct window *w, GtkWidget *wid) | |
190 { | |
191 if (!wid->window) | |
192 gtk_widget_realize (wid); | |
193 | |
194 if (POINTER_IMAGE_INSTANCEP (w->scrollbar_pointer)) | |
195 { | |
196 gdk_window_set_cursor (GET_GTK_WIDGET_WINDOW (wid), | |
197 XIMAGE_INSTANCE_GTK_CURSOR (w->scrollbar_pointer)); | |
198 gdk_flush (); | |
199 } | |
200 } | |
201 | |
202 /* A device method. */ | |
203 static void | |
204 gtk_update_scrollbar_instance_status (struct window *w, int active, int size, | |
205 struct scrollbar_instance *instance) | |
206 { | |
207 struct frame *f = XFRAME (w->frame); | |
208 GtkWidget *wid = SCROLLBAR_GTK_WIDGET (instance); | |
209 gboolean managed = GTK_WIDGET_MAPPED (wid); | |
210 | |
211 if (active && size) | |
212 { | |
213 if (instance->scrollbar_instance_changed) | |
214 { | |
215 /* Need to set the height, width, and position of the widget */ | |
216 GtkAdjustment *adj = gtk_range_get_adjustment (GTK_RANGE (wid)); | |
217 scrollbar_values *pos_data = & SCROLLBAR_GTK_POS_DATA (instance); | |
218 int modified_p = 0; | |
219 | |
220 /* We do not want to update the size all the time if we can | |
221 help it. This cuts down on annoying flicker. | |
222 */ | |
223 if ((wid->allocation.width != pos_data->scrollbar_width) || | |
224 (wid->allocation.height != pos_data->scrollbar_height)) | |
225 { | |
226 gtk_widget_set_usize (wid, | |
227 pos_data->scrollbar_width, | |
228 pos_data->scrollbar_height); | |
2195 | 229 |
230 /* | |
231 UGLY! UGLY! UGLY! Changes to wid->allocation are queued and | |
232 not performed until the GTK event loop. However, when the | |
233 fontlock progress bar is run, the vertical scrollbar's height | |
234 is change and then changed back before events are again | |
235 processed. This means that the change back is not seen and | |
236 the scrollbar is left too short. Fix this by making the | |
237 change manually so the test above sees the change. This does | |
238 not seem to cause problems in other cases. | |
239 */ | |
240 | |
241 wid->allocation.width = pos_data->scrollbar_width; | |
242 wid->allocation.height = pos_data->scrollbar_height; | |
243 | |
462 | 244 modified_p = 1; |
245 } | |
246 | |
247 /* Ditto for the x/y position. */ | |
248 if ((wid->allocation.x != pos_data->scrollbar_x) || | |
249 (wid->allocation.y != pos_data->scrollbar_y)) | |
250 { | |
251 gtk_fixed_move (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), | |
252 wid, | |
253 pos_data->scrollbar_x, | |
254 pos_data->scrollbar_y); | |
2195 | 255 |
256 /* | |
257 UGLY! UGLY! UGLY! Changes to wid->allocation are queued and | |
258 not performed until the GTK event loop. However, when the | |
259 fontlock progress bar is run, the horizontal scrollbar's | |
260 position is change and then changed back before events are | |
261 again processed. This means that the change back is not seen | |
262 and the scrollbar is left in the wrong position. Fix this by | |
263 making the change manually so the test above sees the change. | |
264 This does not seem to cause problems in other cases. | |
265 */ | |
266 | |
267 wid->allocation.x = pos_data->scrollbar_x; | |
268 wid->allocation.y = pos_data->scrollbar_y; | |
269 | |
462 | 270 modified_p = 1; |
271 } | |
272 | |
273 adj->lower = pos_data->minimum; | |
274 adj->upper = pos_data->maximum; | |
275 adj->page_increment = pos_data->slider_size + 1; | |
276 adj->step_increment = w->max_line_len - 1; | |
277 adj->page_size = pos_data->slider_size + 1; | |
278 adj->value = pos_data->slider_position; | |
279 | |
280 /* But, if we didn't resize or move the scrollbar, the | |
281 widget will not get redrawn correctly when the user | |
282 scrolls around in the XEmacs frame manually. So we | |
283 update the slider manually here. | |
284 */ | |
285 if (!modified_p) | |
286 gtk_range_slider_update (GTK_RANGE (wid)); | |
287 | |
288 instance->scrollbar_instance_changed = 0; | |
289 } | |
290 | |
291 if (!managed) | |
292 { | |
293 gtk_widget_show (wid); | |
294 update_one_widget_scrollbar_pointer (w, wid); | |
295 } | |
296 } | |
297 else if (managed) | |
298 { | |
299 gtk_widget_hide (wid); | |
300 } | |
301 } | |
302 | |
303 enum gtk_scrollbar_loop | |
304 { | |
305 GTK_FIND_SCROLLBAR_WINDOW_MIRROR, | |
306 GTK_SET_SCROLLBAR_POINTER, | |
307 GTK_WINDOW_IS_SCROLLBAR, | |
308 GTK_UPDATE_FRAME_SCROLLBARS | |
309 }; | |
310 | |
311 static struct window_mirror * | |
312 gtk_scrollbar_loop (enum gtk_scrollbar_loop type, Lisp_Object window, | |
313 struct window_mirror *mir, | |
314 GUI_ID id, GdkWindow *x_win) | |
315 { | |
316 struct window_mirror *retval = NULL; | |
317 | |
318 while (mir) | |
319 { | |
320 struct scrollbar_instance *vinstance = mir->scrollbar_vertical_instance; | |
321 struct scrollbar_instance *hinstance = mir->scrollbar_horizontal_instance; | |
322 struct window *w = XWINDOW (window); | |
323 | |
324 if (mir->vchild) | |
325 retval = gtk_scrollbar_loop (type, w->vchild, mir->vchild, id, x_win); | |
326 else if (mir->hchild) | |
327 retval = gtk_scrollbar_loop (type, w->hchild, mir->hchild, id, x_win); | |
328 if (retval) | |
329 return retval; | |
330 | |
331 if (hinstance || vinstance) | |
332 { | |
333 switch (type) | |
334 { | |
335 case GTK_FIND_SCROLLBAR_WINDOW_MIRROR: | |
336 if ((vinstance && SCROLLBAR_GTK_ID (vinstance) == id) || | |
337 (hinstance && SCROLLBAR_GTK_ID (hinstance) == id)) | |
338 return mir; | |
339 break; | |
340 case GTK_UPDATE_FRAME_SCROLLBARS: | |
341 if (!mir->vchild && !mir->hchild) | |
342 update_window_scrollbars (w, mir, 1, 0); | |
343 break; | |
344 case GTK_SET_SCROLLBAR_POINTER: | |
345 if (!mir->vchild && !mir->hchild) | |
346 { | |
347 GtkWidget *widget; | |
348 | |
349 widget = SCROLLBAR_GTK_WIDGET (hinstance); | |
350 if (widget && GTK_WIDGET_MAPPED (widget)) | |
351 update_one_widget_scrollbar_pointer (w, widget); | |
352 | |
353 widget = SCROLLBAR_GTK_WIDGET (vinstance); | |
354 if (widget && GTK_WIDGET_MAPPED (widget)) | |
355 update_one_widget_scrollbar_pointer (w, widget); | |
356 } | |
357 break; | |
358 case GTK_WINDOW_IS_SCROLLBAR: | |
359 if (!mir->vchild && !mir->hchild) | |
360 { | |
361 GtkWidget *widget; | |
362 | |
363 widget = SCROLLBAR_GTK_WIDGET (hinstance); | |
364 if (widget && GTK_WIDGET_MAPPED (widget) && | |
365 GET_GTK_WIDGET_WINDOW (widget) == x_win) | |
366 return (struct window_mirror *) 1; | |
367 | |
368 widget = SCROLLBAR_GTK_WIDGET (vinstance); | |
369 if (widget && GTK_WIDGET_MAPPED (widget) && | |
370 GET_GTK_WIDGET_WINDOW (widget) == x_win) | |
371 return (struct window_mirror *) 1; | |
372 } | |
373 break; | |
374 default: | |
2500 | 375 ABORT (); |
462 | 376 } |
377 } | |
378 | |
379 mir = mir->next; | |
380 window = w->next; | |
381 } | |
382 | |
383 return NULL; | |
384 } | |
385 | |
386 /* Used by callbacks. */ | |
387 static struct window_mirror * | |
388 find_scrollbar_window_mirror (struct frame *f, GUI_ID id) | |
389 { | |
390 if (f->mirror_dirty) | |
391 update_frame_window_mirror (f); | |
392 return gtk_scrollbar_loop (GTK_FIND_SCROLLBAR_WINDOW_MIRROR, f->root_window, | |
617 | 393 XWINDOW_MIRROR (f->root_mirror), id, |
394 (GdkWindow *) NULL); | |
462 | 395 } |
396 | |
397 static gboolean | |
398 scrollbar_cb (GtkAdjustment *adj, gpointer user_data) | |
399 { | |
400 /* This function can GC */ | |
401 int vertical = (int) user_data; | |
2168 | 402 struct frame *f = (struct frame*) gtk_object_get_data (GTK_OBJECT (adj), GTK_DATA_FRAME_IDENTIFIER); |
617 | 403 struct scrollbar_instance *instance; |
2168 | 404 GUI_ID id = (GUI_ID) gtk_object_get_data (GTK_OBJECT (adj), GTK_DATA_GUI_IDENTIFIER); |
462 | 405 Lisp_Object win, frame; |
406 struct window_mirror *mirror; | |
407 Lisp_Object event_type = Qnil; | |
408 Lisp_Object event_data = Qnil; | |
409 | |
410 if (!f) | |
411 return(FALSE); | |
412 | |
413 mirror = find_scrollbar_window_mirror (f, id); | |
414 if (!mirror) | |
415 return(FALSE); | |
416 | |
417 win = real_window (mirror, 1); | |
418 | |
419 if (NILP (win)) | |
420 return(FALSE); | |
421 instance = vertical ? mirror->scrollbar_vertical_instance : mirror->scrollbar_horizontal_instance; | |
422 frame = WINDOW_FRAME (XWINDOW (win)); | |
423 | |
424 inhibit_slider_size_change = 0; | |
425 switch (GTK_RANGE (SCROLLBAR_GTK_WIDGET (instance))->scroll_type) | |
426 { | |
427 case GTK_SCROLL_PAGE_BACKWARD: | |
428 event_type = vertical ? Qscrollbar_page_up : Qscrollbar_page_left; | |
429 event_data = Fcons (win, Qnil); | |
430 break; | |
431 case GTK_SCROLL_PAGE_FORWARD: | |
432 event_type = vertical ? Qscrollbar_page_down : Qscrollbar_page_right; | |
433 event_data = Fcons (win, Qnil); | |
434 break; | |
435 case GTK_SCROLL_STEP_FORWARD: | |
436 event_type = vertical ? Qscrollbar_line_down : Qscrollbar_char_right; | |
437 event_data = win; | |
438 break; | |
439 case GTK_SCROLL_STEP_BACKWARD: | |
440 event_type = vertical ? Qscrollbar_line_up : Qscrollbar_char_left; | |
441 event_data = win; | |
442 break; | |
443 case GTK_SCROLL_NONE: | |
444 case GTK_SCROLL_JUMP: | |
445 inhibit_slider_size_change = 1; | |
446 event_type = vertical ? Qscrollbar_vertical_drag : Qscrollbar_horizontal_drag; | |
447 event_data = Fcons (win, make_int ((int)adj->value)); | |
448 break; | |
449 default: | |
2500 | 450 ABORT(); |
462 | 451 } |
452 | |
453 signal_special_gtk_user_event (frame, event_type, event_data); | |
454 | |
455 return (TRUE); | |
456 } | |
457 | |
458 static void | |
459 gtk_scrollbar_pointer_changed_in_window (struct window *w) | |
460 { | |
793 | 461 Lisp_Object window = wrap_window (w); |
462 | 462 |
617 | 463 gtk_scrollbar_loop (GTK_SET_SCROLLBAR_POINTER, window, |
464 find_window_mirror (w), 0, (GdkWindow *) NULL); | |
462 | 465 } |
466 | |
467 /* #### BILL!!! This comment is not true for Gtk - should it be? */ | |
468 /* Make sure that all scrollbars on frame are up-to-date. Called | |
469 directly from gtk_set_frame_properties in frame-gtk.c*/ | |
470 void | |
471 gtk_update_frame_scrollbars (struct frame *f) | |
472 { | |
617 | 473 gtk_scrollbar_loop (GTK_UPDATE_FRAME_SCROLLBARS, f->root_window, |
474 XWINDOW_MIRROR (f->root_mirror), | |
462 | 475 0, (GdkWindow *) NULL); |
476 } | |
477 | |
478 #ifdef MEMORY_USAGE_STATS | |
479 static int | |
2286 | 480 gtk_compute_scrollbar_instance_usage (struct device *UNUSED (d), |
462 | 481 struct scrollbar_instance *inst, |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
482 struct usage_stats *ustats) |
462 | 483 { |
484 int total = 0; | |
485 | |
486 while (inst) | |
487 { | |
488 struct gtk_scrollbar_data *data = | |
489 (struct gtk_scrollbar_data *) inst->scrollbar_data; | |
490 | |
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
4976
diff
changeset
|
491 total += malloced_storage_size (data, sizeof (*data), ustats); |
462 | 492 inst = inst->next; |
493 } | |
494 | |
495 return total; | |
496 } | |
497 | |
498 #endif /* MEMORY_USAGE_STATS */ | |
499 | |
500 | |
501 /************************************************************************/ | |
502 /* initialization */ | |
503 /************************************************************************/ | |
504 | |
505 void | |
506 console_type_create_scrollbar_gtk (void) | |
507 { | |
508 CONSOLE_HAS_METHOD (gtk, inhibit_scrollbar_slider_size_change); | |
509 CONSOLE_HAS_METHOD (gtk, free_scrollbar_instance); | |
510 CONSOLE_HAS_METHOD (gtk, release_scrollbar_instance); | |
511 CONSOLE_HAS_METHOD (gtk, create_scrollbar_instance); | |
512 CONSOLE_HAS_METHOD (gtk, update_scrollbar_instance_values); | |
513 CONSOLE_HAS_METHOD (gtk, update_scrollbar_instance_status); | |
514 CONSOLE_HAS_METHOD (gtk, scrollbar_pointer_changed_in_window); | |
515 #ifdef MEMORY_USAGE_STATS | |
516 CONSOLE_HAS_METHOD (gtk, compute_scrollbar_instance_usage); | |
517 #endif /* MEMORY_USAGE_STATS */ | |
518 } | |
519 | |
520 void | |
521 vars_of_scrollbar_gtk (void) | |
522 { | |
523 Fprovide (intern ("gtk-scrollbars")); | |
524 } |