1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3 * Copyright (C) 1998-2002 Tor Lillqvist
4 * Copyright (C) 2007-2009 Cody Russell
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
24 * file for a list of people on the GTK+ Team. See the ChangeLog
25 * files for a list of changes. These files are distributed with
26 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29 /* Cannot use TrackMouseEvent, as the stupid WM_MOUSELEAVE message
30 * doesn't tell us where the mouse has gone. Thus we cannot use it to
31 * generate a correct GdkNotifyType. Pity, as using TrackMouseEvent
32 * otherwise would make it possible to reliably generate
33 * GDK_LEAVE_NOTIFY events, which would help get rid of those pesky
34 * tooltips sometimes popping up in the wrong place.
36 * Update: a combination of TrackMouseEvent, GetCursorPos and
37 * GetWindowPos can and is actually used to get rid of those
38 * pesky tooltips. It should be possible to use this for the
39 * whole ENTER/LEAVE NOTIFY handling but some platforms may
40 * not have TrackMouseEvent at all (?) --hb
45 #include <glib/gprintf.h>
48 #include "gdkprivate-win32.h"
49 #include "gdkinput-win32.h"
50 #include "gdkkeysyms.h"
74 #define MK_XBUTTON1 32
75 #define MK_XBUTTON2 64
79 * Private function declarations
82 static gboolean gdk_event_translate (MSG *msg,
84 static void handle_wm_paint (MSG *msg,
86 gboolean return_exposes,
89 static gboolean gdk_event_prepare (GSource *source,
91 static gboolean gdk_event_check (GSource *source);
92 static gboolean gdk_event_dispatch (GSource *source,
96 static void append_event (GdkEvent *event);
97 static gboolean is_modally_blocked (GdkWindow *window);
99 /* Private variable declarations
103 static GdkWindow *p_grab_window = NULL; /* Window that currently holds
107 static GdkWindow *p_grab_confine_to = NULL;
109 static GdkWindow *k_grab_window = NULL; /* Window the holds the
114 static GList *client_filters; /* Filters for client messages */
116 static gboolean p_grab_automatic;
117 static GdkEventMask p_grab_mask;
118 static gboolean p_grab_owner_events, k_grab_owner_events;
119 static HCURSOR p_grab_cursor;
121 static GSourceFuncs event_funcs = {
128 GPollFD event_poll_fd;
130 static GdkWindow *current_toplevel = NULL;
131 static gint current_x, current_y;
132 static gint current_root_x, current_root_y;
133 static UINT client_message;
135 static UINT got_gdk_events_message;
136 static HWND modal_win32_dialog = NULL;
139 static HKL latin_locale = NULL;
142 static gboolean in_ime_composition = FALSE;
143 static UINT modal_timer;
144 static UINT sync_timer = 0;
146 static int debug_indent = 0;
149 assign_object (gpointer lhsp,
152 if (*(gpointer *)lhsp != rhs)
154 if (*(gpointer *)lhsp != NULL)
155 g_object_unref (*(gpointer *)lhsp);
156 *(gpointer *)lhsp = rhs;
163 track_mouse_event (DWORD dwFlags,
166 typedef BOOL (WINAPI *PFN_TrackMouseEvent) (LPTRACKMOUSEEVENT);
167 static PFN_TrackMouseEvent p_TrackMouseEvent = NULL;
168 static gboolean once = FALSE;
173 HINSTANCE commctrl32;
175 user32 = GetModuleHandle ("user32.dll");
176 if ((p_TrackMouseEvent = (PFN_TrackMouseEvent)GetProcAddress (user32, "TrackMouseEvent")) == NULL)
178 if ((commctrl32 = LoadLibrary ("commctrl32.dll")) != NULL)
179 p_TrackMouseEvent = (PFN_TrackMouseEvent)
180 GetProcAddress (commctrl32, "_TrackMouseEvent");
185 if (p_TrackMouseEvent)
188 tme.cbSize = sizeof(TRACKMOUSEEVENT);
189 tme.dwFlags = dwFlags;
190 tme.hwndTrack = hwnd;
191 tme.dwHoverTime = HOVER_DEFAULT; /* not used */
193 if (!p_TrackMouseEvent (&tme))
194 WIN32_API_FAILED ("TrackMouseEvent");
195 else if (dwFlags == TME_LEAVE)
196 GDK_NOTE (EVENTS, g_print(" (TrackMouseEvent %p)", hwnd));
197 else if (dwFlags == TME_CANCEL)
198 GDK_NOTE (EVENTS, g_print(" (cancel TrackMouseEvent %p)", hwnd));
203 _gdk_win32_get_next_tick (gulong suggested_tick)
205 static gulong cur_tick = 0;
207 if (suggested_tick == 0)
208 suggested_tick = GetTickCount ();
209 if (suggested_tick <= cur_tick)
212 return cur_tick = suggested_tick;
216 generate_focus_event (GdkWindow *window,
221 event = gdk_event_new (GDK_FOCUS_CHANGE);
222 event->focus_change.window = window;
223 event->focus_change.in = in;
225 append_event (event);
229 generate_grab_broken_event (GdkWindow *window,
231 GdkWindow *grab_window)
233 GdkEvent *event = gdk_event_new (GDK_GRAB_BROKEN);
235 event->grab_broken.window = window;
236 event->grab_broken.send_event = 0;
237 event->grab_broken.keyboard = keyboard;
238 event->grab_broken.implicit = FALSE;
239 event->grab_broken.grab_window = grab_window;
241 append_event (event);
245 inner_window_procedure (HWND hwnd,
255 msg.message = message;
258 msg.time = _gdk_win32_get_next_tick (0);
259 pos = GetMessagePos ();
260 msg.pt.x = GET_X_LPARAM (pos);
261 msg.pt.y = GET_Y_LPARAM (pos);
263 if (gdk_event_translate (&msg, &ret_val))
265 /* If gdk_event_translate() returns TRUE, we return ret_val from
266 * the window procedure.
268 if (modal_win32_dialog)
269 PostMessageW (modal_win32_dialog, got_gdk_events_message,
275 /* Otherwise call DefWindowProcW(). */
276 GDK_NOTE (EVENTS, g_print (" DefWindowProcW"));
277 return DefWindowProcW (hwnd, message, wparam, lparam);
282 _gdk_win32_window_procedure (HWND hwnd,
289 GDK_NOTE (EVENTS, g_print ("%s%*s%s %p",
290 (debug_indent > 0 ? "\n" : ""),
292 _gdk_win32_message_to_string (message), hwnd));
294 retval = inner_window_procedure (hwnd, message, wparam, lparam);
297 GDK_NOTE (EVENTS, g_print (" => %I64d%s", (gint64) retval, (debug_indent == 0 ? "\n" : "")));
303 _gdk_events_init (void)
310 /* List of languages that use a latin keyboard. Somewhat sorted in
311 * "order of least surprise", in case we have to load one of them if
312 * the user only has arabic loaded, for instance.
314 static int latin_languages[] = {
320 /* Rest in numeric order */
349 client_message = RegisterWindowMessage ("GDK_WIN32_CLIENT_MESSAGE");
350 got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
353 /* Check if we have some input locale identifier loaded that uses a
354 * latin keyboard, to be able to get the virtual-key code for the
355 * latin characters corresponding to ASCII control characters.
357 if ((n = GetKeyboardLayoutList (0, NULL)) == 0)
358 WIN32_API_FAILED ("GetKeyboardLayoutList");
361 HKL *hkl_list = g_new (HKL, n);
362 if (GetKeyboardLayoutList (n, hkl_list) == 0)
363 WIN32_API_FAILED ("GetKeyboardLayoutList");
366 for (i = 0; latin_locale == NULL && i < n; i++)
367 for (j = 0; j < G_N_ELEMENTS (latin_languages); j++)
368 if (PRIMARYLANGID (LOWORD (hkl_list[i])) == latin_languages[j])
370 latin_locale = hkl_list [i];
377 if (latin_locale == NULL)
379 /* Try to load a keyboard layout with latin characters then.
382 while (latin_locale == NULL && i < G_N_ELEMENTS (latin_languages))
385 g_sprintf (id, "%08x", MAKELANGID (latin_languages[i++], SUBLANG_DEFAULT));
386 latin_locale = LoadKeyboardLayout (id, KLF_NOTELLSHELL|KLF_SUBSTITUTE_OK);
390 GDK_NOTE (EVENTS, g_print ("latin_locale = %08x\n", (guint) latin_locale));
393 source = g_source_new (&event_funcs, sizeof (GSource));
394 g_source_set_priority (source, GDK_PRIORITY_EVENTS);
397 event_poll_fd.fd = open ("/dev/windows", O_RDONLY);
398 if (event_poll_fd.fd == -1)
399 g_error ("can't open \"/dev/windows\": %s", g_strerror (errno));
401 event_poll_fd.fd = G_WIN32_MSG_HANDLE;
403 event_poll_fd.events = G_IO_IN;
405 g_source_add_poll (source, &event_poll_fd);
406 g_source_set_can_recurse (source, TRUE);
407 g_source_attach (source, NULL);
411 gdk_events_pending (void)
414 return (_gdk_event_queue_find_first (_gdk_display) ||
415 (modal_win32_dialog == NULL &&
416 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
420 gdk_event_get_graphics_expose (GdkWindow *window)
423 GdkEvent *event = NULL;
425 g_return_val_if_fail (window != NULL, NULL);
427 GDK_NOTE (EVENTS, g_print ("gdk_event_get_graphics_expose\n"));
429 if (PeekMessageW (&msg, GDK_WINDOW_HWND (window), WM_PAINT, WM_PAINT, PM_REMOVE))
431 handle_wm_paint (&msg, window, TRUE, &event);
434 GDK_NOTE (EVENTS, g_print ("gdk_event_get_graphics_expose: got it!\n"));
439 GDK_NOTE (EVENTS, g_print ("gdk_event_get_graphics_expose: nope\n"));
444 event_mask_string (GdkEventMask mask)
446 static char bfr[500];
451 if (mask & GDK_##x##_MASK) \
452 p += g_sprintf (p, "%s" #x, (p > bfr ? " " : ""))
454 BIT (POINTER_MOTION);
455 BIT (POINTER_MOTION_HINT);
457 BIT (BUTTON1_MOTION);
458 BIT (BUTTON2_MOTION);
459 BIT (BUTTON3_MOTION);
461 BIT (BUTTON_RELEASE);
468 BIT (PROPERTY_CHANGE);
469 BIT (VISIBILITY_NOTIFY);
480 _gdk_windowing_pointer_grab (GdkWindow *window,
481 GdkWindow *native_window,
482 gboolean owner_events,
483 GdkEventMask event_mask,
484 GdkWindow *confine_to,
488 SetCapture (GDK_WINDOW_HWND (native_window));
489 /* TODO_CSW: grab brokens, confine window, cursor, input_grab */
490 return GDK_GRAB_SUCCESS;
494 gdk_display_pointer_ungrab (GdkDisplay *display,
497 GdkPointerGrabInfo *info;
499 info = _gdk_display_get_last_pointer_grab (display);
502 info->serial_end = 0;
505 /* TODO_CSW: cursor, confines, etc */
507 _gdk_display_pointer_grab_update (display, 0);
511 gdk_keyboard_grab (GdkWindow *window,
512 gboolean owner_events,
518 g_return_val_if_fail (window != NULL, 0);
519 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
521 GDK_NOTE (EVENTS, g_print ("gdk_keyboard_grab %p%s\n",
522 GDK_WINDOW_HWND (window), owner_events ? " OWNER_EVENTS" : ""));
524 display = gdk_drawable_get_display (window);
525 toplevel = gdk_window_get_toplevel (window);
527 _gdk_display_set_has_keyboard_grab (display,
534 return GDK_GRAB_SUCCESS;
538 gdk_display_keyboard_ungrab (GdkDisplay *display,
541 GDK_NOTE (EVENTS, g_print ("gdk_display_keyboard_ungrab\n"));
542 _gdk_display_unset_has_keyboard_grab (display, FALSE);
546 gdk_display_add_client_message_filter (GdkDisplay *display,
547 GdkAtom message_type,
552 gdk_add_client_message_filter (message_type, func, data);
556 gdk_add_client_message_filter (GdkAtom message_type,
560 GdkClientFilter *filter = g_new (GdkClientFilter, 1);
562 filter->type = message_type;
563 filter->function = func;
566 client_filters = g_list_append (client_filters, filter);
570 build_key_event_state (GdkEvent *event,
573 event->key.state = 0;
575 if (key_state[VK_SHIFT] & 0x80)
576 event->key.state |= GDK_SHIFT_MASK;
578 if (key_state[VK_CAPITAL] & 0x01)
579 event->key.state |= GDK_LOCK_MASK;
581 if (key_state[VK_LBUTTON] & 0x80)
582 event->key.state |= GDK_BUTTON1_MASK;
583 if (key_state[VK_MBUTTON] & 0x80)
584 event->key.state |= GDK_BUTTON2_MASK;
585 if (key_state[VK_RBUTTON] & 0x80)
586 event->key.state |= GDK_BUTTON3_MASK;
587 if (key_state[VK_XBUTTON1] & 0x80)
588 event->key.state |= GDK_BUTTON4_MASK;
589 if (key_state[VK_XBUTTON2] & 0x80)
590 event->key.state |= GDK_BUTTON5_MASK;
592 if (_gdk_keyboard_has_altgr &&
593 (key_state[VK_LCONTROL] & 0x80) &&
594 (key_state[VK_RMENU] & 0x80))
596 event->key.group = 1;
597 event->key.state |= GDK_MOD2_MASK;
598 if (key_state[VK_RCONTROL] & 0x80)
599 event->key.state |= GDK_CONTROL_MASK;
600 if (key_state[VK_LMENU] & 0x80)
601 event->key.state |= GDK_MOD1_MASK;
605 event->key.group = 0;
606 if (key_state[VK_CONTROL] & 0x80)
607 event->key.state |= GDK_CONTROL_MASK;
608 if (key_state[VK_MENU] & 0x80)
609 event->key.state |= GDK_MOD1_MASK;
614 build_pointer_event_state (MSG *msg)
620 if (msg->wParam & MK_CONTROL)
621 state |= GDK_CONTROL_MASK;
623 if ((msg->message != WM_LBUTTONDOWN &&
624 (msg->wParam & MK_LBUTTON)) ||
625 msg->message == WM_LBUTTONUP)
626 state |= GDK_BUTTON1_MASK;
628 if ((msg->message != WM_MBUTTONDOWN &&
629 (msg->wParam & MK_MBUTTON)) ||
630 msg->message == WM_MBUTTONUP)
631 state |= GDK_BUTTON2_MASK;
633 if ((msg->message != WM_RBUTTONDOWN &&
634 (msg->wParam & MK_RBUTTON)) ||
635 msg->message == WM_RBUTTONUP)
636 state |= GDK_BUTTON3_MASK;
638 if (((msg->message != WM_XBUTTONDOWN || HIWORD (msg->wParam) != XBUTTON1) &&
639 (msg->wParam & MK_XBUTTON1)) ||
640 (msg->message == WM_XBUTTONUP && HIWORD (msg->wParam) == XBUTTON1))
641 state |= GDK_BUTTON4_MASK;
643 if (((msg->message != WM_XBUTTONDOWN || HIWORD (msg->wParam) != XBUTTON2) &&
644 (msg->wParam & MK_XBUTTON2)) ||
645 (msg->message == WM_XBUTTONUP && HIWORD (msg->wParam) == XBUTTON2))
646 state |= GDK_BUTTON5_MASK;
648 if (msg->wParam & MK_SHIFT)
649 state |= GDK_SHIFT_MASK;
651 if (GetKeyState (VK_MENU) < 0)
652 state |= GDK_MOD1_MASK;
654 if (GetKeyState (VK_CAPITAL) & 0x1)
655 state |= GDK_LOCK_MASK;
661 build_wm_ime_composition_event (GdkEvent *event,
666 event->key.time = _gdk_win32_get_next_tick (msg->time);
668 build_key_event_state (event, key_state);
670 event->key.hardware_keycode = 0; /* FIXME: What should it be? */
671 event->key.string = NULL;
672 event->key.length = 0;
673 event->key.keyval = gdk_unicode_to_keyval (wc);
676 #ifdef G_ENABLE_DEBUG
679 print_event_state (guint state)
681 #define CASE(bit) if (state & GDK_ ## bit ## _MASK) g_print (#bit " ");
699 print_event (GdkEvent *event)
701 gchar *escaped, *kvname;
702 gchar *selection_name, *target_name, *property_name;
704 g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
705 switch (event->any.type)
707 #define CASE(x) case x: g_print (#x); break;
712 CASE (GDK_MOTION_NOTIFY);
713 CASE (GDK_BUTTON_PRESS);
714 CASE (GDK_2BUTTON_PRESS);
715 CASE (GDK_3BUTTON_PRESS);
716 CASE (GDK_BUTTON_RELEASE);
717 CASE (GDK_KEY_PRESS);
718 CASE (GDK_KEY_RELEASE);
719 CASE (GDK_ENTER_NOTIFY);
720 CASE (GDK_LEAVE_NOTIFY);
721 CASE (GDK_FOCUS_CHANGE);
722 CASE (GDK_CONFIGURE);
725 CASE (GDK_PROPERTY_NOTIFY);
726 CASE (GDK_SELECTION_CLEAR);
727 CASE (GDK_SELECTION_REQUEST);
728 CASE (GDK_SELECTION_NOTIFY);
729 CASE (GDK_PROXIMITY_IN);
730 CASE (GDK_PROXIMITY_OUT);
731 CASE (GDK_DRAG_ENTER);
732 CASE (GDK_DRAG_LEAVE);
733 CASE (GDK_DRAG_MOTION);
734 CASE (GDK_DRAG_STATUS);
735 CASE (GDK_DROP_START);
736 CASE (GDK_DROP_FINISHED);
737 CASE (GDK_CLIENT_EVENT);
738 CASE (GDK_VISIBILITY_NOTIFY);
739 CASE (GDK_NO_EXPOSE);
741 CASE (GDK_WINDOW_STATE);
743 CASE (GDK_OWNER_CHANGE);
744 CASE (GDK_GRAB_BROKEN);
746 default: g_assert_not_reached ();
749 g_print (" %p ", GDK_WINDOW_HWND (event->any.window));
751 switch (event->any.type)
755 _gdk_win32_gdkrectangle_to_string (&event->expose.area),
756 event->expose.count);
758 case GDK_MOTION_NOTIFY:
759 g_print ("(%.4g,%.4g) (%.4g,%.4g) %s",
760 event->motion.x, event->motion.y,
761 event->motion.x_root, event->motion.y_root,
762 event->motion.is_hint ? "HINT " : "");
763 print_event_state (event->motion.state);
765 case GDK_BUTTON_PRESS:
766 case GDK_2BUTTON_PRESS:
767 case GDK_3BUTTON_PRESS:
768 case GDK_BUTTON_RELEASE:
769 g_print ("%d (%.4g,%.4g) (%.4g,%.4g) ",
770 event->button.button,
771 event->button.x, event->button.y,
772 event->button.x_root, event->button.y_root);
773 print_event_state (event->button.state);
776 case GDK_KEY_RELEASE:
777 if (event->key.length == 0)
778 escaped = g_strdup ("");
780 escaped = g_strescape (event->key.string, NULL);
781 kvname = gdk_keyval_name (event->key.keyval);
782 g_print ("%#.02x group:%d %s %d:\"%s\" ",
783 event->key.hardware_keycode, event->key.group,
784 (kvname ? kvname : "??"),
788 print_event_state (event->key.state);
790 case GDK_ENTER_NOTIFY:
791 case GDK_LEAVE_NOTIFY:
792 g_print ("%p (%.4g,%.4g) (%.4g,%.4g) %s %s%s",
793 event->crossing.subwindow == NULL ? NULL : GDK_WINDOW_HWND (event->crossing.subwindow),
794 event->crossing.x, event->crossing.y,
795 event->crossing.x_root, event->crossing.y_root,
796 (event->crossing.mode == GDK_CROSSING_NORMAL ? "NORMAL" :
797 (event->crossing.mode == GDK_CROSSING_GRAB ? "GRAB" :
798 (event->crossing.mode == GDK_CROSSING_UNGRAB ? "UNGRAB" :
800 (event->crossing.detail == GDK_NOTIFY_ANCESTOR ? "ANCESTOR" :
801 (event->crossing.detail == GDK_NOTIFY_VIRTUAL ? "VIRTUAL" :
802 (event->crossing.detail == GDK_NOTIFY_INFERIOR ? "INFERIOR" :
803 (event->crossing.detail == GDK_NOTIFY_NONLINEAR ? "NONLINEAR" :
804 (event->crossing.detail == GDK_NOTIFY_NONLINEAR_VIRTUAL ? "NONLINEAR_VIRTUAL" :
805 (event->crossing.detail == GDK_NOTIFY_UNKNOWN ? "UNKNOWN" :
807 event->crossing.focus ? " FOCUS" : "");
808 print_event_state (event->crossing.state);
810 case GDK_FOCUS_CHANGE:
811 g_print ("%s", (event->focus_change.in ? "IN" : "OUT"));
813 case GDK_SELECTION_REQUEST:
814 case GDK_SELECTION_NOTIFY:
815 case GDK_SELECTION_CLEAR:
816 selection_name = gdk_atom_name (event->selection.selection);
817 target_name = gdk_atom_name (event->selection.target);
818 property_name = gdk_atom_name (event->selection.property);
819 g_print ("sel:%s tgt:%s prop:%s",
820 selection_name, target_name, property_name);
821 g_free (selection_name);
822 g_free (target_name);
823 g_free (property_name);
826 g_print ("x:%d y:%d w:%d h:%d",
827 event->configure.x, event->configure.y,
828 event->configure.width, event->configure.height);
830 case GDK_CLIENT_EVENT:
831 g_print ("%s %d %ld %ld %ld %ld %ld",
832 gdk_atom_name (event->client.message_type),
833 event->client.data_format,
834 event->client.data.l[0],
835 event->client.data.l[1],
836 event->client.data.l[2],
837 event->client.data.l[3],
838 event->client.data.l[4]);
841 g_print ("(%.4g,%.4g) (%.4g,%.4g) %s ",
842 event->scroll.x, event->scroll.y,
843 event->scroll.x_root, event->scroll.y_root,
844 (event->scroll.direction == GDK_SCROLL_UP ? "UP" :
845 (event->scroll.direction == GDK_SCROLL_DOWN ? "DOWN" :
846 (event->scroll.direction == GDK_SCROLL_LEFT ? "LEFT" :
847 (event->scroll.direction == GDK_SCROLL_RIGHT ? "RIGHT" :
849 print_event_state (event->scroll.state);
851 case GDK_WINDOW_STATE:
853 _gdk_win32_window_state_to_string (event->window_state.changed_mask),
854 _gdk_win32_window_state_to_string (event->window_state.new_window_state));
857 (event->setting.action == GDK_SETTING_ACTION_NEW ? "NEW" :
858 (event->setting.action == GDK_SETTING_ACTION_CHANGED ? "CHANGED" :
859 (event->setting.action == GDK_SETTING_ACTION_DELETED ? "DELETED" :
861 (event->setting.name ? event->setting.name : "NULL"));
862 case GDK_GRAB_BROKEN:
864 (event->grab_broken.keyboard ? "KEYBOARD" : "POINTER"),
865 (event->grab_broken.implicit ? "IMPLICIT" : "EXPLICIT"),
866 (event->grab_broken.grab_window ? GDK_WINDOW_HWND (event->grab_broken.grab_window) : 0));
871 g_print ("%s", (debug_indent == 0 ? "\n" : ""));
875 decode_key_lparam (LPARAM lParam)
877 static char buf[100];
880 if (HIWORD (lParam) & KF_UP)
881 p += g_sprintf (p, "KF_UP ");
882 if (HIWORD (lParam) & KF_REPEAT)
883 p += g_sprintf (p, "KF_REPEAT ");
884 if (HIWORD (lParam) & KF_ALTDOWN)
885 p += g_sprintf (p, "KF_ALTDOWN ");
886 if (HIWORD (lParam) & KF_EXTENDED)
887 p += g_sprintf (p, "KF_EXTENDED ");
888 p += g_sprintf (p, "sc:%d rep:%d", LOBYTE (HIWORD (lParam)), LOWORD (lParam));
896 fixup_event (GdkEvent *event)
898 if (event->any.window)
899 g_object_ref (event->any.window);
900 if (((event->any.type == GDK_ENTER_NOTIFY) ||
901 (event->any.type == GDK_LEAVE_NOTIFY)) &&
902 (event->crossing.subwindow != NULL))
903 g_object_ref (event->crossing.subwindow);
904 event->any.send_event = InSendMessage ();
908 append_event (GdkEvent *event)
913 link = _gdk_event_queue_append (_gdk_display, event);
914 _gdk_windowing_got_event (_gdk_display, link, event, 0);
915 GDK_NOTE (EVENTS, print_event (event));
919 fill_key_event_string (GdkEvent *event)
924 /* Fill in event->string crudely, since various programs
929 if (event->key.keyval != GDK_VoidSymbol)
930 c = gdk_keyval_to_unicode (event->key.keyval);
937 /* Apply the control key - Taken from Xlib
939 if (event->key.state & GDK_CONTROL_MASK)
941 if ((c >= '@' && c < '\177') || c == ' ')
945 event->key.string = g_memdup ("\0\0", 2);
946 event->key.length = 1;
949 else if (c >= '3' && c <= '7')
957 len = g_unichar_to_utf8 (c, buf);
960 event->key.string = g_locale_from_utf8 (buf, len,
961 NULL, &bytes_written,
963 if (event->key.string)
964 event->key.length = bytes_written;
966 else if (event->key.keyval == GDK_Escape)
968 event->key.length = 1;
969 event->key.string = g_strdup ("\033");
971 else if (event->key.keyval == GDK_Return ||
972 event->key.keyval == GDK_KP_Enter)
974 event->key.length = 1;
975 event->key.string = g_strdup ("\r");
978 if (!event->key.string)
980 event->key.length = 0;
981 event->key.string = g_strdup ("");
985 static GdkFilterReturn
986 apply_event_filters (GdkWindow *window,
990 GdkFilterReturn result = GDK_FILTER_CONTINUE;
995 event = gdk_event_new (GDK_NOTHING);
997 event->any.window = g_object_ref (window);
998 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1000 /* I think GdkFilterFunc semantics require the passed-in event
1001 * to already be in the queue. The filter func can generate
1002 * more events and append them after it if it likes.
1004 node = _gdk_event_queue_append (_gdk_display, event);
1009 GdkEventFilter *filter = (GdkEventFilter *) tmp_list->data;
1011 tmp_list = tmp_list->next;
1012 result = filter->function (msg, event, filter->data);
1013 if (result != GDK_FILTER_CONTINUE)
1017 if (result == GDK_FILTER_CONTINUE || result == GDK_FILTER_REMOVE)
1019 _gdk_event_queue_remove_link (_gdk_display, node);
1020 g_list_free_1 (node);
1021 gdk_event_free (event);
1023 else /* GDK_FILTER_TRANSLATE */
1025 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1026 fixup_event (event);
1027 GDK_NOTE (EVENTS, print_event (event));
1033 * On Windows, transient windows will not have their own taskbar entries.
1034 * Because of this, we must hide and restore groups of transients in both
1035 * directions. That is, all transient children must be hidden or restored
1036 * with this window, but if this window's transient owner also has a
1037 * transient owner then this window's transient owner must be hidden/restored
1038 * with this one. And etc, up the chain until we hit an ancestor that has no
1041 * It would be a good idea if applications don't chain transient windows
1042 * together. There's a limit to how much evil GTK can try to shield you
1046 show_window_recurse (GdkWindow *window, gboolean hide_window)
1048 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1049 GSList *children = impl->transient_children;
1050 GdkWindow *child = NULL;
1052 if (!impl->changing_state)
1054 impl->changing_state = TRUE;
1056 if (children != NULL)
1058 while (children != NULL)
1060 child = children->data;
1061 show_window_recurse (child, hide_window);
1063 children = g_slist_next (children);
1067 if (GDK_WINDOW_IS_MAPPED (window))
1071 if (GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_ICONIFIED)
1073 if (GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_MAXIMIZED)
1075 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
1079 ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
1085 ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
1089 impl->changing_state = FALSE;
1094 do_show_window (GdkWindow *window, gboolean hide_window)
1096 GdkWindow *tmp_window = NULL;
1097 GdkWindowImplWin32 *tmp_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1099 if (!tmp_impl->changing_state)
1101 /* Find the top-level window in our transient chain. */
1102 while (tmp_impl->transient_owner != NULL)
1104 tmp_window = tmp_impl->transient_owner;
1105 tmp_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (tmp_window)->impl);
1108 /* If we couldn't find one, use the window provided. */
1109 if (tmp_window == NULL)
1111 tmp_window = window;
1114 /* Recursively show/hide every window in the chain. */
1115 if (tmp_window != window)
1117 show_window_recurse (tmp_window, hide_window);
1123 gdk_window_is_ancestor (GdkWindow *ancestor,
1126 if (ancestor == NULL || window == NULL)
1129 return (gdk_window_get_parent (window) == ancestor ||
1130 gdk_window_is_ancestor (ancestor, gdk_window_get_parent (window)));
1134 synthesize_enter_or_leave_event (GdkWindow *window,
1137 GdkCrossingMode mode,
1138 GdkNotifyType detail)
1144 ScreenToClient (GDK_WINDOW_HWND (window), &pt);
1146 event = gdk_event_new (type);
1147 event->crossing.window = window;
1148 event->crossing.subwindow = NULL;
1149 event->crossing.time = _gdk_win32_get_next_tick (msg->time);
1150 event->crossing.x = pt.x;
1151 event->crossing.y = pt.y;
1152 event->crossing.x_root = msg->pt.x + _gdk_offset_x;
1153 event->crossing.y_root = msg->pt.y + _gdk_offset_y;
1154 event->crossing.mode = mode;
1155 event->crossing.detail = detail;
1156 event->crossing.focus = TRUE; /* FIXME: Set correctly */
1157 event->crossing.state = 0; /* FIXME: Set correctly */
1159 append_event (event);
1161 if (type == GDK_ENTER_NOTIFY &&
1162 ((GdkWindowObject *) window)->extension_events != 0)
1163 _gdk_input_enter_event (window);
1167 synthesize_expose_events (GdkWindow *window)
1171 GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
1172 GList *list = gdk_window_get_children (window);
1179 synthesize_expose_events ((GdkWindow *) list->data);
1185 if (((GdkWindowObject *) window)->input_only)
1187 else if (!(hdc = GetDC (impl->handle)))
1188 WIN32_GDI_FAILED ("GetDC");
1191 if ((k = GetClipBox (hdc, &r)) == ERROR)
1192 WIN32_GDI_FAILED ("GetClipBox");
1193 else if (k != NULLREGION)
1195 event = gdk_event_new (GDK_EXPOSE);
1196 event->expose.window = window;
1197 event->expose.area.x = r.left;
1198 event->expose.area.y = r.top;
1199 event->expose.area.width = r.right - r.left;
1200 event->expose.area.height = r.bottom - r.top;
1201 event->expose.region = gdk_region_rectangle (&(event->expose.area));
1202 event->expose.count = 0;
1204 append_event (event);
1206 GDI_CALL (ReleaseDC, (impl->handle, hdc));
1211 update_colors (GdkWindow *window,
1215 GdkDrawableImplWin32 *impl = GDK_DRAWABLE_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
1216 GList *list = gdk_window_get_children (window);
1219 GDK_NOTE (COLORMAP, (top ? g_print ("update_colors:") : (void) 0));
1223 update_colors ((GdkWindow *) list->data, FALSE);
1228 if (((GdkWindowObject *) window)->input_only ||
1229 impl->colormap == NULL)
1232 if (!(hdc = GetDC (impl->handle)))
1233 WIN32_GDI_FAILED ("GetDC");
1236 GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (impl->colormap);
1240 if ((holdpal = SelectPalette (hdc, cmapp->hpal, TRUE)) == NULL)
1241 WIN32_GDI_FAILED ("SelectPalette");
1242 else if ((k = RealizePalette (hdc)) == GDI_ERROR)
1243 WIN32_GDI_FAILED ("RealizePalette");
1248 g_print (" %p pal=%p: realized %d colors\n"
1250 impl->handle, cmapp->hpal, k) :
1252 g_print (" %p", impl->handle)));
1253 GDI_CALL (UpdateColors, (hdc));
1254 SelectPalette (hdc, holdpal, TRUE);
1255 RealizePalette (hdc);
1257 GDI_CALL (ReleaseDC, (impl->handle, hdc));
1259 GDK_NOTE (COLORMAP, (top ? g_print ("\n") : (void) 0));
1263 translate_mouse_coords (GdkWindow *window1,
1269 pt.x = GET_X_LPARAM (msg->lParam);
1270 pt.y = GET_Y_LPARAM (msg->lParam);
1271 ClientToScreen (GDK_WINDOW_HWND (window1), &pt);
1272 ScreenToClient (GDK_WINDOW_HWND (window2), &pt);
1273 msg->lParam = MAKELPARAM (pt.x, pt.y);
1276 /* The check_extended flag controls whether to check if the windows want
1277 * events from extended input devices and if the message should be skipped
1278 * because an extended input device is active
1281 propagate (GdkWindow **window,
1283 GdkWindow *grab_window,
1284 gboolean grab_owner_events,
1286 gboolean (*doesnt_want_it) (gint mask,
1288 gboolean check_extended)
1290 if (grab_window != NULL && !grab_owner_events)
1292 /* Event source is grabbed with owner_events FALSE */
1294 /* See if the event should be ignored because an extended input
1297 if (check_extended &&
1298 ((GdkWindowObject *) grab_window)->extension_events != 0 &&
1299 _gdk_input_ignore_core)
1301 GDK_NOTE (EVENTS, g_print (" (ignored for grabber)"));
1304 if ((*doesnt_want_it) (grab_mask, msg))
1306 GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)"));
1311 GDK_NOTE (EVENTS, g_print (" (to grabber)"));
1312 assign_object (window, grab_window);
1317 /* If we come here, we know that if grab_window != NULL then
1318 * grab_owner_events is TRUE
1322 if (check_extended &&
1323 ((GdkWindowObject *) *window)->extension_events != 0 &&
1324 _gdk_input_ignore_core)
1326 GDK_NOTE (EVENTS, g_print (" (ignored)"));
1329 if ((*doesnt_want_it) (((GdkWindowObject *) *window)->event_mask, msg))
1331 /* Owner doesn't want it, propagate to parent. */
1332 GdkWindow *parent = gdk_window_get_parent (*window);
1333 if (parent == _gdk_root || parent == NULL)
1335 /* No parent; check if grabbed */
1336 if (grab_window != NULL)
1338 /* Event source is grabbed with owner_events TRUE */
1340 if (check_extended &&
1341 ((GdkWindowObject *) grab_window)->extension_events != 0 &&
1342 _gdk_input_ignore_core)
1344 GDK_NOTE (EVENTS, g_print (" (ignored for grabber)"));
1347 if ((*doesnt_want_it) (grab_mask, msg))
1349 /* Grabber doesn't want it either */
1350 GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)"));
1356 GDK_NOTE (EVENTS, g_print (" (to grabber)"));
1357 assign_object (window, grab_window);
1363 GDK_NOTE (EVENTS, g_print (" (undelivered)"));
1369 assign_object (window, parent);
1370 /* The only branch where we actually continue the loop */
1379 doesnt_want_key (gint mask,
1382 return (((msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) &&
1383 !(mask & GDK_KEY_RELEASE_MASK)) ||
1384 ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN) &&
1385 !(mask & GDK_KEY_PRESS_MASK)));
1389 doesnt_want_char (gint mask,
1392 return !(mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK));
1396 doesnt_want_button_press (gint mask,
1399 return !(mask & GDK_BUTTON_PRESS_MASK);
1403 doesnt_want_button_release (gint mask,
1406 return !(mask & GDK_BUTTON_RELEASE_MASK);
1410 doesnt_want_button_motion (gint mask,
1413 return !((mask & GDK_POINTER_MOTION_MASK) ||
1414 ((msg->wParam & (MK_LBUTTON|MK_MBUTTON|MK_RBUTTON)) && (mask & GDK_BUTTON_MOTION_MASK)) ||
1415 ((msg->wParam & MK_LBUTTON) && (mask & GDK_BUTTON1_MOTION_MASK)) ||
1416 ((msg->wParam & MK_MBUTTON) && (mask & GDK_BUTTON2_MOTION_MASK)) ||
1417 ((msg->wParam & MK_RBUTTON) && (mask & GDK_BUTTON3_MOTION_MASK)));
1421 doesnt_want_scroll (gint mask,
1424 /* As there are no separate scroll events in X11, button press
1425 * events are used, so higher level code might be selecting for
1426 * either GDK_BUTTON_PRESS_MASK or GDK_SCROLL_MASK when it wants GDK
1427 * scroll events. Make sure this works in the Win32 backend, too.
1429 return !(mask & (GDK_SCROLL_MASK|GDK_BUTTON_PRESS_MASK));
1433 handle_configure_event (MSG *msg,
1438 GdkWindowObject *window_object;
1440 GetClientRect (msg->hwnd, &client_rect);
1441 point.x = client_rect.left; /* always 0 */
1442 point.y = client_rect.top;
1444 /* top level windows need screen coords */
1445 if (gdk_window_get_parent (window) == _gdk_root)
1447 ClientToScreen (msg->hwnd, &point);
1448 point.x += _gdk_offset_x;
1449 point.y += _gdk_offset_y;
1452 window_object = GDK_WINDOW_OBJECT (window);
1454 window_object->width = client_rect.right - client_rect.left;
1455 window_object->height = client_rect.bottom - client_rect.top;
1457 window_object->x = point.x;
1458 window_object->y = point.y;
1460 _gdk_window_update_size (window);
1462 if (window_object->event_mask & GDK_STRUCTURE_MASK)
1464 GdkEvent *event = gdk_event_new (GDK_CONFIGURE);
1466 event->configure.window = window;
1468 event->configure.width = client_rect.right - client_rect.left;
1469 event->configure.height = client_rect.bottom - client_rect.top;
1471 event->configure.x = point.x;
1472 event->configure.y = point.y;
1474 append_event (event);
1479 _gdk_win32_hrgn_to_region (HRGN hrgn)
1487 if ((nbytes = GetRegionData (hrgn, 0, NULL)) == 0)
1489 WIN32_GDI_FAILED ("GetRegionData");
1493 rgndata = (RGNDATA *) g_malloc (nbytes);
1495 if (GetRegionData (hrgn, nbytes, rgndata) == 0)
1497 WIN32_GDI_FAILED ("GetRegionData");
1502 result = gdk_region_new ();
1503 rects = (RECT *) rgndata->Buffer;
1504 for (i = 0; i < rgndata->rdh.nCount; i++)
1508 r.x = rects[i].left;
1510 r.width = rects[i].right - r.x;
1511 r.height = rects[i].bottom - r.y;
1513 gdk_region_union_with_rect (result, &r);
1522 adjust_drag (LONG *drag,
1527 *drag = curr + ((*drag + inc/2 - curr) / inc) * inc;
1529 *drag = curr - ((curr - *drag + inc/2) / inc) * inc;
1533 handle_wm_paint (MSG *msg,
1535 gboolean return_exposes,
1538 HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
1540 PAINTSTRUCT paintstruct;
1541 GdkRegion *update_region;
1543 if (GetUpdateRgn (msg->hwnd, hrgn, FALSE) == ERROR)
1545 WIN32_GDI_FAILED ("GetUpdateRgn");
1546 DeleteObject (hrgn);
1550 hdc = BeginPaint (msg->hwnd, &paintstruct);
1552 GDK_NOTE (EVENTS, g_print (" %s %s dc %p%s",
1553 _gdk_win32_rect_to_string (&paintstruct.rcPaint),
1554 (paintstruct.fErase ? "erase" : ""),
1556 (return_exposes ? " return_exposes" : "")));
1558 EndPaint (msg->hwnd, &paintstruct);
1560 /* HB: don't generate GDK_EXPOSE events for InputOnly
1561 * windows -> backing store now works!
1563 if (((GdkWindowObject *) window)->input_only)
1565 DeleteObject (hrgn);
1569 if (!(((GdkWindowObject *) window)->event_mask & GDK_EXPOSURE_MASK))
1571 GDK_NOTE (EVENTS, g_print (" (ignored)"));
1572 DeleteObject (hrgn);
1576 #if 0 /* we need to process exposes even with GDK_NO_BG
1577 * Otherwise The GIMP canvas update is broken ....
1579 if (((GdkWindowObject *) window)->bg_pixmap == GDK_NO_BG)
1583 if ((paintstruct.rcPaint.right == paintstruct.rcPaint.left) ||
1584 (paintstruct.rcPaint.bottom == paintstruct.rcPaint.top))
1586 GDK_NOTE (EVENTS, g_print (" (empty paintstruct, ignored)"));
1587 DeleteObject (hrgn);
1593 if (!GDK_WINDOW_DESTROYED (window))
1595 GList *list = _gdk_display->queued_events;
1597 *event = gdk_event_new (GDK_EXPOSE);
1598 (*event)->expose.window = window;
1599 (*event)->expose.area.x = paintstruct.rcPaint.left;
1600 (*event)->expose.area.y = paintstruct.rcPaint.top;
1601 (*event)->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left;
1602 (*event)->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top;
1603 (*event)->expose.region = _gdk_win32_hrgn_to_region (hrgn);
1604 (*event)->expose.count = 0;
1606 while (list != NULL)
1608 GdkEventPrivate *evp = list->data;
1610 if (evp->event.any.type == GDK_EXPOSE &&
1611 evp->event.any.window == window &&
1612 !(evp->flags & GDK_EVENT_PENDING))
1613 evp->event.expose.count++;
1619 DeleteObject (hrgn);
1623 update_region = _gdk_win32_hrgn_to_region (hrgn);
1626 //_gdk_win32_windowing_window_get_offsets (window, &xoffset, &yoffset);
1627 //gdk_region_offset (update_region, xoffset, yoffset);
1629 _gdk_window_process_expose (window, update_region);
1630 gdk_region_destroy (update_region);
1632 DeleteObject (hrgn);
1636 handle_stuff_while_moving_or_resizing (void)
1638 int arbitrary_limit = 1;
1639 while (g_main_context_pending (NULL) && arbitrary_limit--)
1640 g_main_context_iteration (NULL, FALSE);
1643 static VOID CALLBACK
1644 modal_timer_proc (HWND hwnd,
1649 if (_sizemove_in_progress)
1650 handle_stuff_while_moving_or_resizing ();
1653 static VOID CALLBACK
1654 sync_timer_proc (HWND hwnd,
1660 if (PeekMessageW (&message, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE))
1665 RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
1667 KillTimer (hwnd, sync_timer);
1671 handle_display_change (void)
1673 _gdk_monitor_init ();
1674 _gdk_root_window_size_init ();
1675 g_signal_emit_by_name (_gdk_screen, "size_changed");
1679 generate_button_event (GdkEventType type,
1684 GdkEvent *event = gdk_event_new (type);
1686 event->button.window = window;
1687 event->button.time = _gdk_win32_get_next_tick (msg->time);
1688 event->button.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
1689 event->button.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
1690 event->button.x_root = msg->pt.x + _gdk_offset_x;
1691 event->button.y_root = msg->pt.y + _gdk_offset_y;
1692 event->button.axes = NULL;
1693 event->button.state = build_pointer_event_state (msg);
1694 event->button.button = button;
1695 event->button.device = _gdk_display->core_pointer;
1697 append_event (event);
1701 ensure_stacking_on_unminimize (MSG *msg)
1704 HWND lowest_transient = NULL;
1707 while ((rover = GetNextWindow (rover, GW_HWNDNEXT)))
1709 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1711 /* Checking window group not implemented yet */
1714 GdkWindowImplWin32 *rover_impl =
1715 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1717 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1718 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1719 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1720 rover_impl->transient_owner != NULL))
1722 lowest_transient = rover;
1726 if (lowest_transient != NULL)
1728 GDK_NOTE (EVENTS, g_print (" restacking: %p", lowest_transient));
1729 SetWindowPos (msg->hwnd, lowest_transient, 0, 0, 0, 0,
1730 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1735 ensure_stacking_on_window_pos_changing (MSG *msg,
1738 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)((GdkWindowObject *) window)->impl;
1739 WINDOWPOS *windowpos = (WINDOWPOS *) msg->lParam;
1741 if (GetActiveWindow () == msg->hwnd &&
1742 impl->type_hint != GDK_WINDOW_TYPE_HINT_UTILITY &&
1743 impl->type_hint != GDK_WINDOW_TYPE_HINT_DIALOG &&
1744 impl->transient_owner == NULL)
1746 /* Make sure the window stays behind any transient-type windows
1747 * of the same window group.
1749 * If the window is not active and being activated, we let
1750 * Windows bring it to the top and rely on the WM_ACTIVATEAPP
1751 * handling to bring any utility windows on top of it.
1754 gboolean restacking;
1756 rover = windowpos->hwndInsertAfter;
1760 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1762 /* Checking window group not implemented yet */
1765 GdkWindowImplWin32 *rover_impl =
1766 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1768 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1769 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1770 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1771 rover_impl->transient_owner != NULL))
1774 windowpos->hwndInsertAfter = rover;
1777 rover = GetNextWindow (rover, GW_HWNDNEXT);
1782 GDK_NOTE (EVENTS, g_print (" restacking: %p", windowpos->hwndInsertAfter));
1790 ensure_stacking_on_activate_app (MSG *msg,
1793 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)((GdkWindowObject *) window)->impl;
1795 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1796 impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1797 impl->transient_owner != NULL)
1799 SetWindowPos (msg->hwnd, HWND_TOP, 0, 0, 0, 0,
1800 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1804 if (IsWindowVisible (msg->hwnd) &&
1805 msg->hwnd == GetActiveWindow ())
1807 /* This window is not a transient-type window and it is the
1808 * activated window. Make sure this window is as visible as
1809 * possible, just below the lowest transient-type window of this
1815 while ((rover = GetNextWindow (rover, GW_HWNDPREV)))
1817 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1819 /* Checking window group not implemented yet */
1822 GdkWindowImplWin32 *rover_impl =
1823 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1825 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1826 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1827 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1828 rover_impl->transient_owner != NULL))
1830 GDK_NOTE (EVENTS, g_print (" restacking: %p", rover));
1831 SetWindowPos (msg->hwnd, rover, 0, 0, 0, 0,
1832 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1841 gdk_event_translate (MSG *msg,
1844 RECT rect, *drag, orig_drag;
1849 BYTE key_state[256];
1851 WINDOWPOS *windowpos;
1858 GdkWindow *window = NULL;
1859 GdkWindowImplWin32 *impl;
1861 GdkWindow *orig_window, *new_window, *toplevel;
1863 GdkPointerGrabInfo *grab = NULL;
1864 GdkWindow *grab_window = NULL;
1865 guint grab_mask = 0;
1866 gboolean grab_owner_events = FALSE;
1868 static gint update_colors_counter = 0;
1873 gboolean return_val = FALSE;
1877 if (_gdk_default_filters)
1879 /* Apply global filters */
1881 GdkFilterReturn result = apply_event_filters (NULL, msg, _gdk_default_filters);
1883 /* If result is GDK_FILTER_CONTINUE, we continue as if nothing
1884 * happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
1885 * we return TRUE, and DefWindowProcW() will not be called.
1887 if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
1891 window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd);
1892 orig_window = window;
1896 /* XXX Handle WM_QUIT here ? */
1897 if (msg->message == WM_QUIT)
1899 GDK_NOTE (EVENTS, g_print (" %d", (int) msg->wParam));
1902 else if (msg->message == WM_MOVE ||
1903 msg->message == WM_SIZE)
1905 /* It's quite normal to get these messages before we have
1906 * had time to register the window in our lookup table, or
1907 * when the window is being destroyed and we already have
1908 * removed it. Repost the same message to our queue so that
1909 * we will get it later when we are prepared.
1911 GDK_NOTE (EVENTS, g_print (" (posted)"));
1913 PostMessageW (msg->hwnd, msg->message, msg->wParam, msg->lParam);
1915 else if (msg->message == WM_CREATE)
1917 window = (UNALIGNED GdkWindow*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams);
1918 GDK_WINDOW_HWND (window) = msg->hwnd;
1922 GDK_NOTE (EVENTS, g_print (" (no GdkWindow)"));
1927 g_object_ref (window);
1929 /* window's refcount has now been increased, so code below should
1930 * not just return from this function, but instead goto done (or
1931 * break out of the big switch). To protect against forgetting this,
1932 * #define return to a syntax error...
1934 #define return GOTO_DONE_INSTEAD
1936 if (!GDK_WINDOW_DESTROYED (window) && ((GdkWindowObject *) window)->filters)
1938 /* Apply per-window filters */
1940 GdkFilterReturn result = apply_event_filters (window, msg, ((GdkWindowObject *) window)->filters);
1942 if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
1949 if (msg->message == client_message)
1952 GdkFilterReturn result = GDK_FILTER_CONTINUE;
1955 GDK_NOTE (EVENTS, g_print (" client_message"));
1957 event = gdk_event_new (GDK_NOTHING);
1958 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1960 node = _gdk_event_queue_append (_gdk_display, event);
1962 tmp_list = client_filters;
1965 GdkClientFilter *filter = tmp_list->data;
1967 tmp_list = tmp_list->next;
1969 if (filter->type == GDK_POINTER_TO_ATOM (msg->wParam))
1971 GDK_NOTE (EVENTS, g_print (" (match)"));
1973 result = (*filter->function) (msg, event, filter->data);
1975 if (result != GDK_FILTER_CONTINUE)
1982 case GDK_FILTER_REMOVE:
1983 _gdk_event_queue_remove_link (_gdk_display, node);
1984 g_list_free_1 (node);
1985 gdk_event_free (event);
1989 case GDK_FILTER_TRANSLATE:
1990 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1991 GDK_NOTE (EVENTS, print_event (event));
1995 case GDK_FILTER_CONTINUE:
1996 /* Send unknown client messages on to Gtk for it to use */
1998 event->client.type = GDK_CLIENT_EVENT;
1999 event->client.window = window;
2000 event->client.message_type = GDK_POINTER_TO_ATOM (msg->wParam);
2001 event->client.data_format = 32;
2002 event->client.data.l[0] = msg->lParam;
2003 for (i = 1; i < 5; i++)
2004 event->client.data.l[i] = 0;
2005 GDK_NOTE (EVENTS, print_event (event));
2011 switch (msg->message)
2013 case WM_INPUTLANGCHANGE:
2014 _gdk_input_locale = (HKL) msg->lParam;
2015 _gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale);
2016 GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
2017 LOCALE_IDEFAULTANSICODEPAGE,
2019 _gdk_input_codepage = atoi (buf);
2020 _gdk_keymap_serial++;
2022 g_print (" cs:%lu hkl:%p%s cp:%d",
2023 (gulong) msg->wParam,
2024 (gpointer) msg->lParam, _gdk_input_locale_is_ime ? " (IME)" : "",
2025 _gdk_input_codepage));
2031 g_print (" %s ch:%.02x %s",
2032 _gdk_win32_key_to_string (msg->lParam),
2034 decode_key_lparam (msg->lParam)));
2036 /* If posted without us having keyboard focus, ignore */
2037 if ((msg->wParam != VK_F10 && msg->wParam != VK_MENU) &&
2038 !(HIWORD (msg->lParam) & KF_ALTDOWN))
2041 /* Let the system handle Alt-Tab, Alt-Space and Alt-F4 unless
2042 * the keyboard is grabbed.
2044 if (_gdk_display->keyboard_grab.window == NULL &&
2045 (msg->wParam == VK_TAB ||
2046 msg->wParam == VK_SPACE ||
2047 msg->wParam == VK_F4))
2050 /* Jump to code in common with WM_KEYUP and WM_KEYDOWN */
2056 g_print (" %s ch:%.02x %s",
2057 _gdk_win32_key_to_string (msg->lParam),
2059 decode_key_lparam (msg->lParam)));
2063 /* Ignore key messages intended for the IME */
2064 if (msg->wParam == VK_PROCESSKEY ||
2068 if (!propagate (&window, msg,
2069 _gdk_display->keyboard_grab.window,
2070 _gdk_display->keyboard_grab.owner_events,
2071 GDK_ALL_EVENTS_MASK,
2072 doesnt_want_key, FALSE))
2075 if (GDK_WINDOW_DESTROYED (window))
2078 event = gdk_event_new ((msg->message == WM_KEYDOWN ||
2079 msg->message == WM_SYSKEYDOWN) ?
2080 GDK_KEY_PRESS : GDK_KEY_RELEASE);
2081 event->key.window = window;
2082 event->key.time = _gdk_win32_get_next_tick (msg->time);
2083 event->key.keyval = GDK_VoidSymbol;
2084 event->key.string = NULL;
2085 event->key.length = 0;
2086 event->key.hardware_keycode = msg->wParam;
2087 if (HIWORD (msg->lParam) & KF_EXTENDED)
2089 switch (msg->wParam)
2092 event->key.hardware_keycode = VK_RCONTROL;
2094 case VK_SHIFT: /* Actually, KF_EXTENDED is not set
2095 * for the right shift key.
2097 event->key.hardware_keycode = VK_RSHIFT;
2100 event->key.hardware_keycode = VK_RMENU;
2104 else if (msg->wParam == VK_SHIFT &&
2105 LOBYTE (HIWORD (msg->lParam)) == _scancode_rshift)
2106 event->key.hardware_keycode = VK_RSHIFT;
2108 API_CALL (GetKeyboardState, (key_state));
2110 /* g_print ("ctrl:%02x lctrl:%02x rctrl:%02x alt:%02x lalt:%02x ralt:%02x\n", key_state[VK_CONTROL], key_state[VK_LCONTROL], key_state[VK_RCONTROL], key_state[VK_MENU], key_state[VK_LMENU], key_state[VK_RMENU]); */
2112 build_key_event_state (event, key_state);
2114 gdk_keymap_translate_keyboard_state (NULL,
2115 event->key.hardware_keycode,
2121 fill_key_event_string (event);
2123 /* Reset MOD1_MASK if it is the Alt key itself */
2124 if (msg->wParam == VK_MENU)
2125 event->key.state &= ~GDK_MOD1_MASK;
2127 append_event (event);
2133 if (msg->wParam != VK_SPACE)
2135 /* To prevent beeps, don't let DefWindowProcW() be called */
2141 case WM_IME_STARTCOMPOSITION:
2142 in_ime_composition = TRUE;
2145 case WM_IME_ENDCOMPOSITION:
2146 in_ime_composition = FALSE;
2149 case WM_IME_COMPOSITION:
2150 /* On Win2k WM_IME_CHAR doesn't work correctly for non-Unicode
2151 * applications. Thus, handle WM_IME_COMPOSITION with
2152 * GCS_RESULTSTR instead, fetch the Unicode chars from the IME
2153 * with ImmGetCompositionStringW().
2156 * http://groups.google.com/groups?selm=natX5.57%24g77.19788%40nntp2.onemain.com
2158 * http://groups.google.com/groups?selm=u2XfrXw5BHA.1628%40tkmsftngp02
2159 * for comments by other people that seems to have the same
2160 * experience. WM_IME_CHAR just gives question marks, apparently
2161 * because of going through some conversion to the current code
2164 * WM_IME_CHAR might work on NT4 or Win9x with ActiveIMM, but
2165 * use WM_IME_COMPOSITION there, too, to simplify the code.
2167 GDK_NOTE (EVENTS, g_print (" %#lx", (long) msg->lParam));
2169 if (!(msg->lParam & GCS_RESULTSTR))
2172 if (!propagate (&window, msg,
2173 _gdk_display->keyboard_grab.window,
2174 _gdk_display->keyboard_grab.owner_events,
2175 GDK_ALL_EVENTS_MASK,
2176 doesnt_want_char, FALSE))
2179 if (GDK_WINDOW_DESTROYED (window))
2182 himc = ImmGetContext (msg->hwnd);
2183 ccount = ImmGetCompositionStringW (himc, GCS_RESULTSTR,
2184 wbuf, sizeof (wbuf));
2185 ImmReleaseContext (msg->hwnd, himc);
2189 API_CALL (GetKeyboardState, (key_state));
2191 for (i = 0; i < ccount; i++)
2193 if (((GdkWindowObject *) window)->event_mask & GDK_KEY_PRESS_MASK)
2195 /* Build a key press event */
2196 event = gdk_event_new (GDK_KEY_PRESS);
2197 event->key.window = window;
2198 build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
2200 append_event (event);
2203 if (((GdkWindowObject *) window)->event_mask & GDK_KEY_RELEASE_MASK)
2205 /* Build a key release event. */
2206 event = gdk_event_new (GDK_KEY_RELEASE);
2207 event->key.window = window;
2208 build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
2210 append_event (event);
2216 case WM_LBUTTONDOWN:
2220 case WM_MBUTTONDOWN:
2224 case WM_RBUTTONDOWN:
2228 case WM_XBUTTONDOWN:
2229 if (HIWORD (msg->wParam) == XBUTTON1)
2236 g_print (" (%d,%d)",
2237 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2239 if (GDK_WINDOW_DESTROYED (window))
2242 generate_button_event (GDK_BUTTON_PRESS, button,
2261 if (HIWORD (msg->wParam) == XBUTTON1)
2268 g_print (" (%d,%d)",
2269 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2272 if (((GdkWindowObject *) window)->extension_events != 0 &&
2273 _gdk_input_ignore_core)
2275 GDK_NOTE (EVENTS, g_print (" (ignored)"));
2280 generate_button_event (GDK_BUTTON_RELEASE, button,
2288 g_print (" %p (%d,%d)",
2289 (gpointer) msg->wParam,
2290 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2292 toplevel = gdk_window_get_toplevel (window);
2293 if (current_toplevel != toplevel)
2295 if (current_toplevel)
2296 synthesize_enter_or_leave_event (current_toplevel, msg,
2297 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2298 synthesize_enter_or_leave_event (toplevel, msg,
2299 GDK_ENTER_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2300 assign_object (¤t_toplevel, toplevel);
2301 track_mouse_event (TME_LEAVE, GDK_WINDOW_HWND (toplevel));
2304 /* If we haven't moved, don't create any GDK event. Windows
2305 * sends WM_MOUSEMOVE messages after a new window is shows under
2306 * the mouse, even if the mouse hasn't moved. This disturbs gtk.
2308 if (msg->pt.x + _gdk_offset_x == current_root_x &&
2309 msg->pt.y + _gdk_offset_y == current_root_y)
2312 current_root_x = msg->pt.x + _gdk_offset_x;
2313 current_root_y = msg->pt.y + _gdk_offset_y;
2315 event = gdk_event_new (GDK_MOTION_NOTIFY);
2316 event->motion.window = window;
2317 event->motion.time = _gdk_win32_get_next_tick (msg->time);
2318 event->motion.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
2319 event->motion.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
2320 event->motion.x_root = current_root_x;
2321 event->motion.y_root = current_root_y;
2322 event->motion.axes = NULL;
2323 event->motion.state = build_pointer_event_state (msg);
2324 event->motion.is_hint = FALSE;
2325 event->motion.device = _gdk_display->core_pointer;
2327 append_event (event);
2332 case WM_NCMOUSEMOVE:
2334 g_print (" (%d,%d)",
2335 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2340 GDK_NOTE (EVENTS, g_print (" %d (%ld,%ld)",
2341 HIWORD (msg->wParam), msg->pt.x, msg->pt.y));
2343 if (!gdk_win32_handle_table_lookup ((GdkNativeWindow) WindowFromPoint (msg->pt)))
2345 /* we are only interested if we don't know the new window */
2346 if (current_toplevel)
2347 synthesize_enter_or_leave_event (current_toplevel, msg,
2348 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2349 assign_object (¤t_toplevel, NULL);
2353 GDK_NOTE (EVENTS, g_print (" (ignored)"));
2360 GDK_NOTE (EVENTS, g_print (" %d", (short) HIWORD (msg->wParam)));
2362 /* WM_MOUSEWHEEL is delivered to the focus window. Work around
2363 * that. Also, the position is in screen coordinates, not client
2364 * coordinates as with the button messages. I love the
2365 * consistency of Windows.
2367 point.x = GET_X_LPARAM (msg->lParam);
2368 point.y = GET_Y_LPARAM (msg->lParam);
2370 if ((hwnd = WindowFromPoint (point)) == NULL)
2374 if ((new_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd)) == NULL)
2377 if (new_window != window)
2379 assign_object (&window, new_window);
2382 ScreenToClient (msg->hwnd, &point);
2384 event = gdk_event_new (GDK_SCROLL);
2385 event->scroll.window = window;
2386 event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
2387 GDK_SCROLL_UP : GDK_SCROLL_DOWN;
2388 event->scroll.time = _gdk_win32_get_next_tick (msg->time);
2389 event->scroll.x = (gint16) point.x;
2390 event->scroll.y = (gint16) point.y;
2391 event->scroll.x_root = (gint16) GET_X_LPARAM (msg->lParam) + _gdk_offset_x;
2392 event->scroll.y_root = (gint16) GET_Y_LPARAM (msg->lParam) + _gdk_offset_y;
2393 event->scroll.state = build_pointer_event_state (msg);
2394 event->scroll.device = _gdk_display->core_pointer;
2396 append_event (event);
2402 /* Just print more debugging information, don't actually handle it. */
2405 (LOWORD (msg->wParam) == SB_ENDSCROLL ? "ENDSCROLL" :
2406 (LOWORD (msg->wParam) == SB_LEFT ? "LEFT" :
2407 (LOWORD (msg->wParam) == SB_RIGHT ? "RIGHT" :
2408 (LOWORD (msg->wParam) == SB_LINELEFT ? "LINELEFT" :
2409 (LOWORD (msg->wParam) == SB_LINERIGHT ? "LINERIGHT" :
2410 (LOWORD (msg->wParam) == SB_PAGELEFT ? "PAGELEFT" :
2411 (LOWORD (msg->wParam) == SB_PAGERIGHT ? "PAGERIGHT" :
2412 (LOWORD (msg->wParam) == SB_THUMBPOSITION ? "THUMBPOSITION" :
2413 (LOWORD (msg->wParam) == SB_THUMBTRACK ? "THUMBTRACK" :
2415 (LOWORD (msg->wParam) == SB_THUMBPOSITION ||
2416 LOWORD (msg->wParam) == SB_THUMBTRACK) ?
2417 (g_print (" %d", HIWORD (msg->wParam)), 0) : 0));
2421 /* Just print more debugging information, don't actually handle it. */
2424 (LOWORD (msg->wParam) == SB_ENDSCROLL ? "ENDSCROLL" :
2425 (LOWORD (msg->wParam) == SB_BOTTOM ? "BOTTOM" :
2426 (LOWORD (msg->wParam) == SB_TOP ? "TOP" :
2427 (LOWORD (msg->wParam) == SB_LINEDOWN ? "LINDOWN" :
2428 (LOWORD (msg->wParam) == SB_LINEUP ? "LINEUP" :
2429 (LOWORD (msg->wParam) == SB_PAGEDOWN ? "PAGEDOWN" :
2430 (LOWORD (msg->wParam) == SB_PAGEUP ? "PAGEUP" :
2431 (LOWORD (msg->wParam) == SB_THUMBPOSITION ? "THUMBPOSITION" :
2432 (LOWORD (msg->wParam) == SB_THUMBTRACK ? "THUMBTRACK" :
2434 (LOWORD (msg->wParam) == SB_THUMBPOSITION ||
2435 LOWORD (msg->wParam) == SB_THUMBTRACK) ?
2436 (g_print (" %d", HIWORD (msg->wParam)), 0) : 0));
2439 case WM_QUERYNEWPALETTE:
2440 if (gdk_visual_get_system ()->type == GDK_VISUAL_PSEUDO_COLOR)
2442 synthesize_expose_events (window);
2443 update_colors_counter = 0;
2448 case WM_PALETTECHANGED:
2449 GDK_NOTE (EVENTS_OR_COLORMAP, g_print (" %p", (HWND) msg->wParam));
2450 if (gdk_visual_get_system ()->type != GDK_VISUAL_PSEUDO_COLOR)
2455 if (msg->hwnd == (HWND) msg->wParam)
2458 if (++update_colors_counter == 5)
2460 synthesize_expose_events (window);
2461 update_colors_counter = 0;
2465 update_colors (window, TRUE);
2468 case WM_MOUSEACTIVATE:
2472 if (gdk_window_get_window_type (window) == GDK_WINDOW_TEMP
2473 || !((GdkWindowObject *)window)->accept_focus)
2475 *ret_valp = MA_NOACTIVATE;
2479 tmp = _gdk_modal_current ();
2483 if (gdk_window_get_toplevel (window) != tmp)
2485 *ret_valp = MA_NOACTIVATEANDEAT;
2494 if (_gdk_display->keyboard_grab.window != NULL &&
2495 !GDK_WINDOW_DESTROYED (_gdk_display->keyboard_grab.window))
2497 generate_grab_broken_event (_gdk_display->keyboard_grab.window, FALSE, NULL);
2502 if (_gdk_display->keyboard_grab.window != NULL &&
2503 !_gdk_display->keyboard_grab.owner_events)
2506 if (!(((GdkWindowObject *) window)->event_mask & GDK_FOCUS_CHANGE_MASK))
2509 if (GDK_WINDOW_DESTROYED (window))
2512 generate_focus_event (window, (msg->message == WM_SETFOCUS));
2517 GDK_NOTE (EVENTS, g_print (" %p", (HANDLE) msg->wParam));
2519 if (GDK_WINDOW_DESTROYED (window))
2527 sync_timer = SetTimer (GDK_WINDOW_HWND (window),
2529 200, sync_timer_proc);
2533 handle_wm_paint (msg, window, FALSE, NULL);
2537 GDK_NOTE (EVENTS, g_print (" %#x %#x",
2538 LOWORD (msg->lParam), HIWORD (msg->lParam)));
2541 grab = _gdk_display_get_last_pointer_grab (_gdk_display);
2544 grab_window = grab->window;
2547 if (grab_window == NULL && LOWORD (msg->lParam) != HTCLIENT)
2550 if (grab_window != NULL && p_grab_cursor != NULL)
2551 hcursor = p_grab_cursor;
2552 else if (!GDK_WINDOW_DESTROYED (window))
2553 hcursor = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->hcursor;
2557 if (hcursor != NULL)
2559 GDK_NOTE (EVENTS, g_print (" (SetCursor(%p)", hcursor));
2560 SetCursor (hcursor);
2569 GDK_NOTE (EVENTS, g_print (" %s %s",
2570 (msg->wParam ? "YES" : "NO"),
2571 (msg->lParam == 0 ? "ShowWindow" :
2572 (msg->lParam == SW_OTHERUNZOOM ? "OTHERUNZOOM" :
2573 (msg->lParam == SW_OTHERZOOM ? "OTHERZOOM" :
2574 (msg->lParam == SW_PARENTCLOSING ? "PARENTCLOSING" :
2575 (msg->lParam == SW_PARENTOPENING ? "PARENTOPENING" :
2578 if (!(((GdkWindowObject *) window)->event_mask & GDK_STRUCTURE_MASK))
2581 if (msg->lParam == SW_OTHERUNZOOM ||
2582 msg->lParam == SW_OTHERZOOM)
2585 if (GDK_WINDOW_DESTROYED (window))
2588 event = gdk_event_new (msg->wParam ? GDK_MAP : GDK_UNMAP);
2589 event->any.window = window;
2591 append_event (event);
2593 if (event->any.type == GDK_UNMAP)
2595 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
2597 if (impl->transient_owner && GetForegroundWindow () == GDK_WINDOW_HWND (window))
2599 SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner));
2602 grab = _gdk_display_get_last_pointer_grab (_gdk_display);
2605 if (grab->window == window)
2606 gdk_pointer_ungrab (msg->time);
2609 if (_gdk_display->keyboard_grab.window == window)
2610 gdk_keyboard_ungrab (msg->time);
2617 switch (msg->wParam)
2621 do_show_window (window, msg->wParam == SC_MINIMIZE ? TRUE : FALSE);
2629 g_print (" %s %dx%d",
2630 (msg->wParam == SIZE_MAXHIDE ? "MAXHIDE" :
2631 (msg->wParam == SIZE_MAXIMIZED ? "MAXIMIZED" :
2632 (msg->wParam == SIZE_MAXSHOW ? "MAXSHOW" :
2633 (msg->wParam == SIZE_MINIMIZED ? "MINIMIZED" :
2634 (msg->wParam == SIZE_RESTORED ? "RESTORED" : "?"))))),
2635 LOWORD (msg->lParam), HIWORD (msg->lParam)));
2637 if (msg->wParam == SIZE_MINIMIZED)
2639 /* Don't generate any GDK event. This is *not* an UNMAP. */
2640 grab = _gdk_display_get_last_pointer_grab (_gdk_display);
2643 if (grab->window == window)
2644 gdk_pointer_ungrab (msg->time);
2646 if (_gdk_display->keyboard_grab.window == window)
2647 gdk_keyboard_ungrab (msg->time);
2649 gdk_synthesize_window_state (window,
2650 GDK_WINDOW_STATE_WITHDRAWN,
2651 GDK_WINDOW_STATE_ICONIFIED);
2652 do_show_window (window, TRUE);
2654 else if ((msg->wParam == SIZE_RESTORED ||
2655 msg->wParam == SIZE_MAXIMIZED) &&
2656 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
2658 GdkWindowState withdrawn_bit =
2659 IsWindowVisible (msg->hwnd) ? GDK_WINDOW_STATE_WITHDRAWN : 0;
2661 if (((GdkWindowObject *) window)->state & GDK_WINDOW_STATE_ICONIFIED)
2662 ensure_stacking_on_unminimize (msg);
2664 if (!GDK_WINDOW_DESTROYED (window))
2665 handle_configure_event (msg, window);
2667 if (msg->wParam == SIZE_RESTORED)
2669 gdk_synthesize_window_state (window,
2670 GDK_WINDOW_STATE_ICONIFIED |
2671 GDK_WINDOW_STATE_MAXIMIZED |
2675 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_TEMP && !GDK_WINDOW_IS_MAPPED (window))
2677 do_show_window (window, FALSE);
2680 else if (msg->wParam == SIZE_MAXIMIZED)
2682 gdk_synthesize_window_state (window,
2683 GDK_WINDOW_STATE_ICONIFIED |
2685 GDK_WINDOW_STATE_MAXIMIZED);
2688 if (((GdkWindowObject *) window)->resize_count > 1)
2689 ((GdkWindowObject *) window)->resize_count -= 1;
2691 if (((GdkWindowObject *) window)->extension_events != 0)
2692 _gdk_input_configure_event (window);
2698 case WM_ENTERSIZEMOVE:
2699 _sizemove_in_progress = TRUE;
2700 modal_timer = SetTimer (NULL, 0, 20, modal_timer_proc);
2703 case WM_EXITSIZEMOVE:
2704 _sizemove_in_progress = FALSE;
2705 KillTimer (NULL, modal_timer);
2708 case WM_ENTERMENULOOP:
2709 _sizemove_in_progress = TRUE;
2710 modal_timer = SetTimer (NULL, 0, 20, modal_timer_proc);
2713 case WM_EXITMENULOOP:
2714 _sizemove_in_progress = FALSE;
2715 KillTimer (NULL, modal_timer);
2718 case WM_WINDOWPOSCHANGING:
2719 GDK_NOTE (EVENTS, (windowpos = (WINDOWPOS *) msg->lParam,
2720 g_print (" %s %s %dx%d@%+d%+d now below %p",
2721 _gdk_win32_window_pos_bits_to_string (windowpos->flags),
2722 (windowpos->hwndInsertAfter == HWND_BOTTOM ? "BOTTOM" :
2723 (windowpos->hwndInsertAfter == HWND_NOTOPMOST ? "NOTOPMOST" :
2724 (windowpos->hwndInsertAfter == HWND_TOP ? "TOP" :
2725 (windowpos->hwndInsertAfter == HWND_TOPMOST ? "TOPMOST" :
2726 (sprintf (buf, "%p", windowpos->hwndInsertAfter),
2728 windowpos->cx, windowpos->cy, windowpos->x, windowpos->y,
2729 GetNextWindow (msg->hwnd, GW_HWNDPREV))));
2731 if (GDK_WINDOW_IS_MAPPED (window))
2732 return_val = ensure_stacking_on_window_pos_changing (msg, window);
2735 case WM_WINDOWPOSCHANGED:
2736 windowpos = (WINDOWPOS *) msg->lParam;
2737 GDK_NOTE (EVENTS, g_print (" %s %s %dx%d@%+d%+d",
2738 _gdk_win32_window_pos_bits_to_string (windowpos->flags),
2739 (windowpos->hwndInsertAfter == HWND_BOTTOM ? "BOTTOM" :
2740 (windowpos->hwndInsertAfter == HWND_NOTOPMOST ? "NOTOPMOST" :
2741 (windowpos->hwndInsertAfter == HWND_TOP ? "TOP" :
2742 (windowpos->hwndInsertAfter == HWND_TOPMOST ? "TOPMOST" :
2743 (sprintf (buf, "%p", windowpos->hwndInsertAfter),
2745 windowpos->cx, windowpos->cy, windowpos->x, windowpos->y));
2747 /* If position and size haven't changed, don't do anything */
2748 if (_sizemove_in_progress &&
2749 (windowpos->flags & SWP_NOMOVE) &&
2750 (windowpos->flags & SWP_NOSIZE))
2753 /* Once we've entered the moving or sizing modal loop, we won't
2754 * return to the main loop until we're done sizing or moving.
2756 if (_sizemove_in_progress &&
2757 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
2758 !GDK_WINDOW_DESTROYED (window))
2760 if (((GdkWindowObject *) window)->event_mask & GDK_STRUCTURE_MASK)
2762 GDK_NOTE (EVENTS, g_print (" do magic"));
2763 if (((GdkWindowObject *) window)->resize_count > 1)
2764 ((GdkWindowObject *) window)->resize_count -= 1;
2766 handle_configure_event (msg, window);
2767 g_main_context_iteration (NULL, FALSE);
2769 /* Dispatch main loop - to realize resizes... */
2770 handle_stuff_while_moving_or_resizing ();
2772 /* Claim as handled, so that WM_SIZE and WM_MOVE are avoided */
2780 GetWindowRect (GDK_WINDOW_HWND (window), &rect);
2781 drag = (RECT *) msg->lParam;
2782 GDK_NOTE (EVENTS, g_print (" %s curr:%s drag:%s",
2783 (msg->wParam == WMSZ_BOTTOM ? "BOTTOM" :
2784 (msg->wParam == WMSZ_BOTTOMLEFT ? "BOTTOMLEFT" :
2785 (msg->wParam == WMSZ_LEFT ? "LEFT" :
2786 (msg->wParam == WMSZ_TOPLEFT ? "TOPLEFT" :
2787 (msg->wParam == WMSZ_TOP ? "TOP" :
2788 (msg->wParam == WMSZ_TOPRIGHT ? "TOPRIGHT" :
2789 (msg->wParam == WMSZ_RIGHT ? "RIGHT" :
2791 (msg->wParam == WMSZ_BOTTOMRIGHT ? "BOTTOMRIGHT" :
2793 _gdk_win32_rect_to_string (&rect),
2794 _gdk_win32_rect_to_string (drag)));
2796 impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
2798 if (impl->hint_flags & GDK_HINT_RESIZE_INC)
2800 GDK_NOTE (EVENTS, g_print (" (RESIZE_INC)"));
2801 if (impl->hint_flags & GDK_HINT_BASE_SIZE)
2803 /* Resize in increments relative to the base size */
2804 rect.left = rect.top = 0;
2805 rect.right = impl->hints.base_width;
2806 rect.bottom = impl->hints.base_height;
2807 _gdk_win32_adjust_client_rect (window, &rect);
2808 point.x = rect.left;
2810 ClientToScreen (GDK_WINDOW_HWND (window), &point);
2811 rect.left = point.x;
2813 point.x = rect.right;
2814 point.y = rect.bottom;
2815 ClientToScreen (GDK_WINDOW_HWND (window), &point);
2816 rect.right = point.x;
2817 rect.bottom = point.y;
2819 GDK_NOTE (EVENTS, g_print (" (also BASE_SIZE, using %s)",
2820 _gdk_win32_rect_to_string (&rect)));
2823 switch (msg->wParam)
2826 if (drag->bottom == rect.bottom)
2828 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2831 case WMSZ_BOTTOMLEFT:
2832 if (drag->bottom == rect.bottom && drag->left == rect.left)
2834 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2835 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2839 if (drag->left == rect.left)
2841 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2845 if (drag->top == rect.top && drag->left == rect.left)
2847 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2848 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2852 if (drag->top == rect.top)
2854 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2858 if (drag->top == rect.top && drag->right == rect.right)
2860 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2861 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2865 if (drag->right == rect.right)
2867 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2870 case WMSZ_BOTTOMRIGHT:
2871 if (drag->bottom == rect.bottom && drag->right == rect.right)
2873 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2874 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2878 if (drag->bottom != orig_drag.bottom || drag->left != orig_drag.left ||
2879 drag->top != orig_drag.top || drag->right != orig_drag.right)
2883 GDK_NOTE (EVENTS, g_print (" (handled RESIZE_INC: %s)",
2884 _gdk_win32_rect_to_string (drag)));
2888 /* WM_GETMINMAXINFO handles min_size and max_size hints? */
2890 if (impl->hint_flags & GDK_HINT_ASPECT)
2892 RECT decorated_rect;
2893 RECT undecorated_drag;
2894 int decoration_width, decoration_height;
2895 gdouble drag_aspect;
2896 int drag_width, drag_height, new_width, new_height;
2898 GetClientRect (GDK_WINDOW_HWND (window), &rect);
2899 decorated_rect = rect;
2900 _gdk_win32_adjust_client_rect (window, &decorated_rect);
2902 /* Set undecorated_drag to the client area being dragged
2903 * out, in screen coordinates.
2905 undecorated_drag = *drag;
2906 undecorated_drag.left -= decorated_rect.left - rect.left;
2907 undecorated_drag.right -= decorated_rect.right - rect.right;
2908 undecorated_drag.top -= decorated_rect.top - rect.top;
2909 undecorated_drag.bottom -= decorated_rect.bottom - rect.bottom;
2911 decoration_width = (decorated_rect.right - decorated_rect.left) - (rect.right - rect.left);
2912 decoration_height = (decorated_rect.bottom - decorated_rect.top) - (rect.bottom - rect.top);
2914 drag_width = undecorated_drag.right - undecorated_drag.left;
2915 drag_height = undecorated_drag.bottom - undecorated_drag.top;
2917 drag_aspect = (gdouble) drag_width / drag_height;
2919 GDK_NOTE (EVENTS, g_print (" (ASPECT:%g--%g curr: %g)",
2920 impl->hints.min_aspect, impl->hints.max_aspect, drag_aspect));
2922 if (drag_aspect < impl->hints.min_aspect)
2924 /* Aspect is getting too narrow */
2925 switch (msg->wParam)
2929 /* User drags top or bottom edge outward. Keep height, increase width. */
2930 new_width = impl->hints.min_aspect * drag_height;
2931 drag->left -= (new_width - drag_width) / 2;
2932 drag->right = drag->left + new_width + decoration_width;
2934 case WMSZ_BOTTOMLEFT:
2935 case WMSZ_BOTTOMRIGHT:
2936 /* User drags bottom-left or bottom-right corner down. Adjust height. */
2937 new_height = drag_width / impl->hints.min_aspect;
2938 drag->bottom = drag->top + new_height + decoration_height;
2942 /* User drags left or right edge inward. Decrease height */
2943 new_height = drag_width / impl->hints.min_aspect;
2944 drag->top += (drag_height - new_height) / 2;
2945 drag->bottom = drag->top + new_height + decoration_height;
2949 /* User drags top-left or top-right corner up. Adjust height. */
2950 new_height = drag_width / impl->hints.min_aspect;
2951 drag->top = drag->bottom - new_height - decoration_height;
2954 else if (drag_aspect > impl->hints.max_aspect)
2956 /* Aspect is getting too wide */
2957 switch (msg->wParam)
2961 /* User drags top or bottom edge inward. Decrease width. */
2962 new_width = impl->hints.max_aspect * drag_height;
2963 drag->left += (drag_width - new_width) / 2;
2964 drag->right = drag->left + new_width + decoration_width;
2966 case WMSZ_BOTTOMLEFT:
2968 /* User drags bottom-left or top-left corner left. Adjust width. */
2969 new_width = impl->hints.max_aspect * drag_height;
2970 drag->left = drag->right - new_width - decoration_width;
2972 case WMSZ_BOTTOMRIGHT:
2974 /* User drags bottom-right or top-right corner right. Adjust width. */
2975 new_width = impl->hints.max_aspect * drag_height;
2976 drag->right = drag->left + new_width + decoration_width;
2980 /* User drags left or right edge outward. Increase height. */
2981 new_height = drag_width / impl->hints.max_aspect;
2982 drag->top -= (new_height - drag_height) / 2;
2983 drag->bottom = drag->top + new_height + decoration_height;
2990 GDK_NOTE (EVENTS, g_print (" (handled ASPECT: %s)",
2991 _gdk_win32_rect_to_string (drag)));
2995 case WM_GETMINMAXINFO:
2996 if (GDK_WINDOW_DESTROYED (window))
2999 impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
3000 mmi = (MINMAXINFO*) msg->lParam;
3001 GDK_NOTE (EVENTS, g_print (" (mintrack:%ldx%ld maxtrack:%ldx%ld "
3002 "maxpos:%+ld%+ld maxsize:%ldx%ld)",
3003 mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y,
3004 mmi->ptMaxTrackSize.x, mmi->ptMaxTrackSize.y,
3005 mmi->ptMaxPosition.x, mmi->ptMaxPosition.y,
3006 mmi->ptMaxSize.x, mmi->ptMaxSize.y));
3008 if (impl->hint_flags & GDK_HINT_MIN_SIZE)
3010 rect.left = rect.top = 0;
3011 rect.right = impl->hints.min_width;
3012 rect.bottom = impl->hints.min_height;
3014 _gdk_win32_adjust_client_rect (window, &rect);
3016 mmi->ptMinTrackSize.x = rect.right - rect.left;
3017 mmi->ptMinTrackSize.y = rect.bottom - rect.top;
3020 if (impl->hint_flags & GDK_HINT_MAX_SIZE)
3024 rect.left = rect.top = 0;
3025 rect.right = impl->hints.max_width;
3026 rect.bottom = impl->hints.max_height;
3028 _gdk_win32_adjust_client_rect (window, &rect);
3030 /* at least on win9x we have the 16 bit trouble */
3031 maxw = rect.right - rect.left;
3032 maxh = rect.bottom - rect.top;
3033 mmi->ptMaxTrackSize.x = maxw > 0 && maxw < G_MAXSHORT ? maxw : G_MAXSHORT;
3034 mmi->ptMaxTrackSize.y = maxh > 0 && maxh < G_MAXSHORT ? maxh : G_MAXSHORT;
3037 if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE))
3039 /* Don't call DefWindowProcW() */
3040 GDK_NOTE (EVENTS, g_print (" (handled, mintrack:%ldx%ld maxtrack:%ldx%ld "
3041 "maxpos:%+ld%+ld maxsize:%ldx%ld)",
3042 mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y,
3043 mmi->ptMaxTrackSize.x, mmi->ptMaxTrackSize.y,
3044 mmi->ptMaxPosition.x, mmi->ptMaxPosition.y,
3045 mmi->ptMaxSize.x, mmi->ptMaxSize.y));
3051 GDK_NOTE (EVENTS, g_print (" (%d,%d)",
3052 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
3054 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
3055 !IsIconic (msg->hwnd))
3057 if (!GDK_WINDOW_DESTROYED (window))
3058 handle_configure_event (msg, window);
3065 if (GDK_WINDOW_DESTROYED (window))
3068 event = gdk_event_new (GDK_DELETE);
3069 event->any.window = window;
3071 append_event (event);
3073 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
3075 if (impl->transient_owner && GetForegroundWindow() == GDK_WINDOW_HWND (window))
3077 SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner));
3084 grab = _gdk_display_get_last_pointer_grab (_gdk_display);
3087 if (grab->window == window)
3088 gdk_pointer_ungrab (msg->time);
3091 if (_gdk_display->keyboard_grab.window == window)
3092 gdk_keyboard_ungrab (msg->time);
3094 if ((window != NULL) && (msg->hwnd != GetDesktopWindow ()))
3095 gdk_window_destroy_notify (window);
3097 if (window == NULL || GDK_WINDOW_DESTROYED (window))
3100 event = gdk_event_new (GDK_DESTROY);
3101 event->any.window = window;
3103 append_event (event);
3108 case WM_DISPLAYCHANGE:
3109 handle_display_change ();
3112 case WM_DESTROYCLIPBOARD:
3113 if (!_ignore_destroy_clipboard)
3115 event = gdk_event_new (GDK_SELECTION_CLEAR);
3116 event->selection.window = window;
3117 event->selection.selection = GDK_SELECTION_CLIPBOARD;
3118 event->selection.time = _gdk_win32_get_next_tick (msg->time);
3119 append_event (event);
3128 case WM_RENDERFORMAT:
3129 GDK_NOTE (EVENTS, g_print (" %s", _gdk_win32_cf_to_string (msg->wParam)));
3131 if (!(target = g_hash_table_lookup (_format_atom_table, GINT_TO_POINTER (msg->wParam))))
3133 GDK_NOTE (EVENTS, g_print (" (target not found)"));
3138 /* We need to render to clipboard immediately, don't call
3141 if (_gdk_event_func)
3143 event = gdk_event_new (GDK_SELECTION_REQUEST);
3144 event->selection.window = window;
3145 event->selection.send_event = FALSE;
3146 event->selection.selection = GDK_SELECTION_CLIPBOARD;
3147 event->selection.target = target;
3148 event->selection.property = _gdk_selection;
3149 event->selection.requestor = msg->hwnd;
3150 event->selection.time = msg->time;
3152 fixup_event (event);
3153 GDK_NOTE (EVENTS, g_print (" (calling gdk_event_func)"));
3154 GDK_NOTE (EVENTS, print_event (event));
3155 (*_gdk_event_func) (event, _gdk_event_data);
3156 gdk_event_free (event);
3158 /* Now the clipboard owner should have rendered */
3159 if (!_delayed_rendering_data)
3161 GDK_NOTE (EVENTS, g_print (" (no _delayed_rendering_data?)"));
3165 if (msg->wParam == CF_DIB)
3167 _delayed_rendering_data =
3168 _gdk_win32_selection_convert_to_dib (_delayed_rendering_data,
3170 if (!_delayed_rendering_data)
3172 g_warning ("Cannot convert to DIB from delayed rendered image");
3177 /* The requestor is holding the clipboard, no
3178 * OpenClipboard() is required/possible
3181 g_print (" SetClipboardData(%s,%p)",
3182 _gdk_win32_cf_to_string (msg->wParam),
3183 _delayed_rendering_data));
3185 API_CALL (SetClipboardData, (msg->wParam, _delayed_rendering_data));
3186 _delayed_rendering_data = NULL;
3192 GDK_NOTE (EVENTS, g_print (" %s%s %p",
3193 (LOWORD (msg->wParam) == WA_ACTIVE ? "ACTIVE" :
3194 (LOWORD (msg->wParam) == WA_CLICKACTIVE ? "CLICKACTIVE" :
3195 (LOWORD (msg->wParam) == WA_INACTIVE ? "INACTIVE" : "???"))),
3196 HIWORD (msg->wParam) ? " minimized" : "",
3197 (HWND) msg->lParam));
3198 /* We handle mouse clicks for modally-blocked windows under WM_MOUSEACTIVATE,
3199 * but we still need to deal with alt-tab, or with SetActiveWindow() type
3202 if (is_modally_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
3204 GdkWindow *modal_current = _gdk_modal_current ();
3205 SetActiveWindow (GDK_WINDOW_HWND (modal_current));
3211 /* Bring any tablet contexts to the top of the overlap order when
3212 * one of our windows is activated.
3213 * NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP
3216 if (LOWORD(msg->wParam) != WA_INACTIVE)
3217 _gdk_input_set_tablet_active ();
3220 case WM_ACTIVATEAPP:
3221 GDK_NOTE (EVENTS, g_print (" %s thread: %I64d",
3222 msg->wParam ? "YES" : "NO",
3223 (gint64) msg->lParam));
3224 if (msg->wParam && GDK_WINDOW_IS_MAPPED (window))
3225 ensure_stacking_on_activate_app (msg, window);
3228 /* Handle WINTAB events here, as we know that gdkinput.c will
3229 * use the fixed WT_DEFBASE as lcMsgBase, and we thus can use the
3230 * constants as case labels.
3233 GDK_NOTE (EVENTS, g_print (" %d %p",
3234 (int) msg->wParam, (gpointer) msg->lParam));
3238 GDK_NOTE (EVENTS, g_print (" %d %p",
3239 (int) msg->wParam, (gpointer) msg->lParam));
3243 GDK_NOTE (EVENTS, g_print (" %p %d %d",
3244 (gpointer) msg->wParam,
3245 LOWORD (msg->lParam),
3246 HIWORD (msg->lParam)));
3250 event = gdk_event_new (GDK_NOTHING);
3251 event->any.window = window;
3252 g_object_ref (window);
3254 if (_gdk_input_other_event (event, msg, window))
3255 append_event (event);
3257 gdk_event_free (event);
3265 g_object_unref (window);
3272 _gdk_events_queue (GdkDisplay *display)
3276 if (modal_win32_dialog != NULL)
3279 while (!_gdk_event_queue_find_first (display) &&
3280 PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3282 TranslateMessage (&msg);
3283 DispatchMessageW (&msg);
3288 gdk_event_prepare (GSource *source,
3294 GDK_THREADS_ENTER ();
3298 retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
3299 (modal_win32_dialog == NULL &&
3300 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
3302 GDK_THREADS_LEAVE ();
3308 gdk_event_check (GSource *source)
3313 GDK_THREADS_ENTER ();
3315 if (event_poll_fd.revents & G_IO_IN)
3317 retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
3318 (modal_win32_dialog == NULL &&
3319 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
3326 GDK_THREADS_LEAVE ();
3332 gdk_event_dispatch (GSource *source,
3333 GSourceFunc callback,
3338 GDK_THREADS_ENTER ();
3340 _gdk_events_queue (_gdk_display);
3341 event = _gdk_event_unqueue (_gdk_display);
3345 if (_gdk_event_func)
3346 (*_gdk_event_func) (event, _gdk_event_data);
3348 gdk_event_free (event);
3351 GDK_THREADS_LEAVE ();
3357 gdk_win32_set_modal_dialog_libgtk_only (HWND window)
3359 modal_win32_dialog = window;
3363 is_modally_blocked (GdkWindow *window)
3365 GdkWindow *modal_current = _gdk_modal_current ();
3366 return modal_current != NULL ? gdk_window_get_toplevel (window) != modal_current : FALSE;
3370 check_for_too_much_data (GdkEvent *event)
3372 if (event->client.data.l[1] ||
3373 event->client.data.l[2] ||
3374 event->client.data.l[3] ||
3375 event->client.data.l[4])
3377 g_warning ("Only four bytes of data are passed in client messages on Win32\n");
3382 gdk_event_send_client_message_for_display (GdkDisplay *display,
3384 GdkNativeWindow winid)
3386 check_for_too_much_data (event);
3388 return PostMessageW ((HWND) winid, client_message,
3389 (WPARAM) event->client.message_type,
3390 event->client.data.l[0]);
3394 gdk_screen_broadcast_client_message (GdkScreen *screen,
3397 check_for_too_much_data (event);
3399 PostMessageW (HWND_BROADCAST, client_message,
3400 (WPARAM) event->client.message_type,
3401 event->client.data.l[0]);
3410 /* Process all messages currently available */
3411 while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3413 TranslateMessage (&msg);
3414 DispatchMessageW (&msg);
3422 gdk_display_sync (GdkDisplay * display)
3426 g_return_if_fail (display == _gdk_display);
3428 /* Process all messages currently available */
3429 while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3430 DispatchMessageW (&msg);
3434 gdk_display_flush (GdkDisplay * display)
3436 g_return_if_fail (display == _gdk_display);
3442 gdk_net_wm_supports (GdkAtom property)
3448 _gdk_windowing_event_data_copy (const GdkEvent *src,
3454 _gdk_windowing_event_data_free (GdkEvent *event)