Mercurial > hg > xemacs-beta
annotate src/scrollbar-msw.c @ 5013:ae48681c47fa
changes to VOID_TO_LISP et al.
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-02-08 Ben Wing <ben@xemacs.org>
* casetab.c (compute_canon_mapper):
* casetab.c (initialize_identity_mapper):
* casetab.c (compute_up_or_eqv_mapper):
* casetab.c (recompute_case_table):
* casetab.c (set_case_table):
* chartab.c (copy_mapper):
* chartab.c (copy_char_table_range):
* chartab.c (get_range_char_table_1):
* console.c (find_nonminibuffer_frame_not_on_console_predicate):
* console.c (find_nonminibuffer_frame_not_on_console):
* console.c (nuke_all_console_slots):
* device.c:
* device.c (find_nonminibuffer_frame_not_on_device_predicate):
* device.c (find_nonminibuffer_frame_not_on_device):
* dialog-msw.c (dialog_proc):
* dialog-msw.c (handle_question_dialog_box):
* dialog-x.c (maybe_run_dbox_text_callback):
* eval.c:
* eval.c (safe_run_hook_trapping_problems_1):
* eval.c (safe_run_hook_trapping_problems):
* event-msw.c:
* event-msw.c (mswindows_wnd_proc):
* event-msw.c (mswindows_find_frame):
* faces.c (update_face_inheritance_mapper):
* frame-msw.c (mswindows_init_frame_1):
* frame-msw.c (mswindows_get_mouse_position):
* frame-msw.c (mswindows_get_frame_parent):
* glade.c (connector):
* glade.c (Fglade_xml_signal_connect):
* glade.c (Fglade_xml_signal_autoconnect):
* glade.c (Fglade_xml_textdomain):
* glyphs-msw.c (mswindows_subwindow_instantiate):
* glyphs-msw.c (mswindows_widget_instantiate):
* glyphs.c (check_instance_cache_mapper):
* glyphs.c (check_window_subwindow_cache):
* glyphs.c (check_image_instance_structure):
* gui-x.c (snarf_widget_value_mapper):
* gui-x.c (popup_selection_callback):
* gui-x.c (button_item_to_widget_value):
* keymap.c (map_keymap_mapper):
* keymap.c (Fmap_keymap):
* menubar-gtk.c (__torn_off_sir):
* menubar-gtk.c (__activate_menu):
* menubar-gtk.c (menu_convert):
* menubar-gtk.c (__generic_button_callback):
* menubar-gtk.c (menu_descriptor_to_widget_1):
* menubar-msw.c:
* menubar-msw.c (EMPTY_ITEM_ID):
* menubar-x.c (menu_item_descriptor_to_widget_value_1):
* menubar-x.c (pre_activate_callback):
* menubar-x.c (command_builder_operate_menu_accelerator):
* menubar-x.c (command_builder_find_menu_accelerator):
* print.c (print_internal):
* process-unix.c (close_process_descs_mapfun):
* process.c (get_process_from_usid):
* process.c (init_process_io_handles):
* profile.c (sigprof_handler):
* profile.c (get_profiling_info_timing_maphash):
* profile.c (Fget_profiling_info):
* profile.c (set_profiling_info_timing_maphash):
* profile.c (mark_profiling_info_maphash):
* scrollbar-msw.c (mswindows_create_scrollbar_instance):
* scrollbar-msw.c (mswindows_free_scrollbar_instance):
* scrollbar-msw.c (mswindows_handle_scrollbar_event):
* specifier.c (recompute_cached_specifier_everywhere_mapfun):
* specifier.c (recompute_cached_specifier_everywhere):
* syntax.c (copy_to_mirrortab):
* syntax.c (copy_if_not_already_present):
* syntax.c (update_just_this_syntax_table):
* text.c (new_dfc_convert_now_damn_it):
* text.h (LISP_STRING_TO_EXTERNAL):
* tooltalk.c:
* tooltalk.c (tooltalk_message_callback):
* tooltalk.c (tooltalk_pattern_callback):
* tooltalk.c (Fcreate_tooltalk_message):
* tooltalk.c (Fcreate_tooltalk_pattern):
* ui-byhand.c (__generic_toolbar_callback):
* ui-byhand.c (generic_toolbar_insert_item):
* ui-byhand.c (__emacs_gtk_ctree_recurse_internal):
* ui-byhand.c (Fgtk_ctree_recurse):
* ui-gtk.c (__internal_callback_destroy):
* ui-gtk.c (__internal_callback_marshal):
* ui-gtk.c (Fgtk_signal_connect):
* ui-gtk.c (gtk_type_to_lisp):
* ui-gtk.c (lisp_to_gtk_type):
* ui-gtk.c (lisp_to_gtk_ret_type):
* lisp-disunion.h:
* lisp-disunion.h (NON_LVALUE):
* lisp-union.h:
* lisp.h (LISP_HASH):
Rename:
LISP_TO_VOID -> STORE_LISP_IN_VOID
VOID_TO_LISP -> GET_LISP_FROM_VOID
These new names are meant to clearly identify that the Lisp object
is the source and void the sink, and that they can't be used the
other way around -- they aren't exact opposites despite the old
names. The names are also important given the new functions
created just below. Also, clarify comments in lisp-union.h and
lisp-disunion.h about the use of the functions.
* lisp.h:
New functions STORE_VOID_IN_LISP and GET_VOID_FROM_LISP. These
are different from the above in that the source is a void *
(previously, you had to use make_opaque_ptr()).
* eval.c (restore_lisp_object):
* eval.c (record_unwind_protect_restoring_lisp_object):
* eval.c (struct restore_int):
* eval.c (restore_int):
* eval.c (record_unwind_protect_restoring_int):
* eval.c (free_pointer):
* eval.c (record_unwind_protect_freeing):
* eval.c (free_dynarr):
* eval.c (record_unwind_protect_freeing_dynarr):
* eval.c (unbind_to_1):
Use STORE_VOID_IN_LISP and GET_VOID_FROM_LISP to eliminate the
use of make_opaque_ptr() and mostly eliminate Lisp consing
entirely in the use of these various record_unwind_protect_*
functions as well as internal_bind_* (e.g. internal_bind_int).
* tests.c:
* tests.c (Ftest_store_void_in_lisp):
* tests.c (syms_of_tests):
* tests.c (vars_of_tests):
Add an C-assert-style test to test STORE_VOID_IN_LISP and
GET_VOID_FROM_LISP to make sure the same value comes back that
was put in.
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 08 Feb 2010 06:42:16 -0600 |
parents | 16112448d484 |
children | 1fae11d56ad2 |
rev | line source |
---|---|
428 | 1 /* scrollbar implementation -- mswindows interface. |
2 Copyright (C) 1994, 1995 Board of Trustees, University of Illinois. | |
3 Copyright (C) 1994 Amdahl Corporation. | |
4 Copyright (C) 1995 Sun Microsystems, Inc. | |
5 Copyright (C) 1995 Darrell Kindred <dkindred+@cmu.edu>. | |
771 | 6 Copyright (C) 2001, 2002 Ben Wing. |
428 | 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 | |
771 | 27 /* This file essentially Mule-ized (except perhaps some Unicode splitting). |
28 5-2000. */ | |
29 | |
428 | 30 #include <config.h> |
31 #include "lisp.h" | |
32 | |
800 | 33 #include "device.h" |
617 | 34 #include "elhash.h" |
428 | 35 #include "events.h" |
872 | 36 #include "frame-impl.h" |
617 | 37 #include "opaque.h" |
428 | 38 #include "scrollbar.h" |
39 #include "specifier.h" | |
872 | 40 #include "window-impl.h" |
428 | 41 |
872 | 42 #include "console-msw-impl.h" |
800 | 43 #include "scrollbar-msw.h" |
44 | |
428 | 45 /* We use a similar sort of vertical scrollbar drag hack for mswindows |
46 * scrollbars as is used for Motif or Lucid scrollbars under X. | |
47 * We do character-based instead of line-based scrolling, which can mean that | |
48 * without the hack it is impossible to drag to the end of a buffer. */ | |
49 #define VERTICAL_SCROLLBAR_DRAG_HACK | |
50 | |
51 static int vertical_drag_in_progress = 0; | |
673 | 52 extern Lisp_Object mswindows_find_frame (HWND hwnd); |
428 | 53 |
617 | 54 /* As long as the HWND is around, the scrollbar instance must be GC-protected. |
55 We have gotten crashes, apparently from trying to access a dead, freed | |
56 frame inside of a window mirror pointed to by the scrollbar structure. */ | |
57 static Lisp_Object Vmswindows_scrollbar_instance_table; | |
58 | |
428 | 59 static void |
60 mswindows_create_scrollbar_instance (struct frame *f, int vertical, | |
61 struct scrollbar_instance *sb) | |
62 { | |
63 int orientation; | |
617 | 64 Lisp_Object ptr; |
442 | 65 |
428 | 66 sb->scrollbar_data = xnew_and_zero (struct mswindows_scrollbar_data); |
442 | 67 |
428 | 68 if (vertical) |
69 orientation = SBS_VERT; | |
70 else | |
71 orientation = SBS_HORZ; | |
442 | 72 |
428 | 73 SCROLLBAR_MSW_HANDLE (sb) = |
771 | 74 qxeCreateWindowEx (0, XETEXT ("SCROLLBAR"), 0, orientation|WS_CHILD, |
75 CW_USEDEFAULT, CW_USEDEFAULT, | |
76 CW_USEDEFAULT, CW_USEDEFAULT, | |
77 FRAME_MSWINDOWS_HANDLE (f), | |
78 NULL, NULL, NULL); | |
546 | 79 SCROLLBAR_MSW_INFO (sb).cbSize = sizeof (SCROLLINFO); |
428 | 80 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL; |
617 | 81 GetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, |
82 &SCROLLBAR_MSW_INFO (sb)); | |
83 ptr = make_opaque_ptr (SCROLLBAR_MSW_HANDLE (sb)); | |
84 Fputhash (ptr, wrap_scrollbar_instance (sb), | |
85 Vmswindows_scrollbar_instance_table); | |
771 | 86 qxeSetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA, |
5013 | 87 (LONG) STORE_LISP_IN_VOID (ptr)); |
428 | 88 } |
89 | |
90 static void | |
91 mswindows_free_scrollbar_instance (struct scrollbar_instance *sb) | |
92 { | |
3482 | 93 if (sb->scrollbar_data) |
94 { | |
95 void *opaque = | |
96 (void *) qxeGetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_USERDATA); | |
97 Lisp_Object ptr; | |
617 | 98 |
5013 | 99 ptr = GET_LISP_FROM_VOID (opaque); |
3482 | 100 assert (OPAQUE_PTRP (ptr)); |
101 ptr = Fremhash (ptr, Vmswindows_scrollbar_instance_table); | |
102 assert (!NILP (ptr)); | |
103 DestroyWindow (SCROLLBAR_MSW_HANDLE (sb)); | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
3482
diff
changeset
|
104 xfree (sb->scrollbar_data); |
3482 | 105 } |
428 | 106 } |
107 | |
108 static void | |
611 | 109 unshow_that_mofo (void *handle) |
110 { | |
111 ShowScrollBar ((HWND) handle, SB_CTL, 0); | |
112 } | |
113 | |
114 static void | |
428 | 115 mswindows_release_scrollbar_instance (struct scrollbar_instance *sb) |
116 { | |
611 | 117 if (gc_in_progress) |
118 /* #### way bogus! need to remove the offending call. | |
119 see mark_redisplay(). */ | |
120 register_post_gc_action (unshow_that_mofo, | |
121 (void *) SCROLLBAR_MSW_HANDLE (sb)); | |
122 else | |
123 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, 0); | |
428 | 124 SCROLLBAR_MSW_SIZE (sb) = 0; |
125 } | |
126 | |
127 #define UPDATE_POS_FIELD(field) \ | |
128 if (new_##field >= 0 && SCROLLBAR_MSW_DATA (sb)->field != new_##field) { \ | |
129 SCROLLBAR_MSW_DATA (sb)->field = new_##field; \ | |
130 pos_changed = 1; \ | |
131 } | |
132 | |
133 static void | |
2286 | 134 mswindows_update_scrollbar_instance_values (struct window *UNUSED (w), |
428 | 135 struct scrollbar_instance *sb, |
2286 | 136 int UNUSED (new_line_increment), |
137 int UNUSED (new_page_increment), | |
428 | 138 int new_minimum, int new_maximum, |
139 int new_slider_size, | |
140 int new_slider_position, | |
141 int new_scrollbar_width, | |
142 int new_scrollbar_height, | |
143 int new_scrollbar_x, | |
144 int new_scrollbar_y) | |
145 { | |
146 int pos_changed = 0; | |
771 | 147 int vert = qxeGetWindowLong (SCROLLBAR_MSW_HANDLE (sb), GWL_STYLE) & SBS_VERT; |
428 | 148 |
149 #if 0 | |
150 stderr_out ("[%d, %d], page = %d, pos = %d, inhibit = %d\n", new_minimum, new_maximum, | |
151 new_slider_size, new_slider_position,inhibit_slider_size_change); | |
152 #endif | |
153 | |
154 /* These might be optimized, but since at least one will change at each | |
155 call, it's probably not worth it. */ | |
156 SCROLLBAR_MSW_INFO (sb).nMin = new_minimum; | |
157 SCROLLBAR_MSW_INFO (sb).nMax = new_maximum; | |
158 SCROLLBAR_MSW_INFO (sb).nPage = new_slider_size + 1; /* +1 for DISABLENOSCROLL */ | |
159 SCROLLBAR_MSW_INFO (sb).nPos = new_slider_position; | |
160 #ifndef VERTICAL_SCROLLBAR_DRAG_HACK | |
161 SCROLLBAR_MSW_INFO (sb).fMask = ((vert && vertical_drag_in_progress) | |
162 ? SIF_RANGE | SIF_POS | |
163 : SIF_ALL | SIF_DISABLENOSCROLL); | |
164 #else | |
165 SCROLLBAR_MSW_INFO (sb).fMask = SIF_ALL | SIF_DISABLENOSCROLL; | |
166 | |
167 /* Ignore XEmacs' requests to update the thumb position and size; they don't | |
168 * bear any relation to reality because we're reporting made-up positions */ | |
169 if (!(vert && vertical_drag_in_progress)) | |
170 #endif | |
171 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb), | |
172 TRUE); | |
173 | |
174 UPDATE_POS_FIELD (scrollbar_x); | |
175 UPDATE_POS_FIELD (scrollbar_y); | |
176 UPDATE_POS_FIELD (scrollbar_width); | |
177 UPDATE_POS_FIELD (scrollbar_height); | |
178 | |
442 | 179 if (pos_changed) |
428 | 180 { |
617 | 181 MoveWindow (SCROLLBAR_MSW_HANDLE (sb), |
182 new_scrollbar_x, new_scrollbar_y, | |
183 new_scrollbar_width, new_scrollbar_height, | |
184 TRUE); | |
428 | 185 } |
186 } | |
187 | |
188 static void | |
2286 | 189 mswindows_update_scrollbar_instance_status (struct window *UNUSED (w), |
190 int UNUSED (active), int size, | |
428 | 191 struct scrollbar_instance *sb) |
192 { | |
193 if (SCROLLBAR_MSW_SIZE (sb) != size) | |
194 { | |
195 SCROLLBAR_MSW_SIZE (sb) = size; | |
196 ShowScrollBar (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, | |
197 SCROLLBAR_MSW_SIZE (sb)); | |
198 SCROLLBAR_MSW_INFO(sb).fMask |= SIF_DISABLENOSCROLL; | |
199 SetScrollInfo(SCROLLBAR_MSW_HANDLE (sb), SB_CTL, &SCROLLBAR_MSW_INFO (sb), TRUE); | |
200 } | |
201 } | |
202 | |
203 void | |
2286 | 204 mswindows_handle_scrollbar_event (HWND hwnd, int code, int UNUSED (pos)) |
428 | 205 { |
206 struct frame *f; | |
207 Lisp_Object win, frame; | |
617 | 208 struct scrollbar_instance *sb = 0; |
209 void *v; | |
428 | 210 SCROLLINFO scrollinfo; |
771 | 211 int vert = qxeGetWindowLong (hwnd, GWL_STYLE) & SBS_VERT; |
428 | 212 int value; |
213 | |
771 | 214 v = (void *) qxeGetWindowLong (hwnd, GWL_USERDATA); |
617 | 215 if (!v) |
546 | 216 { |
617 | 217 /* apparently this can happen, as it was definitely necessary |
218 to put the check in for sb below (VERTICAL_SCROLLBAR_DRAG_HACK) */ | |
546 | 219 frame = mswindows_find_frame (hwnd); |
220 f = XFRAME (frame); | |
221 win = FRAME_SELECTED_WINDOW (f); | |
222 } | |
223 else | |
224 { | |
617 | 225 Lisp_Object ptr; |
5013 | 226 ptr = GET_LISP_FROM_VOID (v); |
617 | 227 assert (OPAQUE_PTRP (ptr)); |
228 ptr = Fgethash (ptr, Vmswindows_scrollbar_instance_table, Qnil); | |
229 sb = XSCROLLBAR_INSTANCE (ptr); | |
664 | 230 /* #### we're still hitting an abort here with 0 as the second |
231 parameter, although only occasionally. It seems that sometimes we | |
232 receive events for scrollbars that don't exist anymore. I assume | |
233 it must happen like this: The user does something that causes a | |
234 scrollbar to disappear (e.g. Alt-TAB, causing recomputation of | |
235 everything in the new frame) and then immediately uses the mouse | |
236 wheel, generating scrollbar events. Both events get posted before | |
237 we have a chance to process them, and in processing the first, the | |
238 scrollbar mentioned in the second disappears. */ | |
239 win = real_window (sb->mirror, 1); | |
240 if (NILP (win)) | |
241 return; | |
617 | 242 frame = WINDOW_FRAME (XWINDOW (win)); |
546 | 243 f = XFRAME (frame); |
244 } | |
428 | 245 |
673 | 246 /* SB_LINEDOWN == SB_CHARLEFT etc. This is the way they will |
247 always be - any Windows is binary compatible backward with | |
248 old programs */ | |
428 | 249 |
250 switch (code) | |
251 { | |
252 case SB_LINEDOWN: | |
253 mswindows_enqueue_misc_user_event | |
254 (frame, vert ? Qscrollbar_line_down : Qscrollbar_char_right, win); | |
255 break; | |
442 | 256 |
428 | 257 case SB_LINEUP: |
258 mswindows_enqueue_misc_user_event | |
259 (frame, vert ? Qscrollbar_line_up : Qscrollbar_char_left, win); | |
260 break; | |
442 | 261 |
428 | 262 case SB_PAGEDOWN: |
263 mswindows_enqueue_misc_user_event | |
264 (win, vert ? Qscrollbar_page_down : Qscrollbar_page_right, | |
265 vert ? Fcons (win, Qnil) : win); | |
266 break; | |
267 | |
268 case SB_PAGEUP: | |
269 mswindows_enqueue_misc_user_event | |
270 (frame, | |
271 vert ? Qscrollbar_page_up : Qscrollbar_page_left, | |
272 vert ? Fcons (win, Qnil) : win); | |
273 break; | |
442 | 274 |
428 | 275 case SB_BOTTOM: |
276 mswindows_enqueue_misc_user_event | |
277 (frame, vert ? Qscrollbar_to_bottom : Qscrollbar_to_right, win); | |
278 break; | |
279 | |
280 case SB_TOP: | |
281 mswindows_enqueue_misc_user_event | |
282 (frame, vert ? Qscrollbar_to_top : Qscrollbar_to_left, win); | |
283 break; | |
284 | |
285 case SB_THUMBTRACK: | |
286 case SB_THUMBPOSITION: | |
287 scrollinfo.cbSize = sizeof(SCROLLINFO); | |
288 scrollinfo.fMask = SIF_ALL; | |
289 GetScrollInfo (hwnd, SB_CTL, &scrollinfo); | |
290 vertical_drag_in_progress = vert; | |
291 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK | |
292 if (vert && (scrollinfo.nTrackPos > scrollinfo.nPos)) | |
293 /* new buffer position = | |
294 * buffer position at start of drag + | |
295 * ((text remaining in buffer at start of drag) * | |
296 * (amount that the thumb has been moved) / | |
297 * (space that remained past end of the thumb at start of drag)) */ | |
298 value = (int) | |
299 (scrollinfo.nPos | |
300 + (((double) | |
301 (scrollinfo.nMax - scrollinfo.nPos) | |
302 * (scrollinfo.nTrackPos - scrollinfo.nPos)) | |
303 / (scrollinfo.nMax - scrollinfo.nPage - scrollinfo.nPos))) | |
304 - 2; /* ensure that the last line doesn't disappear off screen */ | |
305 else | |
306 #endif | |
307 value = scrollinfo.nTrackPos; | |
308 mswindows_enqueue_misc_user_event | |
309 (frame, | |
310 vert ? Qscrollbar_vertical_drag : Qscrollbar_horizontal_drag, | |
311 Fcons (win, make_int (value))); | |
312 break; | |
313 | |
314 case SB_ENDSCROLL: | |
315 #ifdef VERTICAL_SCROLLBAR_DRAG_HACK | |
546 | 316 if (vertical_drag_in_progress && sb) |
428 | 317 /* User has just dropped the thumb - finally update it */ |
318 SetScrollInfo (SCROLLBAR_MSW_HANDLE (sb), SB_CTL, | |
319 &SCROLLBAR_MSW_INFO (sb), TRUE); | |
320 #endif | |
321 vertical_drag_in_progress = 0; | |
322 break; | |
323 } | |
324 } | |
325 | |
326 static int | |
771 | 327 can_scroll (struct scrollbar_instance *scrollbar) |
428 | 328 { |
329 return scrollbar != NULL | |
330 && IsWindowVisible (SCROLLBAR_MSW_HANDLE (scrollbar)) | |
331 && IsWindowEnabled (SCROLLBAR_MSW_HANDLE (scrollbar)); | |
332 } | |
333 | |
334 int | |
464 | 335 mswindows_handle_mousewheel_event (Lisp_Object frame, int keys, int delta, |
336 POINTS where) | |
428 | 337 { |
442 | 338 int hasVertBar, hasHorzBar; /* Indicates presence of scroll bars */ |
428 | 339 unsigned wheelScrollLines = 0; /* Number of lines per wheel notch */ |
826 | 340 Lisp_Object win = Qnil, corpore, sano; |
464 | 341 struct window_mirror *mirror; |
707 | 342 int mene, _mene, tekel, upharsin; |
343 Charbpos mens, sana; | |
344 Charcount in; | |
345 struct window *needle_in_haystack = 0; | |
464 | 346 POINT donde_esta; |
428 | 347 |
464 | 348 donde_esta.x = where.x; |
349 donde_esta.y = where.y; | |
350 | |
351 /* Find the window to scroll */ | |
352 | |
707 | 353 /* The mouse event could actually occur outside of the emacs |
354 frame. */ | |
355 if (ScreenToClient (FRAME_MSWINDOWS_HANDLE (XFRAME (frame)), | |
356 &donde_esta) != 0) | |
357 { | |
819 | 358 /* stderr_out ("donde_esta: %d %d\n", donde_esta.x, donde_esta.y); */ |
359 pixel_to_glyph_translation (XFRAME (frame), donde_esta.x, donde_esta.y, | |
360 &mene, &_mene, &tekel, &upharsin, | |
361 &needle_in_haystack, | |
362 &mens, &sana, &in, &corpore, &sano); | |
363 | |
364 if (needle_in_haystack) | |
365 { | |
366 win = wrap_window (needle_in_haystack); | |
367 /* stderr_out ("found needle\n"); | |
368 debug_print (win); */ | |
369 } | |
707 | 370 } |
819 | 371 |
372 if (!needle_in_haystack) | |
707 | 373 { |
374 win = FRAME_SELECTED_WINDOW (XFRAME (frame)); | |
375 needle_in_haystack = XWINDOW (win); | |
376 } | |
464 | 377 |
707 | 378 mirror = find_window_mirror (needle_in_haystack); |
428 | 379 |
380 /* Check that there is something to scroll */ | |
381 hasVertBar = can_scroll (mirror->scrollbar_vertical_instance); | |
382 hasHorzBar = can_scroll (mirror->scrollbar_horizontal_instance); | |
383 if (!hasVertBar && !hasHorzBar) | |
384 return FALSE; | |
385 | |
386 /* No support for panning and zooming, so ignore */ | |
387 if (keys & (MK_SHIFT | MK_CONTROL)) | |
388 return FALSE; | |
389 | |
390 /* Get the number of lines per wheel delta */ | |
771 | 391 qxeSystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0); |
428 | 392 |
393 /* Calculate the amount to scroll */ | |
394 if (wheelScrollLines == WHEEL_PAGESCROLL) | |
395 { | |
396 /* Scroll by a page */ | |
397 Lisp_Object function; | |
398 if (hasVertBar) | |
399 function = delta > 0 ? Qscrollbar_page_up : Qscrollbar_page_down; | |
400 else | |
401 function = delta > 0 ? Qscrollbar_page_left : Qscrollbar_page_right; | |
402 mswindows_enqueue_misc_user_event (frame, function, Fcons (win, Qnil)); | |
403 } | |
404 else /* Scroll by a number of lines */ | |
405 { | |
406 /* Calc the number of lines to scroll */ | |
407 int toScroll = MulDiv (delta, wheelScrollLines, WHEEL_DELTA); | |
408 | |
409 /* Do the scroll */ | |
410 Lisp_Object function; | |
411 if (hasVertBar) | |
412 function = delta > 0 ? Qscrollbar_line_up : Qscrollbar_line_down; | |
413 else | |
414 function = delta > 0 ? Qscrollbar_char_left : Qscrollbar_char_right; | |
415 if (toScroll < 0) | |
416 toScroll = -toScroll; | |
417 while (toScroll--) | |
418 mswindows_enqueue_misc_user_event (frame, function, win); | |
419 } | |
420 | |
421 return TRUE; | |
422 } | |
423 | |
424 #ifdef MEMORY_USAGE_STATS | |
425 | |
426 static int | |
2286 | 427 mswindows_compute_scrollbar_instance_usage (struct device *UNUSED (d), |
428 struct scrollbar_instance *inst, | |
429 struct overhead_stats *ovstats) | |
428 | 430 { |
431 int total = 0; | |
432 | |
433 while (inst) | |
434 { | |
435 struct mswindows_scrollbar_data *data = | |
436 (struct mswindows_scrollbar_data *) inst->scrollbar_data; | |
437 | |
3024 | 438 total += malloced_storage_size (data, sizeof (*data), ovstats); |
428 | 439 inst = inst->next; |
440 } | |
441 | |
442 return total; | |
443 } | |
444 | |
445 #endif /* MEMORY_USAGE_STATS */ | |
446 | |
447 /************************************************************************/ | |
448 /* Device-specific ghost specifiers initialization */ | |
449 /************************************************************************/ | |
450 | |
617 | 451 DEFUN ("mswindows-init-scrollbar-metrics", Fmswindows_init_scrollbar_metrics, |
452 1, 1, 0, /* | |
428 | 453 */ |
454 (locale)) | |
455 { | |
456 if (DEVICEP (locale)) | |
457 { | |
458 add_spec_to_ghost_specifier (Vscrollbar_width, | |
459 make_int (GetSystemMetrics (SM_CXVSCROLL)), | |
460 locale, Qmswindows, Qnil); | |
461 add_spec_to_ghost_specifier (Vscrollbar_height, | |
462 make_int (GetSystemMetrics (SM_CYHSCROLL)), | |
463 locale, Qmswindows, Qnil); | |
464 } | |
465 return Qnil; | |
466 } | |
467 | |
468 | |
469 /************************************************************************/ | |
470 /* initialization */ | |
471 /************************************************************************/ | |
472 | |
473 void | |
474 console_type_create_scrollbar_mswindows (void) | |
475 { | |
476 CONSOLE_HAS_METHOD (mswindows, create_scrollbar_instance); | |
477 CONSOLE_HAS_METHOD (mswindows, free_scrollbar_instance); | |
478 CONSOLE_HAS_METHOD (mswindows, release_scrollbar_instance); | |
479 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_values); | |
480 CONSOLE_HAS_METHOD (mswindows, update_scrollbar_instance_status); | |
481 /* CONSOLE_HAS_METHOD (mswindows, scrollbar_width_changed_in_frame); */ | |
482 #ifdef MEMORY_USAGE_STATS | |
483 CONSOLE_HAS_METHOD (mswindows, compute_scrollbar_instance_usage); | |
484 #endif | |
485 } | |
486 | |
487 void | |
617 | 488 syms_of_scrollbar_mswindows (void) |
428 | 489 { |
490 DEFSUBR (Fmswindows_init_scrollbar_metrics); | |
491 } | |
492 | |
493 void | |
617 | 494 vars_of_scrollbar_mswindows (void) |
428 | 495 { |
496 Fprovide (intern ("mswindows-scrollbars")); | |
497 | |
617 | 498 staticpro (&Vmswindows_scrollbar_instance_table); |
499 Vmswindows_scrollbar_instance_table = | |
500 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQ); | |
501 } |