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) 2001,2009 Hans Breuer
5 * Copyright (C) 2007-2009 Cody Russell
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
25 * file for a list of people on the GTK+ Team. See the ChangeLog
26 * files for a list of changes. These files are distributed with
27 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
30 /* Cannot use TrackMouseEvent, as the stupid WM_MOUSELEAVE message
31 * doesn't tell us where the mouse has gone. Thus we cannot use it to
32 * generate a correct GdkNotifyType. Pity, as using TrackMouseEvent
33 * otherwise would make it possible to reliably generate
34 * GDK_LEAVE_NOTIFY events, which would help get rid of those pesky
35 * tooltips sometimes popping up in the wrong place.
37 * Update: a combination of TrackMouseEvent, GetCursorPos and
38 * GetWindowPos can and is actually used to get rid of those
39 * pesky tooltips. It should be possible to use this for the
40 * whole ENTER/LEAVE NOTIFY handling but some platforms may
41 * not have TrackMouseEvent at all (?) --hb
46 #include <glib/gprintf.h>
49 #include "gdkprivate-win32.h"
50 #include "gdkkeysyms.h"
51 #include "gdkdevicemanager-win32.h"
52 #include "gdkdeviceprivate.h"
53 #include "gdkdevice-wintab.h"
77 #define MK_XBUTTON1 32
78 #define MK_XBUTTON2 64
82 * Private function declarations
85 static gboolean gdk_event_translate (MSG *msg,
87 static void handle_wm_paint (MSG *msg,
89 gboolean return_exposes,
92 static gboolean gdk_event_prepare (GSource *source,
94 static gboolean gdk_event_check (GSource *source);
95 static gboolean gdk_event_dispatch (GSource *source,
99 static void append_event (GdkEvent *event);
100 static gboolean is_modally_blocked (GdkWindow *window);
102 /* Private variable declarations
105 static GList *client_filters; /* Filters for client messages */
106 extern gint _gdk_input_ignore_core;
108 static HCURSOR p_grab_cursor;
110 static GSourceFuncs event_funcs = {
117 GPollFD event_poll_fd;
119 static GdkWindow *current_toplevel = NULL;
120 static gint current_x, current_y;
121 static gint current_root_x, current_root_y;
122 static UINT client_message;
124 static UINT got_gdk_events_message;
125 static HWND modal_win32_dialog = NULL;
128 static HKL latin_locale = NULL;
131 static gboolean in_ime_composition = FALSE;
132 static UINT modal_timer;
133 static UINT sync_timer = 0;
135 static int debug_indent = 0;
138 assign_object (gpointer lhsp,
141 if (*(gpointer *)lhsp != rhs)
143 if (*(gpointer *)lhsp != NULL)
144 g_object_unref (*(gpointer *)lhsp);
145 *(gpointer *)lhsp = rhs;
152 track_mouse_event (DWORD dwFlags,
157 tme.cbSize = sizeof(TRACKMOUSEEVENT);
158 tme.dwFlags = dwFlags;
159 tme.hwndTrack = hwnd;
160 tme.dwHoverTime = HOVER_DEFAULT; /* not used */
162 if (!TrackMouseEvent (&tme))
163 WIN32_API_FAILED ("TrackMouseEvent");
164 else if (dwFlags == TME_LEAVE)
165 GDK_NOTE (EVENTS, g_print(" (TrackMouseEvent %p)", hwnd));
166 else if (dwFlags == TME_CANCEL)
167 GDK_NOTE (EVENTS, g_print(" (cancel TrackMouseEvent %p)", hwnd));
171 _gdk_win32_get_next_tick (gulong suggested_tick)
173 static gulong cur_tick = 0;
175 if (suggested_tick == 0)
176 suggested_tick = GetTickCount ();
177 if (suggested_tick <= cur_tick)
180 return cur_tick = suggested_tick;
184 generate_focus_event (GdkDeviceManager *device_manager,
191 device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard;
193 event = gdk_event_new (GDK_FOCUS_CHANGE);
194 event->focus_change.window = window;
195 event->focus_change.in = in;
196 gdk_event_set_device (event, device);
198 append_event (event);
202 generate_grab_broken_event (GdkDeviceManager *device_manager,
205 GdkWindow *grab_window)
207 GdkEvent *event = gdk_event_new (GDK_GRAB_BROKEN);
211 device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard;
213 device = GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_pointer;
215 event->grab_broken.window = window;
216 event->grab_broken.send_event = 0;
217 event->grab_broken.keyboard = keyboard;
218 event->grab_broken.implicit = FALSE;
219 event->grab_broken.grab_window = grab_window;
220 gdk_event_set_device (event, device);
222 append_event (event);
226 inner_window_procedure (HWND hwnd,
236 msg.message = message;
239 msg.time = _gdk_win32_get_next_tick (0);
240 pos = GetMessagePos ();
241 msg.pt.x = GET_X_LPARAM (pos);
242 msg.pt.y = GET_Y_LPARAM (pos);
244 if (gdk_event_translate (&msg, &ret_val))
246 /* If gdk_event_translate() returns TRUE, we return ret_val from
247 * the window procedure.
249 if (modal_win32_dialog)
250 PostMessageW (modal_win32_dialog, got_gdk_events_message,
256 /* Otherwise call DefWindowProcW(). */
257 GDK_NOTE (EVENTS, g_print (" DefWindowProcW"));
258 return DefWindowProcW (hwnd, message, wparam, lparam);
263 _gdk_win32_window_procedure (HWND hwnd,
270 GDK_NOTE (EVENTS, g_print ("%s%*s%s %p",
271 (debug_indent > 0 ? "\n" : ""),
273 _gdk_win32_message_to_string (message), hwnd));
275 retval = inner_window_procedure (hwnd, message, wparam, lparam);
278 GDK_NOTE (EVENTS, g_print (" => %I64d%s", (gint64) retval, (debug_indent == 0 ? "\n" : "")));
284 _gdk_events_init (void)
291 /* List of languages that use a latin keyboard. Somewhat sorted in
292 * "order of least surprise", in case we have to load one of them if
293 * the user only has arabic loaded, for instance.
295 static int latin_languages[] = {
301 /* Rest in numeric order */
330 client_message = RegisterWindowMessage ("GDK_WIN32_CLIENT_MESSAGE");
331 got_gdk_events_message = RegisterWindowMessage ("GDK_WIN32_GOT_EVENTS");
334 /* Check if we have some input locale identifier loaded that uses a
335 * latin keyboard, to be able to get the virtual-key code for the
336 * latin characters corresponding to ASCII control characters.
338 if ((n = GetKeyboardLayoutList (0, NULL)) == 0)
339 WIN32_API_FAILED ("GetKeyboardLayoutList");
342 HKL *hkl_list = g_new (HKL, n);
343 if (GetKeyboardLayoutList (n, hkl_list) == 0)
344 WIN32_API_FAILED ("GetKeyboardLayoutList");
347 for (i = 0; latin_locale == NULL && i < n; i++)
348 for (j = 0; j < G_N_ELEMENTS (latin_languages); j++)
349 if (PRIMARYLANGID (LOWORD (hkl_list[i])) == latin_languages[j])
351 latin_locale = hkl_list [i];
358 if (latin_locale == NULL)
360 /* Try to load a keyboard layout with latin characters then.
363 while (latin_locale == NULL && i < G_N_ELEMENTS (latin_languages))
366 g_sprintf (id, "%08x", MAKELANGID (latin_languages[i++], SUBLANG_DEFAULT));
367 latin_locale = LoadKeyboardLayout (id, KLF_NOTELLSHELL|KLF_SUBSTITUTE_OK);
371 GDK_NOTE (EVENTS, g_print ("latin_locale = %08x\n", (guint) latin_locale));
374 source = g_source_new (&event_funcs, sizeof (GSource));
375 g_source_set_name (source, "GDK Win32 event source");
376 g_source_set_priority (source, GDK_PRIORITY_EVENTS);
379 event_poll_fd.fd = open ("/dev/windows", O_RDONLY);
380 if (event_poll_fd.fd == -1)
381 g_error ("can't open \"/dev/windows\": %s", g_strerror (errno));
383 event_poll_fd.fd = G_WIN32_MSG_HANDLE;
385 event_poll_fd.events = G_IO_IN;
387 g_source_add_poll (source, &event_poll_fd);
388 g_source_set_can_recurse (source, TRUE);
389 g_source_attach (source, NULL);
393 gdk_events_pending (void)
396 return (_gdk_event_queue_find_first (_gdk_display) ||
397 (modal_win32_dialog == NULL &&
398 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
401 #if 0 /* Unused, but might be useful to re-introduce in some debugging output? */
404 event_mask_string (GdkEventMask mask)
406 static char bfr[500];
411 if (mask & GDK_##x##_MASK) \
412 p += g_sprintf (p, "%s" #x, (p > bfr ? " " : ""))
414 BIT (POINTER_MOTION);
415 BIT (POINTER_MOTION_HINT);
417 BIT (BUTTON1_MOTION);
418 BIT (BUTTON2_MOTION);
419 BIT (BUTTON3_MOTION);
421 BIT (BUTTON_RELEASE);
428 BIT (PROPERTY_CHANGE);
429 BIT (VISIBILITY_NOTIFY);
442 _gdk_windowing_device_grab (GdkDevice *device,
444 GdkWindow *native_window,
445 gboolean owner_events,
446 GdkEventMask event_mask,
447 GdkWindow *confine_to,
452 GdkCursorPrivate *cursor_private;
454 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) native_window)->impl);
456 g_return_val_if_fail (window != NULL, 0);
457 g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
458 g_return_val_if_fail (confine_to == NULL || GDK_IS_WINDOW (confine_to), 0);
460 cursor_private = (GdkCursorPrivate*) cursor;
464 else if ((hcursor = CopyCursor (cursor_private->hcursor)) == NULL)
465 WIN32_API_FAILED ("CopyCursor");
467 return_val = GDK_DEVICE_GET_CLASS (device)->grab (device,
475 /* TODO_CSW: grab brokens, confine window, input_grab */
476 if (p_grab_cursor != NULL)
478 if (GetCursor () == p_grab_cursor)
480 DestroyCursor (p_grab_cursor);
483 p_grab_cursor = hcursor;
485 if (p_grab_cursor != NULL)
486 SetCursor (p_grab_cursor);
487 else if (impl->hcursor != NULL)
488 SetCursor (impl->hcursor);
490 SetCursor (LoadCursor (NULL, IDC_ARROW));
496 gdk_device_ungrab (GdkDevice *device,
499 GdkDeviceGrabInfo *info;
502 g_return_if_fail (GDK_IS_DEVICE (device));
504 display = gdk_device_get_display (device);
505 info = _gdk_display_get_last_device_grab (display, device);
509 info->serial_end = 0;
510 GDK_DEVICE_GET_CLASS (device)->ungrab (device, time);
513 _gdk_display_device_grab_update (display, device, 0);
518 find_window_for_mouse_event (GdkWindow* reported_window,
524 GdkWindow* other_window = NULL;
525 GdkDeviceManagerWin32 *device_manager;
527 device_manager = GDK_DEVICE_MANAGER_WIN32 (gdk_display_get_device_manager (_gdk_display));
529 if (!_gdk_display_get_last_device_grab (_gdk_display, device_manager->core_pointer))
530 return reported_window;
532 points = MAKEPOINTS (msg->lParam);
535 ClientToScreen (msg->hwnd, &pt);
537 hwnd = WindowFromPoint (pt);
543 GetClientRect (hwnd, &rect);
544 ScreenToClient (hwnd, &pt);
545 if (!PtInRect (&rect, pt))
548 other_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) hwnd);
551 if (other_window == NULL)
554 /* need to also adjust the coordinates to the new window */
557 ClientToScreen (msg->hwnd, &pt);
558 ScreenToClient (GDK_WINDOW_HWND (other_window), &pt);
559 /* ATTENTION: need to update client coords */
560 msg->lParam = MAKELPARAM (pt.x, pt.y);
566 gdk_display_add_client_message_filter (GdkDisplay *display,
567 GdkAtom message_type,
572 gdk_add_client_message_filter (message_type, func, data);
576 gdk_add_client_message_filter (GdkAtom message_type,
580 GdkClientFilter *filter = g_new (GdkClientFilter, 1);
582 filter->type = message_type;
583 filter->function = func;
586 client_filters = g_list_append (client_filters, filter);
590 build_key_event_state (GdkEvent *event,
593 event->key.state = 0;
595 if (key_state[VK_SHIFT] & 0x80)
596 event->key.state |= GDK_SHIFT_MASK;
598 if (key_state[VK_CAPITAL] & 0x01)
599 event->key.state |= GDK_LOCK_MASK;
601 if (key_state[VK_LBUTTON] & 0x80)
602 event->key.state |= GDK_BUTTON1_MASK;
603 if (key_state[VK_MBUTTON] & 0x80)
604 event->key.state |= GDK_BUTTON2_MASK;
605 if (key_state[VK_RBUTTON] & 0x80)
606 event->key.state |= GDK_BUTTON3_MASK;
607 if (key_state[VK_XBUTTON1] & 0x80)
608 event->key.state |= GDK_BUTTON4_MASK;
609 if (key_state[VK_XBUTTON2] & 0x80)
610 event->key.state |= GDK_BUTTON5_MASK;
612 if (_gdk_keyboard_has_altgr &&
613 (key_state[VK_LCONTROL] & 0x80) &&
614 (key_state[VK_RMENU] & 0x80))
616 event->key.group = 1;
617 event->key.state |= GDK_MOD2_MASK;
618 if (key_state[VK_RCONTROL] & 0x80)
619 event->key.state |= GDK_CONTROL_MASK;
620 if (key_state[VK_LMENU] & 0x80)
621 event->key.state |= GDK_MOD1_MASK;
625 event->key.group = 0;
626 if (key_state[VK_CONTROL] & 0x80)
627 event->key.state |= GDK_CONTROL_MASK;
628 if (key_state[VK_MENU] & 0x80)
629 event->key.state |= GDK_MOD1_MASK;
634 build_pointer_event_state (MSG *msg)
640 if (msg->wParam & MK_CONTROL)
641 state |= GDK_CONTROL_MASK;
643 if ((msg->message != WM_LBUTTONDOWN &&
644 (msg->wParam & MK_LBUTTON)) ||
645 msg->message == WM_LBUTTONUP)
646 state |= GDK_BUTTON1_MASK;
648 if ((msg->message != WM_MBUTTONDOWN &&
649 (msg->wParam & MK_MBUTTON)) ||
650 msg->message == WM_MBUTTONUP)
651 state |= GDK_BUTTON2_MASK;
653 if ((msg->message != WM_RBUTTONDOWN &&
654 (msg->wParam & MK_RBUTTON)) ||
655 msg->message == WM_RBUTTONUP)
656 state |= GDK_BUTTON3_MASK;
658 if (((msg->message != WM_XBUTTONDOWN || HIWORD (msg->wParam) != XBUTTON1) &&
659 (msg->wParam & MK_XBUTTON1)) ||
660 (msg->message == WM_XBUTTONUP && HIWORD (msg->wParam) == XBUTTON1))
661 state |= GDK_BUTTON4_MASK;
663 if (((msg->message != WM_XBUTTONDOWN || HIWORD (msg->wParam) != XBUTTON2) &&
664 (msg->wParam & MK_XBUTTON2)) ||
665 (msg->message == WM_XBUTTONUP && HIWORD (msg->wParam) == XBUTTON2))
666 state |= GDK_BUTTON5_MASK;
668 if (msg->wParam & MK_SHIFT)
669 state |= GDK_SHIFT_MASK;
671 if (GetKeyState (VK_MENU) < 0)
672 state |= GDK_MOD1_MASK;
674 if (GetKeyState (VK_CAPITAL) & 0x1)
675 state |= GDK_LOCK_MASK;
681 build_wm_ime_composition_event (GdkEvent *event,
686 event->key.time = _gdk_win32_get_next_tick (msg->time);
688 build_key_event_state (event, key_state);
690 event->key.hardware_keycode = 0; /* FIXME: What should it be? */
691 event->key.string = NULL;
692 event->key.length = 0;
693 event->key.keyval = gdk_unicode_to_keyval (wc);
696 #ifdef G_ENABLE_DEBUG
699 print_event_state (guint state)
701 #define CASE(bit) if (state & GDK_ ## bit ## _MASK) g_print (#bit " ");
719 _gdk_win32_print_event (const GdkEvent *event)
721 gchar *escaped, *kvname;
722 gchar *selection_name, *target_name, *property_name;
724 g_print ("%s%*s===> ", (debug_indent > 0 ? "\n" : ""), debug_indent, "");
725 switch (event->any.type)
727 #define CASE(x) case x: g_print (#x); break;
732 CASE (GDK_MOTION_NOTIFY);
733 CASE (GDK_BUTTON_PRESS);
734 CASE (GDK_2BUTTON_PRESS);
735 CASE (GDK_3BUTTON_PRESS);
736 CASE (GDK_BUTTON_RELEASE);
737 CASE (GDK_KEY_PRESS);
738 CASE (GDK_KEY_RELEASE);
739 CASE (GDK_ENTER_NOTIFY);
740 CASE (GDK_LEAVE_NOTIFY);
741 CASE (GDK_FOCUS_CHANGE);
742 CASE (GDK_CONFIGURE);
745 CASE (GDK_PROPERTY_NOTIFY);
746 CASE (GDK_SELECTION_CLEAR);
747 CASE (GDK_SELECTION_REQUEST);
748 CASE (GDK_SELECTION_NOTIFY);
749 CASE (GDK_PROXIMITY_IN);
750 CASE (GDK_PROXIMITY_OUT);
751 CASE (GDK_DRAG_ENTER);
752 CASE (GDK_DRAG_LEAVE);
753 CASE (GDK_DRAG_MOTION);
754 CASE (GDK_DRAG_STATUS);
755 CASE (GDK_DROP_START);
756 CASE (GDK_DROP_FINISHED);
757 CASE (GDK_CLIENT_EVENT);
758 CASE (GDK_VISIBILITY_NOTIFY);
760 CASE (GDK_WINDOW_STATE);
762 CASE (GDK_OWNER_CHANGE);
763 CASE (GDK_GRAB_BROKEN);
765 default: g_assert_not_reached ();
768 g_print (" %p ", event->any.window ? GDK_WINDOW_HWND (event->any.window) : NULL);
770 switch (event->any.type)
774 _gdk_win32_gdkrectangle_to_string (&event->expose.area),
775 event->expose.count);
777 case GDK_MOTION_NOTIFY:
778 g_print ("(%.4g,%.4g) (%.4g,%.4g) %s",
779 event->motion.x, event->motion.y,
780 event->motion.x_root, event->motion.y_root,
781 event->motion.is_hint ? "HINT " : "");
782 print_event_state (event->motion.state);
784 case GDK_BUTTON_PRESS:
785 case GDK_2BUTTON_PRESS:
786 case GDK_3BUTTON_PRESS:
787 case GDK_BUTTON_RELEASE:
788 g_print ("%d (%.4g,%.4g) (%.4g,%.4g) ",
789 event->button.button,
790 event->button.x, event->button.y,
791 event->button.x_root, event->button.y_root);
792 print_event_state (event->button.state);
795 case GDK_KEY_RELEASE:
796 if (event->key.length == 0)
797 escaped = g_strdup ("");
799 escaped = g_strescape (event->key.string, NULL);
800 kvname = gdk_keyval_name (event->key.keyval);
801 g_print ("%#.02x group:%d %s %d:\"%s\" ",
802 event->key.hardware_keycode, event->key.group,
803 (kvname ? kvname : "??"),
807 print_event_state (event->key.state);
809 case GDK_ENTER_NOTIFY:
810 case GDK_LEAVE_NOTIFY:
811 g_print ("%p (%.4g,%.4g) (%.4g,%.4g) %s %s%s",
812 event->crossing.subwindow == NULL ? NULL : GDK_WINDOW_HWND (event->crossing.subwindow),
813 event->crossing.x, event->crossing.y,
814 event->crossing.x_root, event->crossing.y_root,
815 (event->crossing.mode == GDK_CROSSING_NORMAL ? "NORMAL" :
816 (event->crossing.mode == GDK_CROSSING_GRAB ? "GRAB" :
817 (event->crossing.mode == GDK_CROSSING_UNGRAB ? "UNGRAB" :
819 (event->crossing.detail == GDK_NOTIFY_ANCESTOR ? "ANCESTOR" :
820 (event->crossing.detail == GDK_NOTIFY_VIRTUAL ? "VIRTUAL" :
821 (event->crossing.detail == GDK_NOTIFY_INFERIOR ? "INFERIOR" :
822 (event->crossing.detail == GDK_NOTIFY_NONLINEAR ? "NONLINEAR" :
823 (event->crossing.detail == GDK_NOTIFY_NONLINEAR_VIRTUAL ? "NONLINEAR_VIRTUAL" :
824 (event->crossing.detail == GDK_NOTIFY_UNKNOWN ? "UNKNOWN" :
826 event->crossing.focus ? " FOCUS" : "");
827 print_event_state (event->crossing.state);
829 case GDK_FOCUS_CHANGE:
830 g_print ("%s", (event->focus_change.in ? "IN" : "OUT"));
833 g_print ("x:%d y:%d w:%d h:%d",
834 event->configure.x, event->configure.y,
835 event->configure.width, event->configure.height);
837 case GDK_SELECTION_CLEAR:
838 case GDK_SELECTION_REQUEST:
839 case GDK_SELECTION_NOTIFY:
840 selection_name = gdk_atom_name (event->selection.selection);
841 target_name = gdk_atom_name (event->selection.target);
842 property_name = gdk_atom_name (event->selection.property);
843 g_print ("sel:%s tgt:%s prop:%s",
844 selection_name, target_name, property_name);
845 g_free (selection_name);
846 g_free (target_name);
847 g_free (property_name);
851 case GDK_DRAG_MOTION:
852 case GDK_DRAG_STATUS:
854 case GDK_DROP_FINISHED:
855 if (event->dnd.context != NULL)
856 g_print ("ctx:%p: %s %s src:%p dest:%p",
858 _gdk_win32_drag_protocol_to_string (event->dnd.context->protocol),
859 event->dnd.context->is_source ? "SOURCE" : "DEST",
860 event->dnd.context->source_window == NULL ? NULL : GDK_WINDOW_HWND (event->dnd.context->source_window),
861 event->dnd.context->dest_window == NULL ? NULL : GDK_WINDOW_HWND (event->dnd.context->dest_window));
863 case GDK_CLIENT_EVENT:
864 g_print ("%s %d %ld %ld %ld %ld %ld",
865 gdk_atom_name (event->client.message_type),
866 event->client.data_format,
867 event->client.data.l[0],
868 event->client.data.l[1],
869 event->client.data.l[2],
870 event->client.data.l[3],
871 event->client.data.l[4]);
874 g_print ("(%.4g,%.4g) (%.4g,%.4g) %s ",
875 event->scroll.x, event->scroll.y,
876 event->scroll.x_root, event->scroll.y_root,
877 (event->scroll.direction == GDK_SCROLL_UP ? "UP" :
878 (event->scroll.direction == GDK_SCROLL_DOWN ? "DOWN" :
879 (event->scroll.direction == GDK_SCROLL_LEFT ? "LEFT" :
880 (event->scroll.direction == GDK_SCROLL_RIGHT ? "RIGHT" :
882 print_event_state (event->scroll.state);
884 case GDK_WINDOW_STATE:
886 _gdk_win32_window_state_to_string (event->window_state.changed_mask),
887 _gdk_win32_window_state_to_string (event->window_state.new_window_state));
890 (event->setting.action == GDK_SETTING_ACTION_NEW ? "NEW" :
891 (event->setting.action == GDK_SETTING_ACTION_CHANGED ? "CHANGED" :
892 (event->setting.action == GDK_SETTING_ACTION_DELETED ? "DELETED" :
894 (event->setting.name ? event->setting.name : "NULL"));
895 case GDK_GRAB_BROKEN:
897 (event->grab_broken.keyboard ? "KEYBOARD" : "POINTER"),
898 (event->grab_broken.implicit ? "IMPLICIT" : "EXPLICIT"),
899 (event->grab_broken.grab_window ? GDK_WINDOW_HWND (event->grab_broken.grab_window) : 0));
904 g_print ("%s", (debug_indent == 0 ? "\n" : ""));
908 decode_key_lparam (LPARAM lParam)
910 static char buf[100];
913 if (HIWORD (lParam) & KF_UP)
914 p += g_sprintf (p, "KF_UP ");
915 if (HIWORD (lParam) & KF_REPEAT)
916 p += g_sprintf (p, "KF_REPEAT ");
917 if (HIWORD (lParam) & KF_ALTDOWN)
918 p += g_sprintf (p, "KF_ALTDOWN ");
919 if (HIWORD (lParam) & KF_EXTENDED)
920 p += g_sprintf (p, "KF_EXTENDED ");
921 p += g_sprintf (p, "sc:%d rep:%d", LOBYTE (HIWORD (lParam)), LOWORD (lParam));
929 fixup_event (GdkEvent *event)
931 if (event->any.window)
932 g_object_ref (event->any.window);
933 if (((event->any.type == GDK_ENTER_NOTIFY) ||
934 (event->any.type == GDK_LEAVE_NOTIFY)) &&
935 (event->crossing.subwindow != NULL))
936 g_object_ref (event->crossing.subwindow);
937 event->any.send_event = InSendMessage ();
941 append_event (GdkEvent *event)
947 link = _gdk_event_queue_append (_gdk_display, event);
948 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
949 /* event morphing, the passed in may not be valid afterwards */
950 _gdk_windowing_got_event (_gdk_display, link, event, 0);
952 _gdk_event_queue_append (_gdk_display, event);
953 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
958 fill_key_event_string (GdkEvent *event)
963 /* Fill in event->string crudely, since various programs
968 if (event->key.keyval != GDK_KEY_VoidSymbol)
969 c = gdk_keyval_to_unicode (event->key.keyval);
976 /* Apply the control key - Taken from Xlib
978 if (event->key.state & GDK_CONTROL_MASK)
980 if ((c >= '@' && c < '\177') || c == ' ')
984 event->key.string = g_memdup ("\0\0", 2);
985 event->key.length = 1;
988 else if (c >= '3' && c <= '7')
996 len = g_unichar_to_utf8 (c, buf);
999 event->key.string = g_locale_from_utf8 (buf, len,
1000 NULL, &bytes_written,
1002 if (event->key.string)
1003 event->key.length = bytes_written;
1005 else if (event->key.keyval == GDK_KEY_Escape)
1007 event->key.length = 1;
1008 event->key.string = g_strdup ("\033");
1010 else if (event->key.keyval == GDK_KEY_Return ||
1011 event->key.keyval == GDK_KEY_KP_Enter)
1013 event->key.length = 1;
1014 event->key.string = g_strdup ("\r");
1017 if (!event->key.string)
1019 event->key.length = 0;
1020 event->key.string = g_strdup ("");
1024 static GdkFilterReturn
1025 apply_event_filters (GdkWindow *window,
1029 GdkFilterReturn result = GDK_FILTER_CONTINUE;
1034 event = gdk_event_new (GDK_NOTHING);
1036 event->any.window = g_object_ref (window);
1037 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1039 /* I think GdkFilterFunc semantics require the passed-in event
1040 * to already be in the queue. The filter func can generate
1041 * more events and append them after it if it likes.
1043 node = _gdk_event_queue_append (_gdk_display, event);
1045 tmp_list = *filters;
1048 GdkEventFilter *filter = (GdkEventFilter *) tmp_list->data;
1051 if ((filter->flags & GDK_EVENT_FILTER_REMOVED) != 0)
1053 tmp_list = tmp_list->next;
1057 filter->ref_count++;
1058 result = filter->function (msg, event, filter->data);
1060 /* get the next node after running the function since the
1061 function may add or remove a next node */
1063 tmp_list = tmp_list->next;
1065 filter->ref_count--;
1066 if (filter->ref_count == 0)
1068 *filters = g_list_remove_link (*filters, node);
1069 g_list_free_1 (node);
1073 if (result != GDK_FILTER_CONTINUE)
1077 if (result == GDK_FILTER_CONTINUE || result == GDK_FILTER_REMOVE)
1079 _gdk_event_queue_remove_link (_gdk_display, node);
1080 g_list_free_1 (node);
1081 gdk_event_free (event);
1083 else /* GDK_FILTER_TRANSLATE */
1085 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1086 fixup_event (event);
1087 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
1093 * On Windows, transient windows will not have their own taskbar entries.
1094 * Because of this, we must hide and restore groups of transients in both
1095 * directions. That is, all transient children must be hidden or restored
1096 * with this window, but if this window's transient owner also has a
1097 * transient owner then this window's transient owner must be hidden/restored
1098 * with this one. And etc, up the chain until we hit an ancestor that has no
1101 * It would be a good idea if applications don't chain transient windows
1102 * together. There's a limit to how much evil GTK can try to shield you
1106 show_window_recurse (GdkWindow *window, gboolean hide_window)
1108 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1109 GSList *children = impl->transient_children;
1110 GdkWindow *child = NULL;
1112 if (!impl->changing_state)
1114 impl->changing_state = TRUE;
1116 if (children != NULL)
1118 while (children != NULL)
1120 child = children->data;
1121 show_window_recurse (child, hide_window);
1123 children = g_slist_next (children);
1127 if (GDK_WINDOW_IS_MAPPED (window))
1131 if (GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_ICONIFIED)
1133 if (GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_MAXIMIZED)
1135 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
1139 ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
1145 ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
1149 impl->changing_state = FALSE;
1154 do_show_window (GdkWindow *window, gboolean hide_window)
1156 GdkWindow *tmp_window = NULL;
1157 GdkWindowImplWin32 *tmp_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1159 if (!tmp_impl->changing_state)
1161 /* Find the top-level window in our transient chain. */
1162 while (tmp_impl->transient_owner != NULL)
1164 tmp_window = tmp_impl->transient_owner;
1165 tmp_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (tmp_window)->impl);
1168 /* If we couldn't find one, use the window provided. */
1169 if (tmp_window == NULL)
1171 tmp_window = window;
1174 /* Recursively show/hide every window in the chain. */
1175 if (tmp_window != window)
1177 show_window_recurse (tmp_window, hide_window);
1183 synthesize_enter_or_leave_event (GdkWindow *window,
1186 GdkCrossingMode mode,
1187 GdkNotifyType detail)
1193 ScreenToClient (GDK_WINDOW_HWND (window), &pt);
1195 event = gdk_event_new (type);
1196 event->crossing.window = window;
1197 event->crossing.subwindow = NULL;
1198 event->crossing.time = _gdk_win32_get_next_tick (msg->time);
1199 event->crossing.x = pt.x;
1200 event->crossing.y = pt.y;
1201 event->crossing.x_root = msg->pt.x + _gdk_offset_x;
1202 event->crossing.y_root = msg->pt.y + _gdk_offset_y;
1203 event->crossing.mode = mode;
1204 event->crossing.detail = detail;
1205 event->crossing.focus = TRUE; /* FIXME: Set correctly */
1206 event->crossing.state = 0; /* FIXME: Set correctly */
1207 gdk_event_set_device (event, _gdk_display->core_pointer);
1209 append_event (event);
1211 if (type == GDK_ENTER_NOTIFY &&
1212 ((GdkWindowObject *) window)->extension_events != 0)
1213 _gdk_device_wintab_update_window_coords (window);
1216 /* The check_extended flag controls whether to check if the windows want
1217 * events from extended input devices and if the message should be skipped
1218 * because an extended input device is active
1221 propagate (GdkWindow **window,
1223 GdkWindow *grab_window,
1224 gboolean grab_owner_events,
1226 gboolean (*doesnt_want_it) (gint mask,
1228 gboolean check_extended)
1230 if (grab_window != NULL && !grab_owner_events)
1232 /* Event source is grabbed with owner_events FALSE */
1234 /* See if the event should be ignored because an extended input
1237 if (check_extended &&
1238 ((GdkWindowObject *) grab_window)->extension_events != 0 &&
1239 _gdk_input_ignore_core)
1241 GDK_NOTE (EVENTS, g_print (" (ignored for grabber)"));
1244 if ((*doesnt_want_it) (grab_mask, msg))
1246 GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)"));
1251 GDK_NOTE (EVENTS, g_print (" (to grabber)"));
1252 assign_object (window, grab_window);
1257 /* If we come here, we know that if grab_window != NULL then
1258 * grab_owner_events is TRUE
1262 if (check_extended &&
1263 ((GdkWindowObject *) *window)->extension_events != 0 &&
1264 _gdk_input_ignore_core)
1266 GDK_NOTE (EVENTS, g_print (" (ignored)"));
1269 if ((*doesnt_want_it) (((GdkWindowObject *) *window)->event_mask, msg))
1271 /* Owner doesn't want it, propagate to parent. */
1272 GdkWindow *parent = gdk_window_get_parent (*window);
1273 if (parent == _gdk_root || parent == NULL)
1275 /* No parent; check if grabbed */
1276 if (grab_window != NULL)
1278 /* Event source is grabbed with owner_events TRUE */
1280 if (check_extended &&
1281 ((GdkWindowObject *) grab_window)->extension_events != 0 &&
1282 _gdk_input_ignore_core)
1284 GDK_NOTE (EVENTS, g_print (" (ignored for grabber)"));
1287 if ((*doesnt_want_it) (grab_mask, msg))
1289 /* Grabber doesn't want it either */
1290 GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)"));
1296 GDK_NOTE (EVENTS, g_print (" (to grabber)"));
1297 assign_object (window, grab_window);
1303 GDK_NOTE (EVENTS, g_print (" (undelivered)"));
1309 assign_object (window, parent);
1310 /* The only branch where we actually continue the loop */
1319 doesnt_want_key (gint mask,
1322 return (((msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) &&
1323 !(mask & GDK_KEY_RELEASE_MASK)) ||
1324 ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN) &&
1325 !(mask & GDK_KEY_PRESS_MASK)));
1329 doesnt_want_char (gint mask,
1332 return !(mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK));
1336 handle_configure_event (MSG *msg,
1341 GdkWindowObject *window_object;
1343 GetClientRect (msg->hwnd, &client_rect);
1344 point.x = client_rect.left; /* always 0 */
1345 point.y = client_rect.top;
1347 /* top level windows need screen coords */
1348 if (gdk_window_get_parent (window) == _gdk_root)
1350 ClientToScreen (msg->hwnd, &point);
1351 point.x += _gdk_offset_x;
1352 point.y += _gdk_offset_y;
1355 window_object = GDK_WINDOW_OBJECT (window);
1357 window_object->width = client_rect.right - client_rect.left;
1358 window_object->height = client_rect.bottom - client_rect.top;
1360 window_object->x = point.x;
1361 window_object->y = point.y;
1363 _gdk_window_update_size (window);
1365 if (window_object->event_mask & GDK_STRUCTURE_MASK)
1367 GdkEvent *event = gdk_event_new (GDK_CONFIGURE);
1369 event->configure.window = window;
1371 event->configure.width = client_rect.right - client_rect.left;
1372 event->configure.height = client_rect.bottom - client_rect.top;
1374 event->configure.x = point.x;
1375 event->configure.y = point.y;
1377 append_event (event);
1382 _gdk_win32_hrgn_to_region (HRGN hrgn)
1386 cairo_region_t *result;
1390 if ((nbytes = GetRegionData (hrgn, 0, NULL)) == 0)
1392 WIN32_GDI_FAILED ("GetRegionData");
1396 rgndata = (RGNDATA *) g_malloc (nbytes);
1398 if (GetRegionData (hrgn, nbytes, rgndata) == 0)
1400 WIN32_GDI_FAILED ("GetRegionData");
1405 result = cairo_region_create ();
1406 rects = (RECT *) rgndata->Buffer;
1407 for (i = 0; i < rgndata->rdh.nCount; i++)
1411 r.x = rects[i].left;
1413 r.width = rects[i].right - r.x;
1414 r.height = rects[i].bottom - r.y;
1416 cairo_region_union_rectangle (result, &r);
1425 adjust_drag (LONG *drag,
1430 *drag = curr + ((*drag + inc/2 - curr) / inc) * inc;
1432 *drag = curr - ((curr - *drag + inc/2) / inc) * inc;
1436 handle_wm_paint (MSG *msg,
1438 gboolean return_exposes,
1441 HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
1443 PAINTSTRUCT paintstruct;
1444 cairo_region_t *update_region;
1446 if (GetUpdateRgn (msg->hwnd, hrgn, FALSE) == ERROR)
1448 WIN32_GDI_FAILED ("GetUpdateRgn");
1449 DeleteObject (hrgn);
1453 hdc = BeginPaint (msg->hwnd, &paintstruct);
1455 GDK_NOTE (EVENTS, g_print (" %s %s dc %p%s",
1456 _gdk_win32_rect_to_string (&paintstruct.rcPaint),
1457 (paintstruct.fErase ? "erase" : ""),
1459 (return_exposes ? " return_exposes" : "")));
1461 EndPaint (msg->hwnd, &paintstruct);
1463 if ((paintstruct.rcPaint.right == paintstruct.rcPaint.left) ||
1464 (paintstruct.rcPaint.bottom == paintstruct.rcPaint.top))
1466 GDK_NOTE (EVENTS, g_print (" (empty paintstruct, ignored)"));
1467 DeleteObject (hrgn);
1473 if (!GDK_WINDOW_DESTROYED (window))
1475 GList *list = _gdk_display->queued_events;
1477 *event = gdk_event_new (GDK_EXPOSE);
1478 (*event)->expose.window = window;
1479 (*event)->expose.area.x = paintstruct.rcPaint.left;
1480 (*event)->expose.area.y = paintstruct.rcPaint.top;
1481 (*event)->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left;
1482 (*event)->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top;
1483 (*event)->expose.region = _gdk_win32_hrgn_to_region (hrgn);
1484 (*event)->expose.count = 0;
1486 while (list != NULL)
1488 GdkEventPrivate *evp = list->data;
1490 if (evp->event.any.type == GDK_EXPOSE &&
1491 evp->event.any.window == window &&
1492 !(evp->flags & GDK_EVENT_PENDING))
1493 evp->event.expose.count++;
1499 DeleteObject (hrgn);
1503 update_region = _gdk_win32_hrgn_to_region (hrgn);
1504 if (!cairo_region_is_empty (update_region))
1505 _gdk_window_invalidate_for_expose (window, update_region);
1506 cairo_region_destroy (update_region);
1508 DeleteObject (hrgn);
1511 static VOID CALLBACK
1512 modal_timer_proc (HWND hwnd,
1517 int arbitrary_limit = 1;
1519 while (_modal_operation_in_progress &&
1520 g_main_context_pending (NULL) &&
1522 g_main_context_iteration (NULL, FALSE);
1526 _gdk_win32_begin_modal_call (void)
1528 g_assert (!_modal_operation_in_progress);
1530 _modal_operation_in_progress = TRUE;
1532 modal_timer = SetTimer (NULL, 0, 10, modal_timer_proc);
1533 if (modal_timer == 0)
1534 WIN32_API_FAILED ("SetTimer");
1538 _gdk_win32_end_modal_call (void)
1540 g_assert (_modal_operation_in_progress);
1542 _modal_operation_in_progress = FALSE;
1544 if (modal_timer != 0)
1546 API_CALL (KillTimer, (NULL, modal_timer));
1551 static VOID CALLBACK
1552 sync_timer_proc (HWND hwnd,
1558 if (PeekMessageW (&message, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE))
1563 RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
1565 KillTimer (hwnd, sync_timer);
1569 handle_display_change (void)
1571 _gdk_monitor_init ();
1572 _gdk_root_window_size_init ();
1573 g_signal_emit_by_name (_gdk_screen, "size_changed");
1577 generate_button_event (GdkEventType type,
1582 GdkEvent *event = gdk_event_new (type);
1584 event->button.window = window;
1585 event->button.time = _gdk_win32_get_next_tick (msg->time);
1586 event->button.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
1587 event->button.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
1588 event->button.x_root = msg->pt.x + _gdk_offset_x;
1589 event->button.y_root = msg->pt.y + _gdk_offset_y;
1590 event->button.axes = NULL;
1591 event->button.state = build_pointer_event_state (msg);
1592 event->button.button = button;
1593 gdk_event_set_device (event, _gdk_display->core_pointer);
1595 append_event (event);
1599 ensure_stacking_on_unminimize (MSG *msg)
1602 HWND lowest_transient = NULL;
1605 while ((rover = GetNextWindow (rover, GW_HWNDNEXT)))
1607 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1609 /* Checking window group not implemented yet */
1612 GdkWindowImplWin32 *rover_impl =
1613 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1615 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1616 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1617 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1618 rover_impl->transient_owner != NULL))
1620 lowest_transient = rover;
1624 if (lowest_transient != NULL)
1626 GDK_NOTE (EVENTS, g_print (" restacking: %p", lowest_transient));
1627 SetWindowPos (msg->hwnd, lowest_transient, 0, 0, 0, 0,
1628 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1633 ensure_stacking_on_window_pos_changing (MSG *msg,
1636 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)((GdkWindowObject *) window)->impl;
1637 WINDOWPOS *windowpos = (WINDOWPOS *) msg->lParam;
1639 if (GetActiveWindow () == msg->hwnd &&
1640 impl->type_hint != GDK_WINDOW_TYPE_HINT_UTILITY &&
1641 impl->type_hint != GDK_WINDOW_TYPE_HINT_DIALOG &&
1642 impl->transient_owner == NULL)
1644 /* Make sure the window stays behind any transient-type windows
1645 * of the same window group.
1647 * If the window is not active and being activated, we let
1648 * Windows bring it to the top and rely on the WM_ACTIVATEAPP
1649 * handling to bring any utility windows on top of it.
1652 gboolean restacking;
1654 rover = windowpos->hwndInsertAfter;
1658 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1660 /* Checking window group not implemented yet */
1663 GdkWindowImplWin32 *rover_impl =
1664 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1666 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1667 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1668 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1669 rover_impl->transient_owner != NULL))
1672 windowpos->hwndInsertAfter = rover;
1675 rover = GetNextWindow (rover, GW_HWNDNEXT);
1680 GDK_NOTE (EVENTS, g_print (" restacking: %p", windowpos->hwndInsertAfter));
1688 ensure_stacking_on_activate_app (MSG *msg,
1691 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)((GdkWindowObject *) window)->impl;
1693 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1694 impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1695 impl->transient_owner != NULL)
1697 SetWindowPos (msg->hwnd, HWND_TOP, 0, 0, 0, 0,
1698 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1702 if (IsWindowVisible (msg->hwnd) &&
1703 msg->hwnd == GetActiveWindow ())
1705 /* This window is not a transient-type window and it is the
1706 * activated window. Make sure this window is as visible as
1707 * possible, just below the lowest transient-type window of this
1713 while ((rover = GetNextWindow (rover, GW_HWNDPREV)))
1715 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1717 /* Checking window group not implemented yet */
1720 GdkWindowImplWin32 *rover_impl =
1721 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1723 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1724 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1725 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1726 rover_impl->transient_owner != NULL))
1728 GDK_NOTE (EVENTS, g_print (" restacking: %p", rover));
1729 SetWindowPos (msg->hwnd, rover, 0, 0, 0, 0,
1730 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1739 gdk_event_translate (MSG *msg,
1742 RECT rect, *drag, orig_drag;
1747 BYTE key_state[256];
1749 WINDOWPOS *windowpos;
1756 GdkWindow *window = NULL;
1757 GdkWindowImplWin32 *impl;
1759 GdkWindow *orig_window, *new_window, *toplevel;
1761 GdkDeviceManager *device_manager;
1763 GdkDeviceGrabInfo *keyboard_grab = NULL;
1764 GdkDeviceGrabInfo *pointer_grab = NULL;
1765 GdkWindow *grab_window = NULL;
1771 gboolean return_val = FALSE;
1775 if (_gdk_default_filters)
1777 /* Apply global filters */
1779 GdkFilterReturn result = apply_event_filters (NULL, msg, &_gdk_default_filters);
1781 /* If result is GDK_FILTER_CONTINUE, we continue as if nothing
1782 * happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
1783 * we return TRUE, and DefWindowProcW() will not be called.
1785 if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
1789 window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd);
1790 orig_window = window;
1794 /* XXX Handle WM_QUIT here ? */
1795 if (msg->message == WM_QUIT)
1797 GDK_NOTE (EVENTS, g_print (" %d", (int) msg->wParam));
1800 else if (msg->message == WM_MOVE ||
1801 msg->message == WM_SIZE)
1803 /* It's quite normal to get these messages before we have
1804 * had time to register the window in our lookup table, or
1805 * when the window is being destroyed and we already have
1806 * removed it. Repost the same message to our queue so that
1807 * we will get it later when we are prepared.
1809 GDK_NOTE (EVENTS, g_print (" (posted)"));
1811 PostMessageW (msg->hwnd, msg->message, msg->wParam, msg->lParam);
1813 else if (msg->message == WM_CREATE)
1815 window = (UNALIGNED GdkWindow*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams);
1816 GDK_WINDOW_HWND (window) = msg->hwnd;
1820 GDK_NOTE (EVENTS, g_print (" (no GdkWindow)"));
1825 device_manager = gdk_display_get_device_manager (_gdk_display);
1827 keyboard_grab = _gdk_display_get_last_device_grab (_gdk_display,
1828 GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
1829 pointer_grab = _gdk_display_get_last_device_grab (_gdk_display,
1830 GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_pointer);
1832 g_object_ref (window);
1834 /* window's refcount has now been increased, so code below should
1835 * not just return from this function, but instead goto done (or
1836 * break out of the big switch). To protect against forgetting this,
1837 * #define return to a syntax error...
1839 #define return GOTO_DONE_INSTEAD
1841 if (!GDK_WINDOW_DESTROYED (window) && ((GdkWindowObject *) window)->filters)
1843 /* Apply per-window filters */
1845 GdkFilterReturn result = apply_event_filters (window, msg, &((GdkWindowObject *) window)->filters);
1847 if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
1854 if (msg->message == client_message)
1857 GdkFilterReturn result = GDK_FILTER_CONTINUE;
1860 GDK_NOTE (EVENTS, g_print (" client_message"));
1862 event = gdk_event_new (GDK_NOTHING);
1863 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1865 node = _gdk_event_queue_append (_gdk_display, event);
1867 tmp_list = client_filters;
1870 GdkClientFilter *filter = tmp_list->data;
1872 tmp_list = tmp_list->next;
1874 if (filter->type == GDK_POINTER_TO_ATOM (msg->wParam))
1876 GDK_NOTE (EVENTS, g_print (" (match)"));
1878 result = (*filter->function) (msg, event, filter->data);
1880 if (result != GDK_FILTER_CONTINUE)
1887 case GDK_FILTER_REMOVE:
1888 _gdk_event_queue_remove_link (_gdk_display, node);
1889 g_list_free_1 (node);
1890 gdk_event_free (event);
1894 case GDK_FILTER_TRANSLATE:
1895 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1896 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
1900 case GDK_FILTER_CONTINUE:
1901 /* Send unknown client messages on to Gtk for it to use */
1903 event->client.type = GDK_CLIENT_EVENT;
1904 event->client.window = window;
1905 event->client.message_type = GDK_POINTER_TO_ATOM (msg->wParam);
1906 event->client.data_format = 32;
1907 event->client.data.l[0] = msg->lParam;
1908 for (i = 1; i < 5; i++)
1909 event->client.data.l[i] = 0;
1910 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
1916 switch (msg->message)
1918 case WM_INPUTLANGCHANGE:
1919 _gdk_input_locale = (HKL) msg->lParam;
1920 _gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale);
1921 GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
1922 LOCALE_IDEFAULTANSICODEPAGE,
1924 _gdk_input_codepage = atoi (buf);
1925 _gdk_keymap_serial++;
1927 g_print (" cs:%lu hkl:%p%s cp:%d",
1928 (gulong) msg->wParam,
1929 (gpointer) msg->lParam, _gdk_input_locale_is_ime ? " (IME)" : "",
1930 _gdk_input_codepage));
1936 g_print (" %s ch:%.02x %s",
1937 _gdk_win32_key_to_string (msg->lParam),
1939 decode_key_lparam (msg->lParam)));
1941 /* If posted without us having keyboard focus, ignore */
1942 if ((msg->wParam != VK_F10 && msg->wParam != VK_MENU) &&
1943 !(HIWORD (msg->lParam) & KF_ALTDOWN))
1946 /* Let the system handle Alt-Tab, Alt-Space and Alt-F4 unless
1947 * the keyboard is grabbed.
1949 if (!keyboard_grab &&
1950 (msg->wParam == VK_TAB ||
1951 msg->wParam == VK_SPACE ||
1952 msg->wParam == VK_F4))
1955 /* Jump to code in common with WM_KEYUP and WM_KEYDOWN */
1961 g_print (" %s ch:%.02x %s",
1962 _gdk_win32_key_to_string (msg->lParam),
1964 decode_key_lparam (msg->lParam)));
1968 /* Ignore key messages intended for the IME */
1969 if (msg->wParam == VK_PROCESSKEY ||
1973 if (keyboard_grab &&
1974 !propagate (&window, msg,
1975 keyboard_grab->window,
1976 keyboard_grab->owner_events,
1977 GDK_ALL_EVENTS_MASK,
1978 doesnt_want_key, FALSE))
1981 if (GDK_WINDOW_DESTROYED (window))
1984 event = gdk_event_new ((msg->message == WM_KEYDOWN ||
1985 msg->message == WM_SYSKEYDOWN) ?
1986 GDK_KEY_PRESS : GDK_KEY_RELEASE);
1987 event->key.window = window;
1988 event->key.time = _gdk_win32_get_next_tick (msg->time);
1989 event->key.keyval = GDK_KEY_VoidSymbol;
1990 event->key.string = NULL;
1991 event->key.length = 0;
1992 event->key.hardware_keycode = msg->wParam;
1993 gdk_event_set_device (event, GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
1994 if (HIWORD (msg->lParam) & KF_EXTENDED)
1996 switch (msg->wParam)
1999 event->key.hardware_keycode = VK_RCONTROL;
2001 case VK_SHIFT: /* Actually, KF_EXTENDED is not set
2002 * for the right shift key.
2004 event->key.hardware_keycode = VK_RSHIFT;
2007 event->key.hardware_keycode = VK_RMENU;
2011 else if (msg->wParam == VK_SHIFT &&
2012 LOBYTE (HIWORD (msg->lParam)) == _scancode_rshift)
2013 event->key.hardware_keycode = VK_RSHIFT;
2015 API_CALL (GetKeyboardState, (key_state));
2017 /* 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]); */
2019 build_key_event_state (event, key_state);
2021 gdk_keymap_translate_keyboard_state (NULL,
2022 event->key.hardware_keycode,
2028 fill_key_event_string (event);
2030 /* Reset MOD1_MASK if it is the Alt key itself */
2031 if (msg->wParam == VK_MENU)
2032 event->key.state &= ~GDK_MOD1_MASK;
2034 append_event (event);
2040 if (msg->wParam != VK_SPACE)
2042 /* To prevent beeps, don't let DefWindowProcW() be called */
2048 case WM_IME_STARTCOMPOSITION:
2049 in_ime_composition = TRUE;
2052 case WM_IME_ENDCOMPOSITION:
2053 in_ime_composition = FALSE;
2056 case WM_IME_COMPOSITION:
2057 /* On Win2k WM_IME_CHAR doesn't work correctly for non-Unicode
2058 * applications. Thus, handle WM_IME_COMPOSITION with
2059 * GCS_RESULTSTR instead, fetch the Unicode chars from the IME
2060 * with ImmGetCompositionStringW().
2063 * http://groups.google.com/groups?selm=natX5.57%24g77.19788%40nntp2.onemain.com
2065 * http://groups.google.com/groups?selm=u2XfrXw5BHA.1628%40tkmsftngp02
2066 * for comments by other people that seems to have the same
2067 * experience. WM_IME_CHAR just gives question marks, apparently
2068 * because of going through some conversion to the current code
2071 * WM_IME_CHAR might work on NT4 or Win9x with ActiveIMM, but
2072 * use WM_IME_COMPOSITION there, too, to simplify the code.
2074 GDK_NOTE (EVENTS, g_print (" %#lx", (long) msg->lParam));
2076 if (!(msg->lParam & GCS_RESULTSTR))
2079 if (keyboard_grab &&
2080 !propagate (&window, msg,
2081 keyboard_grab->window,
2082 keyboard_grab->owner_events,
2083 GDK_ALL_EVENTS_MASK,
2084 doesnt_want_char, FALSE))
2087 if (GDK_WINDOW_DESTROYED (window))
2090 himc = ImmGetContext (msg->hwnd);
2091 ccount = ImmGetCompositionStringW (himc, GCS_RESULTSTR,
2092 wbuf, sizeof (wbuf));
2093 ImmReleaseContext (msg->hwnd, himc);
2097 API_CALL (GetKeyboardState, (key_state));
2099 for (i = 0; i < ccount; i++)
2101 if (((GdkWindowObject *) window)->event_mask & GDK_KEY_PRESS_MASK)
2103 /* Build a key press event */
2104 event = gdk_event_new (GDK_KEY_PRESS);
2105 event->key.window = window;
2106 gdk_event_set_device (event, GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
2107 build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
2109 append_event (event);
2112 if (((GdkWindowObject *) window)->event_mask & GDK_KEY_RELEASE_MASK)
2114 /* Build a key release event. */
2115 event = gdk_event_new (GDK_KEY_RELEASE);
2116 event->key.window = window;
2117 gdk_event_set_device (event, GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
2118 build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
2120 append_event (event);
2126 case WM_LBUTTONDOWN:
2130 case WM_MBUTTONDOWN:
2134 case WM_RBUTTONDOWN:
2138 case WM_XBUTTONDOWN:
2139 if (HIWORD (msg->wParam) == XBUTTON1)
2146 g_print (" (%d,%d)",
2147 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2149 assign_object (&window, find_window_for_mouse_event (window, msg));
2150 /* TODO_CSW?: there used to some synthesize and propagate */
2151 if (GDK_WINDOW_DESTROYED (window))
2154 /* TODO_CSW? Emulate X11's automatic active grab */
2155 generate_button_event (GDK_BUTTON_PRESS, button,
2174 if (HIWORD (msg->wParam) == XBUTTON1)
2181 g_print (" (%d,%d)",
2182 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2184 assign_object (&window, find_window_for_mouse_event (window, msg));
2186 if (((GdkWindowObject *) window)->extension_events != 0 &&
2187 _gdk_input_ignore_core)
2189 GDK_NOTE (EVENTS, g_print (" (ignored)"));
2194 generate_button_event (GDK_BUTTON_RELEASE, button,
2202 g_print (" %p (%d,%d)",
2203 (gpointer) msg->wParam,
2204 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2206 assign_object (&window, find_window_for_mouse_event (window, msg));
2207 toplevel = gdk_window_get_toplevel (window);
2208 if (current_toplevel != toplevel)
2210 GDK_NOTE (EVENTS, g_print (" toplevel %p -> %p",
2211 current_toplevel ? GDK_WINDOW_HWND (current_toplevel) : NULL,
2212 toplevel ? GDK_WINDOW_HWND (toplevel) : NULL));
2213 if (current_toplevel)
2214 synthesize_enter_or_leave_event (current_toplevel, msg,
2215 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2216 synthesize_enter_or_leave_event (toplevel, msg,
2217 GDK_ENTER_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2218 assign_object (¤t_toplevel, toplevel);
2219 track_mouse_event (TME_LEAVE, GDK_WINDOW_HWND (toplevel));
2222 /* If we haven't moved, don't create any GDK event. Windows
2223 * sends WM_MOUSEMOVE messages after a new window is shows under
2224 * the mouse, even if the mouse hasn't moved. This disturbs gtk.
2226 if (msg->pt.x + _gdk_offset_x == current_root_x &&
2227 msg->pt.y + _gdk_offset_y == current_root_y)
2230 current_root_x = msg->pt.x + _gdk_offset_x;
2231 current_root_y = msg->pt.y + _gdk_offset_y;
2233 event = gdk_event_new (GDK_MOTION_NOTIFY);
2234 event->motion.window = window;
2235 event->motion.time = _gdk_win32_get_next_tick (msg->time);
2236 event->motion.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
2237 event->motion.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
2238 event->motion.x_root = current_root_x;
2239 event->motion.y_root = current_root_y;
2240 event->motion.axes = NULL;
2241 event->motion.state = build_pointer_event_state (msg);
2242 event->motion.is_hint = FALSE;
2243 gdk_event_set_device (event, _gdk_display->core_pointer);
2245 append_event (event);
2250 case WM_NCMOUSEMOVE:
2252 g_print (" (%d,%d)",
2253 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2254 #if 0 /* TODO_CSW? */
2255 if (current_toplevel != NULL &&
2256 (((GdkWindowObject *) current_toplevel)->event_mask & GDK_LEAVE_NOTIFY_MASK))
2258 synthesize_enter_or_leave_event (current_toplevel, msg,
2259 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2265 GDK_NOTE (EVENTS, g_print (" %d (%ld,%ld)",
2266 HIWORD (msg->wParam), msg->pt.x, msg->pt.y));
2268 if (!gdk_win32_handle_table_lookup ((GdkNativeWindow) WindowFromPoint (msg->pt)))
2270 /* we are only interested if we don't know the new window */
2271 if (current_toplevel)
2272 synthesize_enter_or_leave_event (current_toplevel, msg,
2273 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2274 assign_object (¤t_toplevel, NULL);
2278 GDK_NOTE (EVENTS, g_print (" (ignored)"));
2285 GDK_NOTE (EVENTS, g_print (" %d", (short) HIWORD (msg->wParam)));
2287 /* WM_MOUSEWHEEL is delivered to the focus window. Work around
2288 * that. Also, the position is in screen coordinates, not client
2289 * coordinates as with the button messages. I love the
2290 * consistency of Windows.
2292 point.x = GET_X_LPARAM (msg->lParam);
2293 point.y = GET_Y_LPARAM (msg->lParam);
2295 if ((hwnd = WindowFromPoint (point)) == NULL)
2299 if ((new_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd)) == NULL)
2302 if (new_window != window)
2304 assign_object (&window, new_window);
2307 ScreenToClient (msg->hwnd, &point);
2309 event = gdk_event_new (GDK_SCROLL);
2310 event->scroll.window = window;
2311 event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
2312 GDK_SCROLL_UP : GDK_SCROLL_DOWN;
2313 event->scroll.time = _gdk_win32_get_next_tick (msg->time);
2314 event->scroll.x = (gint16) point.x;
2315 event->scroll.y = (gint16) point.y;
2316 event->scroll.x_root = (gint16) GET_X_LPARAM (msg->lParam) + _gdk_offset_x;
2317 event->scroll.y_root = (gint16) GET_Y_LPARAM (msg->lParam) + _gdk_offset_y;
2318 event->scroll.state = build_pointer_event_state (msg);
2319 gdk_event_set_device (event, _gdk_display->core_pointer);
2321 append_event (event);
2327 /* Just print more debugging information, don't actually handle it. */
2330 (LOWORD (msg->wParam) == SB_ENDSCROLL ? "ENDSCROLL" :
2331 (LOWORD (msg->wParam) == SB_LEFT ? "LEFT" :
2332 (LOWORD (msg->wParam) == SB_RIGHT ? "RIGHT" :
2333 (LOWORD (msg->wParam) == SB_LINELEFT ? "LINELEFT" :
2334 (LOWORD (msg->wParam) == SB_LINERIGHT ? "LINERIGHT" :
2335 (LOWORD (msg->wParam) == SB_PAGELEFT ? "PAGELEFT" :
2336 (LOWORD (msg->wParam) == SB_PAGERIGHT ? "PAGERIGHT" :
2337 (LOWORD (msg->wParam) == SB_THUMBPOSITION ? "THUMBPOSITION" :
2338 (LOWORD (msg->wParam) == SB_THUMBTRACK ? "THUMBTRACK" :
2340 (LOWORD (msg->wParam) == SB_THUMBPOSITION ||
2341 LOWORD (msg->wParam) == SB_THUMBTRACK) ?
2342 (g_print (" %d", HIWORD (msg->wParam)), 0) : 0));
2346 /* Just print more debugging information, don't actually handle it. */
2349 (LOWORD (msg->wParam) == SB_ENDSCROLL ? "ENDSCROLL" :
2350 (LOWORD (msg->wParam) == SB_BOTTOM ? "BOTTOM" :
2351 (LOWORD (msg->wParam) == SB_TOP ? "TOP" :
2352 (LOWORD (msg->wParam) == SB_LINEDOWN ? "LINDOWN" :
2353 (LOWORD (msg->wParam) == SB_LINEUP ? "LINEUP" :
2354 (LOWORD (msg->wParam) == SB_PAGEDOWN ? "PAGEDOWN" :
2355 (LOWORD (msg->wParam) == SB_PAGEUP ? "PAGEUP" :
2356 (LOWORD (msg->wParam) == SB_THUMBPOSITION ? "THUMBPOSITION" :
2357 (LOWORD (msg->wParam) == SB_THUMBTRACK ? "THUMBTRACK" :
2359 (LOWORD (msg->wParam) == SB_THUMBPOSITION ||
2360 LOWORD (msg->wParam) == SB_THUMBTRACK) ?
2361 (g_print (" %d", HIWORD (msg->wParam)), 0) : 0));
2364 case WM_MOUSEACTIVATE:
2368 if (gdk_window_get_window_type (window) == GDK_WINDOW_TEMP
2369 || !((GdkWindowObject *)window)->accept_focus)
2371 *ret_valp = MA_NOACTIVATE;
2375 tmp = _gdk_modal_current ();
2379 if (gdk_window_get_toplevel (window) != tmp)
2381 *ret_valp = MA_NOACTIVATEANDEAT;
2390 if (keyboard_grab != NULL &&
2391 !GDK_WINDOW_DESTROYED (keyboard_grab->window))
2393 generate_grab_broken_event (device_manager, keyboard_grab->window, TRUE, NULL);
2398 if (keyboard_grab != NULL &&
2399 !keyboard_grab->owner_events)
2402 if (!(((GdkWindowObject *) window)->event_mask & GDK_FOCUS_CHANGE_MASK))
2405 if (GDK_WINDOW_DESTROYED (window))
2408 generate_focus_event (device_manager, window, (msg->message == WM_SETFOCUS));
2413 GDK_NOTE (EVENTS, g_print (" %p", (HANDLE) msg->wParam));
2415 if (GDK_WINDOW_DESTROYED (window))
2423 sync_timer = SetTimer (GDK_WINDOW_HWND (window),
2425 200, sync_timer_proc);
2429 handle_wm_paint (msg, window, FALSE, NULL);
2433 GDK_NOTE (EVENTS, g_print (" %#x %#x",
2434 LOWORD (msg->lParam), HIWORD (msg->lParam)));
2436 if (pointer_grab != NULL)
2437 grab_window = pointer_grab->window;
2439 if (grab_window == NULL && LOWORD (msg->lParam) != HTCLIENT)
2442 if (grab_window != NULL && p_grab_cursor != NULL)
2443 hcursor = p_grab_cursor;
2444 else if (!GDK_WINDOW_DESTROYED (window))
2445 hcursor = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->hcursor;
2449 if (hcursor != NULL)
2451 GDK_NOTE (EVENTS, g_print (" (SetCursor(%p)", hcursor));
2452 SetCursor (hcursor);
2459 GDK_NOTE (EVENTS, g_print (" %s %s",
2460 (msg->wParam ? "YES" : "NO"),
2461 (msg->lParam == 0 ? "ShowWindow" :
2462 (msg->lParam == SW_OTHERUNZOOM ? "OTHERUNZOOM" :
2463 (msg->lParam == SW_OTHERZOOM ? "OTHERZOOM" :
2464 (msg->lParam == SW_PARENTCLOSING ? "PARENTCLOSING" :
2465 (msg->lParam == SW_PARENTOPENING ? "PARENTOPENING" :
2468 if (!(((GdkWindowObject *) window)->event_mask & GDK_STRUCTURE_MASK))
2471 if (msg->lParam == SW_OTHERUNZOOM ||
2472 msg->lParam == SW_OTHERZOOM)
2475 if (GDK_WINDOW_DESTROYED (window))
2478 event = gdk_event_new (msg->wParam ? GDK_MAP : GDK_UNMAP);
2479 event->any.window = window;
2481 append_event (event);
2483 if (event->any.type == GDK_UNMAP)
2485 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
2487 if (impl->transient_owner && GetForegroundWindow () == GDK_WINDOW_HWND (window))
2489 SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner));
2492 if (pointer_grab != NULL)
2494 if (pointer_grab->window == window)
2495 gdk_pointer_ungrab (msg->time);
2498 if (keyboard_grab &&
2499 keyboard_grab->window == window)
2500 gdk_keyboard_ungrab (msg->time);
2507 switch (msg->wParam)
2511 do_show_window (window, msg->wParam == SC_MINIMIZE ? TRUE : FALSE);
2519 g_print (" %s %dx%d",
2520 (msg->wParam == SIZE_MAXHIDE ? "MAXHIDE" :
2521 (msg->wParam == SIZE_MAXIMIZED ? "MAXIMIZED" :
2522 (msg->wParam == SIZE_MAXSHOW ? "MAXSHOW" :
2523 (msg->wParam == SIZE_MINIMIZED ? "MINIMIZED" :
2524 (msg->wParam == SIZE_RESTORED ? "RESTORED" : "?"))))),
2525 LOWORD (msg->lParam), HIWORD (msg->lParam)));
2527 if (msg->wParam == SIZE_MINIMIZED)
2529 /* Don't generate any GDK event. This is *not* an UNMAP. */
2530 if (pointer_grab != NULL)
2532 if (pointer_grab->window == window)
2533 gdk_pointer_ungrab (msg->time);
2535 if (keyboard_grab &&
2536 keyboard_grab->window == window)
2537 gdk_keyboard_ungrab (msg->time);
2539 gdk_synthesize_window_state (window,
2540 GDK_WINDOW_STATE_WITHDRAWN,
2541 GDK_WINDOW_STATE_ICONIFIED);
2542 do_show_window (window, TRUE);
2544 else if ((msg->wParam == SIZE_RESTORED ||
2545 msg->wParam == SIZE_MAXIMIZED) &&
2546 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
2548 GdkWindowState withdrawn_bit =
2549 IsWindowVisible (msg->hwnd) ? GDK_WINDOW_STATE_WITHDRAWN : 0;
2551 if (((GdkWindowObject *) window)->state & GDK_WINDOW_STATE_ICONIFIED)
2552 ensure_stacking_on_unminimize (msg);
2554 if (!GDK_WINDOW_DESTROYED (window))
2555 handle_configure_event (msg, window);
2557 if (msg->wParam == SIZE_RESTORED)
2559 gdk_synthesize_window_state (window,
2560 GDK_WINDOW_STATE_ICONIFIED |
2561 GDK_WINDOW_STATE_MAXIMIZED |
2565 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_TEMP && !GDK_WINDOW_IS_MAPPED (window))
2567 do_show_window (window, FALSE);
2570 else if (msg->wParam == SIZE_MAXIMIZED)
2572 gdk_synthesize_window_state (window,
2573 GDK_WINDOW_STATE_ICONIFIED |
2575 GDK_WINDOW_STATE_MAXIMIZED);
2578 if (((GdkWindowObject *) window)->resize_count > 1)
2579 ((GdkWindowObject *) window)->resize_count -= 1;
2581 if (((GdkWindowObject *) window)->extension_events != 0)
2582 _gdk_device_wintab_update_window_coords (window);
2588 case WM_ENTERSIZEMOVE:
2589 case WM_ENTERMENULOOP:
2590 _gdk_win32_begin_modal_call ();
2593 case WM_EXITSIZEMOVE:
2594 case WM_EXITMENULOOP:
2595 _gdk_win32_end_modal_call ();
2598 case WM_WINDOWPOSCHANGING:
2599 GDK_NOTE (EVENTS, (windowpos = (WINDOWPOS *) msg->lParam,
2600 g_print (" %s %s %dx%d@%+d%+d now below %p",
2601 _gdk_win32_window_pos_bits_to_string (windowpos->flags),
2602 (windowpos->hwndInsertAfter == HWND_BOTTOM ? "BOTTOM" :
2603 (windowpos->hwndInsertAfter == HWND_NOTOPMOST ? "NOTOPMOST" :
2604 (windowpos->hwndInsertAfter == HWND_TOP ? "TOP" :
2605 (windowpos->hwndInsertAfter == HWND_TOPMOST ? "TOPMOST" :
2606 (sprintf (buf, "%p", windowpos->hwndInsertAfter),
2608 windowpos->cx, windowpos->cy, windowpos->x, windowpos->y,
2609 GetNextWindow (msg->hwnd, GW_HWNDPREV))));
2611 if (GDK_WINDOW_IS_MAPPED (window))
2612 return_val = ensure_stacking_on_window_pos_changing (msg, window);
2615 case WM_WINDOWPOSCHANGED:
2616 windowpos = (WINDOWPOS *) msg->lParam;
2617 GDK_NOTE (EVENTS, g_print (" %s %s %dx%d@%+d%+d",
2618 _gdk_win32_window_pos_bits_to_string (windowpos->flags),
2619 (windowpos->hwndInsertAfter == HWND_BOTTOM ? "BOTTOM" :
2620 (windowpos->hwndInsertAfter == HWND_NOTOPMOST ? "NOTOPMOST" :
2621 (windowpos->hwndInsertAfter == HWND_TOP ? "TOP" :
2622 (windowpos->hwndInsertAfter == HWND_TOPMOST ? "TOPMOST" :
2623 (sprintf (buf, "%p", windowpos->hwndInsertAfter),
2625 windowpos->cx, windowpos->cy, windowpos->x, windowpos->y));
2627 /* If position and size haven't changed, don't do anything */
2628 if (_modal_operation_in_progress &&
2629 (windowpos->flags & SWP_NOMOVE) &&
2630 (windowpos->flags & SWP_NOSIZE))
2633 /* Once we've entered the moving or sizing modal loop, we won't
2634 * return to the main loop until we're done sizing or moving.
2636 if (_modal_operation_in_progress &&
2637 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
2638 !GDK_WINDOW_DESTROYED (window))
2640 if (((GdkWindowObject *) window)->event_mask & GDK_STRUCTURE_MASK)
2642 GDK_NOTE (EVENTS, g_print (" do magic"));
2643 if (((GdkWindowObject *) window)->resize_count > 1)
2644 ((GdkWindowObject *) window)->resize_count -= 1;
2646 handle_configure_event (msg, window);
2647 g_main_context_iteration (NULL, FALSE);
2649 /* Dispatch main loop - to realize resizes... */
2650 modal_timer_proc (msg->hwnd, msg->message, 0, msg->time);
2652 /* Claim as handled, so that WM_SIZE and WM_MOVE are avoided */
2660 GetWindowRect (GDK_WINDOW_HWND (window), &rect);
2661 drag = (RECT *) msg->lParam;
2662 GDK_NOTE (EVENTS, g_print (" %s curr:%s drag:%s",
2663 (msg->wParam == WMSZ_BOTTOM ? "BOTTOM" :
2664 (msg->wParam == WMSZ_BOTTOMLEFT ? "BOTTOMLEFT" :
2665 (msg->wParam == WMSZ_LEFT ? "LEFT" :
2666 (msg->wParam == WMSZ_TOPLEFT ? "TOPLEFT" :
2667 (msg->wParam == WMSZ_TOP ? "TOP" :
2668 (msg->wParam == WMSZ_TOPRIGHT ? "TOPRIGHT" :
2669 (msg->wParam == WMSZ_RIGHT ? "RIGHT" :
2671 (msg->wParam == WMSZ_BOTTOMRIGHT ? "BOTTOMRIGHT" :
2673 _gdk_win32_rect_to_string (&rect),
2674 _gdk_win32_rect_to_string (drag)));
2676 impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
2678 if (impl->hint_flags & GDK_HINT_RESIZE_INC)
2680 GDK_NOTE (EVENTS, g_print (" (RESIZE_INC)"));
2681 if (impl->hint_flags & GDK_HINT_BASE_SIZE)
2683 /* Resize in increments relative to the base size */
2684 rect.left = rect.top = 0;
2685 rect.right = impl->hints.base_width;
2686 rect.bottom = impl->hints.base_height;
2687 _gdk_win32_adjust_client_rect (window, &rect);
2688 point.x = rect.left;
2690 ClientToScreen (GDK_WINDOW_HWND (window), &point);
2691 rect.left = point.x;
2693 point.x = rect.right;
2694 point.y = rect.bottom;
2695 ClientToScreen (GDK_WINDOW_HWND (window), &point);
2696 rect.right = point.x;
2697 rect.bottom = point.y;
2699 GDK_NOTE (EVENTS, g_print (" (also BASE_SIZE, using %s)",
2700 _gdk_win32_rect_to_string (&rect)));
2703 switch (msg->wParam)
2706 if (drag->bottom == rect.bottom)
2708 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2711 case WMSZ_BOTTOMLEFT:
2712 if (drag->bottom == rect.bottom && drag->left == rect.left)
2714 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2715 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2719 if (drag->left == rect.left)
2721 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2725 if (drag->top == rect.top && drag->left == rect.left)
2727 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2728 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2732 if (drag->top == rect.top)
2734 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2738 if (drag->top == rect.top && drag->right == rect.right)
2740 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2741 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2745 if (drag->right == rect.right)
2747 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2750 case WMSZ_BOTTOMRIGHT:
2751 if (drag->bottom == rect.bottom && drag->right == rect.right)
2753 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2754 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2758 if (drag->bottom != orig_drag.bottom || drag->left != orig_drag.left ||
2759 drag->top != orig_drag.top || drag->right != orig_drag.right)
2763 GDK_NOTE (EVENTS, g_print (" (handled RESIZE_INC: %s)",
2764 _gdk_win32_rect_to_string (drag)));
2768 /* WM_GETMINMAXINFO handles min_size and max_size hints? */
2770 if (impl->hint_flags & GDK_HINT_ASPECT)
2772 RECT decorated_rect;
2773 RECT undecorated_drag;
2774 int decoration_width, decoration_height;
2775 gdouble drag_aspect;
2776 int drag_width, drag_height, new_width, new_height;
2778 GetClientRect (GDK_WINDOW_HWND (window), &rect);
2779 decorated_rect = rect;
2780 _gdk_win32_adjust_client_rect (window, &decorated_rect);
2782 /* Set undecorated_drag to the client area being dragged
2783 * out, in screen coordinates.
2785 undecorated_drag = *drag;
2786 undecorated_drag.left -= decorated_rect.left - rect.left;
2787 undecorated_drag.right -= decorated_rect.right - rect.right;
2788 undecorated_drag.top -= decorated_rect.top - rect.top;
2789 undecorated_drag.bottom -= decorated_rect.bottom - rect.bottom;
2791 decoration_width = (decorated_rect.right - decorated_rect.left) - (rect.right - rect.left);
2792 decoration_height = (decorated_rect.bottom - decorated_rect.top) - (rect.bottom - rect.top);
2794 drag_width = undecorated_drag.right - undecorated_drag.left;
2795 drag_height = undecorated_drag.bottom - undecorated_drag.top;
2797 drag_aspect = (gdouble) drag_width / drag_height;
2799 GDK_NOTE (EVENTS, g_print (" (ASPECT:%g--%g curr: %g)",
2800 impl->hints.min_aspect, impl->hints.max_aspect, drag_aspect));
2802 if (drag_aspect < impl->hints.min_aspect)
2804 /* Aspect is getting too narrow */
2805 switch (msg->wParam)
2809 /* User drags top or bottom edge outward. Keep height, increase width. */
2810 new_width = impl->hints.min_aspect * drag_height;
2811 drag->left -= (new_width - drag_width) / 2;
2812 drag->right = drag->left + new_width + decoration_width;
2814 case WMSZ_BOTTOMLEFT:
2815 case WMSZ_BOTTOMRIGHT:
2816 /* User drags bottom-left or bottom-right corner down. Adjust height. */
2817 new_height = drag_width / impl->hints.min_aspect;
2818 drag->bottom = drag->top + new_height + decoration_height;
2822 /* User drags left or right edge inward. Decrease height */
2823 new_height = drag_width / impl->hints.min_aspect;
2824 drag->top += (drag_height - new_height) / 2;
2825 drag->bottom = drag->top + new_height + decoration_height;
2829 /* User drags top-left or top-right corner up. Adjust height. */
2830 new_height = drag_width / impl->hints.min_aspect;
2831 drag->top = drag->bottom - new_height - decoration_height;
2834 else if (drag_aspect > impl->hints.max_aspect)
2836 /* Aspect is getting too wide */
2837 switch (msg->wParam)
2841 /* User drags top or bottom edge inward. Decrease width. */
2842 new_width = impl->hints.max_aspect * drag_height;
2843 drag->left += (drag_width - new_width) / 2;
2844 drag->right = drag->left + new_width + decoration_width;
2846 case WMSZ_BOTTOMLEFT:
2848 /* User drags bottom-left or top-left corner left. Adjust width. */
2849 new_width = impl->hints.max_aspect * drag_height;
2850 drag->left = drag->right - new_width - decoration_width;
2852 case WMSZ_BOTTOMRIGHT:
2854 /* User drags bottom-right or top-right corner right. Adjust width. */
2855 new_width = impl->hints.max_aspect * drag_height;
2856 drag->right = drag->left + new_width + decoration_width;
2860 /* User drags left or right edge outward. Increase height. */
2861 new_height = drag_width / impl->hints.max_aspect;
2862 drag->top -= (new_height - drag_height) / 2;
2863 drag->bottom = drag->top + new_height + decoration_height;
2870 GDK_NOTE (EVENTS, g_print (" (handled ASPECT: %s)",
2871 _gdk_win32_rect_to_string (drag)));
2875 case WM_GETMINMAXINFO:
2876 if (GDK_WINDOW_DESTROYED (window))
2879 impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
2880 mmi = (MINMAXINFO*) msg->lParam;
2881 GDK_NOTE (EVENTS, g_print (" (mintrack:%ldx%ld maxtrack:%ldx%ld "
2882 "maxpos:%+ld%+ld maxsize:%ldx%ld)",
2883 mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y,
2884 mmi->ptMaxTrackSize.x, mmi->ptMaxTrackSize.y,
2885 mmi->ptMaxPosition.x, mmi->ptMaxPosition.y,
2886 mmi->ptMaxSize.x, mmi->ptMaxSize.y));
2888 if (impl->hint_flags & GDK_HINT_MIN_SIZE)
2890 rect.left = rect.top = 0;
2891 rect.right = impl->hints.min_width;
2892 rect.bottom = impl->hints.min_height;
2894 _gdk_win32_adjust_client_rect (window, &rect);
2896 mmi->ptMinTrackSize.x = rect.right - rect.left;
2897 mmi->ptMinTrackSize.y = rect.bottom - rect.top;
2900 if (impl->hint_flags & GDK_HINT_MAX_SIZE)
2904 rect.left = rect.top = 0;
2905 rect.right = impl->hints.max_width;
2906 rect.bottom = impl->hints.max_height;
2908 _gdk_win32_adjust_client_rect (window, &rect);
2910 /* at least on win9x we have the 16 bit trouble */
2911 maxw = rect.right - rect.left;
2912 maxh = rect.bottom - rect.top;
2913 mmi->ptMaxTrackSize.x = maxw > 0 && maxw < G_MAXSHORT ? maxw : G_MAXSHORT;
2914 mmi->ptMaxTrackSize.y = maxh > 0 && maxh < G_MAXSHORT ? maxh : G_MAXSHORT;
2917 if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE))
2919 /* Don't call DefWindowProcW() */
2920 GDK_NOTE (EVENTS, g_print (" (handled, mintrack:%ldx%ld maxtrack:%ldx%ld "
2921 "maxpos:%+ld%+ld maxsize:%ldx%ld)",
2922 mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y,
2923 mmi->ptMaxTrackSize.x, mmi->ptMaxTrackSize.y,
2924 mmi->ptMaxPosition.x, mmi->ptMaxPosition.y,
2925 mmi->ptMaxSize.x, mmi->ptMaxSize.y));
2931 GDK_NOTE (EVENTS, g_print (" (%d,%d)",
2932 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2934 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
2935 !IsIconic (msg->hwnd))
2937 if (!GDK_WINDOW_DESTROYED (window))
2938 handle_configure_event (msg, window);
2945 if (GDK_WINDOW_DESTROYED (window))
2948 event = gdk_event_new (GDK_DELETE);
2949 event->any.window = window;
2951 append_event (event);
2953 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
2955 if (impl->transient_owner && GetForegroundWindow() == GDK_WINDOW_HWND (window))
2957 SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner));
2964 if (pointer_grab != NULL)
2966 if (pointer_grab->window == window)
2967 gdk_pointer_ungrab (msg->time);
2970 if (keyboard_grab &&
2971 keyboard_grab->window == window)
2972 gdk_keyboard_ungrab (msg->time);
2974 if ((window != NULL) && (msg->hwnd != GetDesktopWindow ()))
2975 gdk_window_destroy_notify (window);
2977 if (window == NULL || GDK_WINDOW_DESTROYED (window))
2980 event = gdk_event_new (GDK_DESTROY);
2981 event->any.window = window;
2983 append_event (event);
2988 case WM_DISPLAYCHANGE:
2989 handle_display_change ();
2992 case WM_DESTROYCLIPBOARD:
2993 if (!_ignore_destroy_clipboard)
2995 event = gdk_event_new (GDK_SELECTION_CLEAR);
2996 event->selection.window = window;
2997 event->selection.selection = GDK_SELECTION_CLIPBOARD;
2998 event->selection.time = _gdk_win32_get_next_tick (msg->time);
2999 append_event (event);
3008 case WM_RENDERFORMAT:
3009 GDK_NOTE (EVENTS, g_print (" %s", _gdk_win32_cf_to_string (msg->wParam)));
3011 if (!(target = g_hash_table_lookup (_format_atom_table, GINT_TO_POINTER (msg->wParam))))
3013 GDK_NOTE (EVENTS, g_print (" (target not found)"));
3018 /* We need to render to clipboard immediately, don't call
3021 event = gdk_event_new (GDK_SELECTION_REQUEST);
3022 event->selection.window = window;
3023 event->selection.send_event = FALSE;
3024 event->selection.selection = GDK_SELECTION_CLIPBOARD;
3025 event->selection.target = target;
3026 event->selection.property = _gdk_selection;
3027 event->selection.requestor = msg->hwnd;
3028 event->selection.time = msg->time;
3030 fixup_event (event);
3031 GDK_NOTE (EVENTS, g_print (" (calling _gdk_event_emit)"));
3032 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
3033 _gdk_event_emit (event);
3034 gdk_event_free (event);
3036 /* Now the clipboard owner should have rendered */
3037 if (!_delayed_rendering_data)
3039 GDK_NOTE (EVENTS, g_print (" (no _delayed_rendering_data?)"));
3043 if (msg->wParam == CF_DIB)
3045 _delayed_rendering_data =
3046 _gdk_win32_selection_convert_to_dib (_delayed_rendering_data,
3048 if (!_delayed_rendering_data)
3050 g_warning ("Cannot convert to DIB from delayed rendered image");
3055 /* The requestor is holding the clipboard, no
3056 * OpenClipboard() is required/possible
3059 g_print (" SetClipboardData(%s,%p)",
3060 _gdk_win32_cf_to_string (msg->wParam),
3061 _delayed_rendering_data));
3063 API_CALL (SetClipboardData, (msg->wParam, _delayed_rendering_data));
3064 _delayed_rendering_data = NULL;
3069 GDK_NOTE (EVENTS, g_print (" %s%s %p",
3070 (LOWORD (msg->wParam) == WA_ACTIVE ? "ACTIVE" :
3071 (LOWORD (msg->wParam) == WA_CLICKACTIVE ? "CLICKACTIVE" :
3072 (LOWORD (msg->wParam) == WA_INACTIVE ? "INACTIVE" : "???"))),
3073 HIWORD (msg->wParam) ? " minimized" : "",
3074 (HWND) msg->lParam));
3075 /* We handle mouse clicks for modally-blocked windows under WM_MOUSEACTIVATE,
3076 * but we still need to deal with alt-tab, or with SetActiveWindow() type
3079 if (is_modally_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
3081 GdkWindow *modal_current = _gdk_modal_current ();
3082 SetActiveWindow (GDK_WINDOW_HWND (modal_current));
3088 /* Bring any tablet contexts to the top of the overlap order when
3089 * one of our windows is activated.
3090 * NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP
3093 if (LOWORD(msg->wParam) != WA_INACTIVE)
3094 _gdk_input_set_tablet_active ();
3097 case WM_ACTIVATEAPP:
3098 GDK_NOTE (EVENTS, g_print (" %s thread: %I64d",
3099 msg->wParam ? "YES" : "NO",
3100 (gint64) msg->lParam));
3101 if (msg->wParam && GDK_WINDOW_IS_MAPPED (window))
3102 ensure_stacking_on_activate_app (msg, window);
3105 /* Handle WINTAB events here, as we know that gdkinput.c will
3106 * use the fixed WT_DEFBASE as lcMsgBase, and we thus can use the
3107 * constants as case labels.
3110 GDK_NOTE (EVENTS, g_print (" %d %p",
3111 (int) msg->wParam, (gpointer) msg->lParam));
3115 GDK_NOTE (EVENTS, g_print (" %d %p",
3116 (int) msg->wParam, (gpointer) msg->lParam));
3120 GDK_NOTE (EVENTS, g_print (" %p %d %d",
3121 (gpointer) msg->wParam,
3122 LOWORD (msg->lParam),
3123 HIWORD (msg->lParam)));
3127 event = gdk_event_new (GDK_NOTHING);
3128 event->any.window = window;
3129 g_object_ref (window);
3131 if (_gdk_input_other_event (event, msg, window))
3132 append_event (event);
3134 gdk_event_free (event);
3142 g_object_unref (window);
3149 _gdk_events_queue (GdkDisplay *display)
3153 if (modal_win32_dialog != NULL)
3156 while (!_gdk_event_queue_find_first (display) &&
3157 PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3159 TranslateMessage (&msg);
3160 DispatchMessageW (&msg);
3165 gdk_event_prepare (GSource *source,
3171 GDK_THREADS_ENTER ();
3175 retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
3176 (modal_win32_dialog == NULL &&
3177 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
3179 GDK_THREADS_LEAVE ();
3185 gdk_event_check (GSource *source)
3190 GDK_THREADS_ENTER ();
3192 if (event_poll_fd.revents & G_IO_IN)
3194 retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
3195 (modal_win32_dialog == NULL &&
3196 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
3203 GDK_THREADS_LEAVE ();
3209 gdk_event_dispatch (GSource *source,
3210 GSourceFunc callback,
3215 GDK_THREADS_ENTER ();
3217 _gdk_events_queue (_gdk_display);
3218 event = _gdk_event_unqueue (_gdk_display);
3222 _gdk_event_emit (event);
3224 gdk_event_free (event);
3226 /* Do drag & drop if it is still pending */
3227 if (_dnd_source_state == GDK_WIN32_DND_PENDING)
3229 _dnd_source_state = GDK_WIN32_DND_DRAGGING;
3230 _gdk_win32_dnd_do_dragdrop ();
3231 _dnd_source_state = GDK_WIN32_DND_NONE;
3235 GDK_THREADS_LEAVE ();
3241 gdk_win32_set_modal_dialog_libgtk_only (HWND window)
3243 modal_win32_dialog = window;
3247 is_modally_blocked (GdkWindow *window)
3249 GdkWindow *modal_current = _gdk_modal_current ();
3250 return modal_current != NULL ? gdk_window_get_toplevel (window) != modal_current : FALSE;
3254 check_for_too_much_data (GdkEvent *event)
3256 if (event->client.data.l[1] ||
3257 event->client.data.l[2] ||
3258 event->client.data.l[3] ||
3259 event->client.data.l[4])
3261 g_warning ("Only four bytes of data are passed in client messages on Win32\n");
3266 gdk_event_send_client_message_for_display (GdkDisplay *display,
3268 GdkNativeWindow winid)
3270 check_for_too_much_data (event);
3272 return PostMessageW ((HWND) winid, client_message,
3273 (WPARAM) event->client.message_type,
3274 event->client.data.l[0]);
3278 gdk_screen_broadcast_client_message (GdkScreen *screen,
3281 check_for_too_much_data (event);
3283 PostMessageW (HWND_BROADCAST, client_message,
3284 (WPARAM) event->client.message_type,
3285 event->client.data.l[0]);
3294 /* Process all messages currently available */
3295 while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3297 TranslateMessage (&msg);
3298 DispatchMessageW (&msg);
3306 gdk_display_sync (GdkDisplay * display)
3310 g_return_if_fail (display == _gdk_display);
3312 /* Process all messages currently available */
3313 while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3314 DispatchMessageW (&msg);
3318 gdk_display_flush (GdkDisplay * display)
3320 g_return_if_fail (display == _gdk_display);
3326 gdk_net_wm_supports (GdkAtom property)
3332 _gdk_windowing_event_data_copy (const GdkEvent *src,
3338 _gdk_windowing_event_data_free (GdkEvent *event)