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);
759 CASE (GDK_NO_EXPOSE);
761 CASE (GDK_WINDOW_STATE);
763 CASE (GDK_OWNER_CHANGE);
764 CASE (GDK_GRAB_BROKEN);
766 default: g_assert_not_reached ();
769 g_print (" %p ", event->any.window ? GDK_WINDOW_HWND (event->any.window) : NULL);
771 switch (event->any.type)
775 _gdk_win32_gdkrectangle_to_string (&event->expose.area),
776 event->expose.count);
778 case GDK_MOTION_NOTIFY:
779 g_print ("(%.4g,%.4g) (%.4g,%.4g) %s",
780 event->motion.x, event->motion.y,
781 event->motion.x_root, event->motion.y_root,
782 event->motion.is_hint ? "HINT " : "");
783 print_event_state (event->motion.state);
785 case GDK_BUTTON_PRESS:
786 case GDK_2BUTTON_PRESS:
787 case GDK_3BUTTON_PRESS:
788 case GDK_BUTTON_RELEASE:
789 g_print ("%d (%.4g,%.4g) (%.4g,%.4g) ",
790 event->button.button,
791 event->button.x, event->button.y,
792 event->button.x_root, event->button.y_root);
793 print_event_state (event->button.state);
796 case GDK_KEY_RELEASE:
797 if (event->key.length == 0)
798 escaped = g_strdup ("");
800 escaped = g_strescape (event->key.string, NULL);
801 kvname = gdk_keyval_name (event->key.keyval);
802 g_print ("%#.02x group:%d %s %d:\"%s\" ",
803 event->key.hardware_keycode, event->key.group,
804 (kvname ? kvname : "??"),
808 print_event_state (event->key.state);
810 case GDK_ENTER_NOTIFY:
811 case GDK_LEAVE_NOTIFY:
812 g_print ("%p (%.4g,%.4g) (%.4g,%.4g) %s %s%s",
813 event->crossing.subwindow == NULL ? NULL : GDK_WINDOW_HWND (event->crossing.subwindow),
814 event->crossing.x, event->crossing.y,
815 event->crossing.x_root, event->crossing.y_root,
816 (event->crossing.mode == GDK_CROSSING_NORMAL ? "NORMAL" :
817 (event->crossing.mode == GDK_CROSSING_GRAB ? "GRAB" :
818 (event->crossing.mode == GDK_CROSSING_UNGRAB ? "UNGRAB" :
820 (event->crossing.detail == GDK_NOTIFY_ANCESTOR ? "ANCESTOR" :
821 (event->crossing.detail == GDK_NOTIFY_VIRTUAL ? "VIRTUAL" :
822 (event->crossing.detail == GDK_NOTIFY_INFERIOR ? "INFERIOR" :
823 (event->crossing.detail == GDK_NOTIFY_NONLINEAR ? "NONLINEAR" :
824 (event->crossing.detail == GDK_NOTIFY_NONLINEAR_VIRTUAL ? "NONLINEAR_VIRTUAL" :
825 (event->crossing.detail == GDK_NOTIFY_UNKNOWN ? "UNKNOWN" :
827 event->crossing.focus ? " FOCUS" : "");
828 print_event_state (event->crossing.state);
830 case GDK_FOCUS_CHANGE:
831 g_print ("%s", (event->focus_change.in ? "IN" : "OUT"));
834 g_print ("x:%d y:%d w:%d h:%d",
835 event->configure.x, event->configure.y,
836 event->configure.width, event->configure.height);
838 case GDK_SELECTION_CLEAR:
839 case GDK_SELECTION_REQUEST:
840 case GDK_SELECTION_NOTIFY:
841 selection_name = gdk_atom_name (event->selection.selection);
842 target_name = gdk_atom_name (event->selection.target);
843 property_name = gdk_atom_name (event->selection.property);
844 g_print ("sel:%s tgt:%s prop:%s",
845 selection_name, target_name, property_name);
846 g_free (selection_name);
847 g_free (target_name);
848 g_free (property_name);
852 case GDK_DRAG_MOTION:
853 case GDK_DRAG_STATUS:
855 case GDK_DROP_FINISHED:
856 if (event->dnd.context != NULL)
857 g_print ("ctx:%p: %s %s src:%p dest:%p",
859 _gdk_win32_drag_protocol_to_string (event->dnd.context->protocol),
860 event->dnd.context->is_source ? "SOURCE" : "DEST",
861 event->dnd.context->source_window == NULL ? NULL : GDK_WINDOW_HWND (event->dnd.context->source_window),
862 event->dnd.context->dest_window == NULL ? NULL : GDK_WINDOW_HWND (event->dnd.context->dest_window));
864 case GDK_CLIENT_EVENT:
865 g_print ("%s %d %ld %ld %ld %ld %ld",
866 gdk_atom_name (event->client.message_type),
867 event->client.data_format,
868 event->client.data.l[0],
869 event->client.data.l[1],
870 event->client.data.l[2],
871 event->client.data.l[3],
872 event->client.data.l[4]);
875 g_print ("(%.4g,%.4g) (%.4g,%.4g) %s ",
876 event->scroll.x, event->scroll.y,
877 event->scroll.x_root, event->scroll.y_root,
878 (event->scroll.direction == GDK_SCROLL_UP ? "UP" :
879 (event->scroll.direction == GDK_SCROLL_DOWN ? "DOWN" :
880 (event->scroll.direction == GDK_SCROLL_LEFT ? "LEFT" :
881 (event->scroll.direction == GDK_SCROLL_RIGHT ? "RIGHT" :
883 print_event_state (event->scroll.state);
885 case GDK_WINDOW_STATE:
887 _gdk_win32_window_state_to_string (event->window_state.changed_mask),
888 _gdk_win32_window_state_to_string (event->window_state.new_window_state));
891 (event->setting.action == GDK_SETTING_ACTION_NEW ? "NEW" :
892 (event->setting.action == GDK_SETTING_ACTION_CHANGED ? "CHANGED" :
893 (event->setting.action == GDK_SETTING_ACTION_DELETED ? "DELETED" :
895 (event->setting.name ? event->setting.name : "NULL"));
896 case GDK_GRAB_BROKEN:
898 (event->grab_broken.keyboard ? "KEYBOARD" : "POINTER"),
899 (event->grab_broken.implicit ? "IMPLICIT" : "EXPLICIT"),
900 (event->grab_broken.grab_window ? GDK_WINDOW_HWND (event->grab_broken.grab_window) : 0));
905 g_print ("%s", (debug_indent == 0 ? "\n" : ""));
909 decode_key_lparam (LPARAM lParam)
911 static char buf[100];
914 if (HIWORD (lParam) & KF_UP)
915 p += g_sprintf (p, "KF_UP ");
916 if (HIWORD (lParam) & KF_REPEAT)
917 p += g_sprintf (p, "KF_REPEAT ");
918 if (HIWORD (lParam) & KF_ALTDOWN)
919 p += g_sprintf (p, "KF_ALTDOWN ");
920 if (HIWORD (lParam) & KF_EXTENDED)
921 p += g_sprintf (p, "KF_EXTENDED ");
922 p += g_sprintf (p, "sc:%d rep:%d", LOBYTE (HIWORD (lParam)), LOWORD (lParam));
930 fixup_event (GdkEvent *event)
932 if (event->any.window)
933 g_object_ref (event->any.window);
934 if (((event->any.type == GDK_ENTER_NOTIFY) ||
935 (event->any.type == GDK_LEAVE_NOTIFY)) &&
936 (event->crossing.subwindow != NULL))
937 g_object_ref (event->crossing.subwindow);
938 event->any.send_event = InSendMessage ();
942 append_event (GdkEvent *event)
948 link = _gdk_event_queue_append (_gdk_display, event);
949 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
950 /* event morphing, the passed in may not be valid afterwards */
951 _gdk_windowing_got_event (_gdk_display, link, event, 0);
953 _gdk_event_queue_append (_gdk_display, event);
954 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
959 fill_key_event_string (GdkEvent *event)
964 /* Fill in event->string crudely, since various programs
969 if (event->key.keyval != GDK_KEY_VoidSymbol)
970 c = gdk_keyval_to_unicode (event->key.keyval);
977 /* Apply the control key - Taken from Xlib
979 if (event->key.state & GDK_CONTROL_MASK)
981 if ((c >= '@' && c < '\177') || c == ' ')
985 event->key.string = g_memdup ("\0\0", 2);
986 event->key.length = 1;
989 else if (c >= '3' && c <= '7')
997 len = g_unichar_to_utf8 (c, buf);
1000 event->key.string = g_locale_from_utf8 (buf, len,
1001 NULL, &bytes_written,
1003 if (event->key.string)
1004 event->key.length = bytes_written;
1006 else if (event->key.keyval == GDK_KEY_Escape)
1008 event->key.length = 1;
1009 event->key.string = g_strdup ("\033");
1011 else if (event->key.keyval == GDK_KEY_Return ||
1012 event->key.keyval == GDK_KEY_KP_Enter)
1014 event->key.length = 1;
1015 event->key.string = g_strdup ("\r");
1018 if (!event->key.string)
1020 event->key.length = 0;
1021 event->key.string = g_strdup ("");
1025 static GdkFilterReturn
1026 apply_event_filters (GdkWindow *window,
1030 GdkFilterReturn result = GDK_FILTER_CONTINUE;
1035 event = gdk_event_new (GDK_NOTHING);
1037 event->any.window = g_object_ref (window);
1038 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1040 /* I think GdkFilterFunc semantics require the passed-in event
1041 * to already be in the queue. The filter func can generate
1042 * more events and append them after it if it likes.
1044 node = _gdk_event_queue_append (_gdk_display, event);
1046 tmp_list = *filters;
1049 GdkEventFilter *filter = (GdkEventFilter *) tmp_list->data;
1052 if ((filter->flags & GDK_EVENT_FILTER_REMOVED) != 0)
1054 tmp_list = tmp_list->next;
1058 filter->ref_count++;
1059 result = filter->function (msg, event, filter->data);
1061 /* get the next node after running the function since the
1062 function may add or remove a next node */
1064 tmp_list = tmp_list->next;
1066 filter->ref_count--;
1067 if (filter->ref_count == 0)
1069 *filters = g_list_remove_link (*filters, node);
1070 g_list_free_1 (node);
1074 if (result != GDK_FILTER_CONTINUE)
1078 if (result == GDK_FILTER_CONTINUE || result == GDK_FILTER_REMOVE)
1080 _gdk_event_queue_remove_link (_gdk_display, node);
1081 g_list_free_1 (node);
1082 gdk_event_free (event);
1084 else /* GDK_FILTER_TRANSLATE */
1086 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1087 fixup_event (event);
1088 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
1094 * On Windows, transient windows will not have their own taskbar entries.
1095 * Because of this, we must hide and restore groups of transients in both
1096 * directions. That is, all transient children must be hidden or restored
1097 * with this window, but if this window's transient owner also has a
1098 * transient owner then this window's transient owner must be hidden/restored
1099 * with this one. And etc, up the chain until we hit an ancestor that has no
1102 * It would be a good idea if applications don't chain transient windows
1103 * together. There's a limit to how much evil GTK can try to shield you
1107 show_window_recurse (GdkWindow *window, gboolean hide_window)
1109 GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1110 GSList *children = impl->transient_children;
1111 GdkWindow *child = NULL;
1113 if (!impl->changing_state)
1115 impl->changing_state = TRUE;
1117 if (children != NULL)
1119 while (children != NULL)
1121 child = children->data;
1122 show_window_recurse (child, hide_window);
1124 children = g_slist_next (children);
1128 if (GDK_WINDOW_IS_MAPPED (window))
1132 if (GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_ICONIFIED)
1134 if (GDK_WINDOW_OBJECT (window)->state & GDK_WINDOW_STATE_MAXIMIZED)
1136 ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWMAXIMIZED);
1140 ShowWindow (GDK_WINDOW_HWND (window), SW_RESTORE);
1146 ShowWindow (GDK_WINDOW_HWND (window), SW_MINIMIZE);
1150 impl->changing_state = FALSE;
1155 do_show_window (GdkWindow *window, gboolean hide_window)
1157 GdkWindow *tmp_window = NULL;
1158 GdkWindowImplWin32 *tmp_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
1160 if (!tmp_impl->changing_state)
1162 /* Find the top-level window in our transient chain. */
1163 while (tmp_impl->transient_owner != NULL)
1165 tmp_window = tmp_impl->transient_owner;
1166 tmp_impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (tmp_window)->impl);
1169 /* If we couldn't find one, use the window provided. */
1170 if (tmp_window == NULL)
1172 tmp_window = window;
1175 /* Recursively show/hide every window in the chain. */
1176 if (tmp_window != window)
1178 show_window_recurse (tmp_window, hide_window);
1184 synthesize_enter_or_leave_event (GdkWindow *window,
1187 GdkCrossingMode mode,
1188 GdkNotifyType detail)
1194 ScreenToClient (GDK_WINDOW_HWND (window), &pt);
1196 event = gdk_event_new (type);
1197 event->crossing.window = window;
1198 event->crossing.subwindow = NULL;
1199 event->crossing.time = _gdk_win32_get_next_tick (msg->time);
1200 event->crossing.x = pt.x;
1201 event->crossing.y = pt.y;
1202 event->crossing.x_root = msg->pt.x + _gdk_offset_x;
1203 event->crossing.y_root = msg->pt.y + _gdk_offset_y;
1204 event->crossing.mode = mode;
1205 event->crossing.detail = detail;
1206 event->crossing.focus = TRUE; /* FIXME: Set correctly */
1207 event->crossing.state = 0; /* FIXME: Set correctly */
1208 gdk_event_set_device (event, _gdk_display->core_pointer);
1210 append_event (event);
1212 if (type == GDK_ENTER_NOTIFY &&
1213 ((GdkWindowObject *) window)->extension_events != 0)
1214 _gdk_device_wintab_update_window_coords (window);
1217 /* The check_extended flag controls whether to check if the windows want
1218 * events from extended input devices and if the message should be skipped
1219 * because an extended input device is active
1222 propagate (GdkWindow **window,
1224 GdkWindow *grab_window,
1225 gboolean grab_owner_events,
1227 gboolean (*doesnt_want_it) (gint mask,
1229 gboolean check_extended)
1231 if (grab_window != NULL && !grab_owner_events)
1233 /* Event source is grabbed with owner_events FALSE */
1235 /* See if the event should be ignored because an extended input
1238 if (check_extended &&
1239 ((GdkWindowObject *) grab_window)->extension_events != 0 &&
1240 _gdk_input_ignore_core)
1242 GDK_NOTE (EVENTS, g_print (" (ignored for grabber)"));
1245 if ((*doesnt_want_it) (grab_mask, msg))
1247 GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)"));
1252 GDK_NOTE (EVENTS, g_print (" (to grabber)"));
1253 assign_object (window, grab_window);
1258 /* If we come here, we know that if grab_window != NULL then
1259 * grab_owner_events is TRUE
1263 if (check_extended &&
1264 ((GdkWindowObject *) *window)->extension_events != 0 &&
1265 _gdk_input_ignore_core)
1267 GDK_NOTE (EVENTS, g_print (" (ignored)"));
1270 if ((*doesnt_want_it) (((GdkWindowObject *) *window)->event_mask, msg))
1272 /* Owner doesn't want it, propagate to parent. */
1273 GdkWindow *parent = gdk_window_get_parent (*window);
1274 if (parent == _gdk_root || parent == NULL)
1276 /* No parent; check if grabbed */
1277 if (grab_window != NULL)
1279 /* Event source is grabbed with owner_events TRUE */
1281 if (check_extended &&
1282 ((GdkWindowObject *) grab_window)->extension_events != 0 &&
1283 _gdk_input_ignore_core)
1285 GDK_NOTE (EVENTS, g_print (" (ignored for grabber)"));
1288 if ((*doesnt_want_it) (grab_mask, msg))
1290 /* Grabber doesn't want it either */
1291 GDK_NOTE (EVENTS, g_print (" (grabber doesn't want it)"));
1297 GDK_NOTE (EVENTS, g_print (" (to grabber)"));
1298 assign_object (window, grab_window);
1304 GDK_NOTE (EVENTS, g_print (" (undelivered)"));
1310 assign_object (window, parent);
1311 /* The only branch where we actually continue the loop */
1320 doesnt_want_key (gint mask,
1323 return (((msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP) &&
1324 !(mask & GDK_KEY_RELEASE_MASK)) ||
1325 ((msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN) &&
1326 !(mask & GDK_KEY_PRESS_MASK)));
1330 doesnt_want_char (gint mask,
1333 return !(mask & (GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK));
1337 handle_configure_event (MSG *msg,
1342 GdkWindowObject *window_object;
1344 GetClientRect (msg->hwnd, &client_rect);
1345 point.x = client_rect.left; /* always 0 */
1346 point.y = client_rect.top;
1348 /* top level windows need screen coords */
1349 if (gdk_window_get_parent (window) == _gdk_root)
1351 ClientToScreen (msg->hwnd, &point);
1352 point.x += _gdk_offset_x;
1353 point.y += _gdk_offset_y;
1356 window_object = GDK_WINDOW_OBJECT (window);
1358 window_object->width = client_rect.right - client_rect.left;
1359 window_object->height = client_rect.bottom - client_rect.top;
1361 window_object->x = point.x;
1362 window_object->y = point.y;
1364 _gdk_window_update_size (window);
1366 if (window_object->event_mask & GDK_STRUCTURE_MASK)
1368 GdkEvent *event = gdk_event_new (GDK_CONFIGURE);
1370 event->configure.window = window;
1372 event->configure.width = client_rect.right - client_rect.left;
1373 event->configure.height = client_rect.bottom - client_rect.top;
1375 event->configure.x = point.x;
1376 event->configure.y = point.y;
1378 append_event (event);
1383 _gdk_win32_hrgn_to_region (HRGN hrgn)
1387 cairo_region_t *result;
1391 if ((nbytes = GetRegionData (hrgn, 0, NULL)) == 0)
1393 WIN32_GDI_FAILED ("GetRegionData");
1397 rgndata = (RGNDATA *) g_malloc (nbytes);
1399 if (GetRegionData (hrgn, nbytes, rgndata) == 0)
1401 WIN32_GDI_FAILED ("GetRegionData");
1406 result = cairo_region_create ();
1407 rects = (RECT *) rgndata->Buffer;
1408 for (i = 0; i < rgndata->rdh.nCount; i++)
1412 r.x = rects[i].left;
1414 r.width = rects[i].right - r.x;
1415 r.height = rects[i].bottom - r.y;
1417 cairo_region_union_rectangle (result, &r);
1426 adjust_drag (LONG *drag,
1431 *drag = curr + ((*drag + inc/2 - curr) / inc) * inc;
1433 *drag = curr - ((curr - *drag + inc/2) / inc) * inc;
1437 handle_wm_paint (MSG *msg,
1439 gboolean return_exposes,
1442 HRGN hrgn = CreateRectRgn (0, 0, 0, 0);
1444 PAINTSTRUCT paintstruct;
1445 cairo_region_t *update_region;
1447 if (GetUpdateRgn (msg->hwnd, hrgn, FALSE) == ERROR)
1449 WIN32_GDI_FAILED ("GetUpdateRgn");
1450 DeleteObject (hrgn);
1454 hdc = BeginPaint (msg->hwnd, &paintstruct);
1456 GDK_NOTE (EVENTS, g_print (" %s %s dc %p%s",
1457 _gdk_win32_rect_to_string (&paintstruct.rcPaint),
1458 (paintstruct.fErase ? "erase" : ""),
1460 (return_exposes ? " return_exposes" : "")));
1462 EndPaint (msg->hwnd, &paintstruct);
1464 if ((paintstruct.rcPaint.right == paintstruct.rcPaint.left) ||
1465 (paintstruct.rcPaint.bottom == paintstruct.rcPaint.top))
1467 GDK_NOTE (EVENTS, g_print (" (empty paintstruct, ignored)"));
1468 DeleteObject (hrgn);
1474 if (!GDK_WINDOW_DESTROYED (window))
1476 GList *list = _gdk_display->queued_events;
1478 *event = gdk_event_new (GDK_EXPOSE);
1479 (*event)->expose.window = window;
1480 (*event)->expose.area.x = paintstruct.rcPaint.left;
1481 (*event)->expose.area.y = paintstruct.rcPaint.top;
1482 (*event)->expose.area.width = paintstruct.rcPaint.right - paintstruct.rcPaint.left;
1483 (*event)->expose.area.height = paintstruct.rcPaint.bottom - paintstruct.rcPaint.top;
1484 (*event)->expose.region = _gdk_win32_hrgn_to_region (hrgn);
1485 (*event)->expose.count = 0;
1487 while (list != NULL)
1489 GdkEventPrivate *evp = list->data;
1491 if (evp->event.any.type == GDK_EXPOSE &&
1492 evp->event.any.window == window &&
1493 !(evp->flags & GDK_EVENT_PENDING))
1494 evp->event.expose.count++;
1500 DeleteObject (hrgn);
1504 update_region = _gdk_win32_hrgn_to_region (hrgn);
1505 if (!cairo_region_is_empty (update_region))
1506 _gdk_window_invalidate_for_expose (window, update_region);
1507 cairo_region_destroy (update_region);
1509 DeleteObject (hrgn);
1512 static VOID CALLBACK
1513 modal_timer_proc (HWND hwnd,
1518 int arbitrary_limit = 1;
1520 while (_modal_operation_in_progress &&
1521 g_main_context_pending (NULL) &&
1523 g_main_context_iteration (NULL, FALSE);
1527 _gdk_win32_begin_modal_call (void)
1529 g_assert (!_modal_operation_in_progress);
1531 _modal_operation_in_progress = TRUE;
1533 modal_timer = SetTimer (NULL, 0, 10, modal_timer_proc);
1534 if (modal_timer == 0)
1535 WIN32_API_FAILED ("SetTimer");
1539 _gdk_win32_end_modal_call (void)
1541 g_assert (_modal_operation_in_progress);
1543 _modal_operation_in_progress = FALSE;
1545 if (modal_timer != 0)
1547 API_CALL (KillTimer, (NULL, modal_timer));
1552 static VOID CALLBACK
1553 sync_timer_proc (HWND hwnd,
1559 if (PeekMessageW (&message, hwnd, WM_PAINT, WM_PAINT, PM_REMOVE))
1564 RedrawWindow (hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ALLCHILDREN);
1566 KillTimer (hwnd, sync_timer);
1570 handle_display_change (void)
1572 _gdk_monitor_init ();
1573 _gdk_root_window_size_init ();
1574 g_signal_emit_by_name (_gdk_screen, "size_changed");
1578 generate_button_event (GdkEventType type,
1583 GdkEvent *event = gdk_event_new (type);
1585 event->button.window = window;
1586 event->button.time = _gdk_win32_get_next_tick (msg->time);
1587 event->button.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
1588 event->button.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
1589 event->button.x_root = msg->pt.x + _gdk_offset_x;
1590 event->button.y_root = msg->pt.y + _gdk_offset_y;
1591 event->button.axes = NULL;
1592 event->button.state = build_pointer_event_state (msg);
1593 event->button.button = button;
1594 gdk_event_set_device (event, _gdk_display->core_pointer);
1596 append_event (event);
1600 ensure_stacking_on_unminimize (MSG *msg)
1603 HWND lowest_transient = NULL;
1606 while ((rover = GetNextWindow (rover, GW_HWNDNEXT)))
1608 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1610 /* Checking window group not implemented yet */
1613 GdkWindowImplWin32 *rover_impl =
1614 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1616 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1617 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1618 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1619 rover_impl->transient_owner != NULL))
1621 lowest_transient = rover;
1625 if (lowest_transient != NULL)
1627 GDK_NOTE (EVENTS, g_print (" restacking: %p", lowest_transient));
1628 SetWindowPos (msg->hwnd, lowest_transient, 0, 0, 0, 0,
1629 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1634 ensure_stacking_on_window_pos_changing (MSG *msg,
1637 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)((GdkWindowObject *) window)->impl;
1638 WINDOWPOS *windowpos = (WINDOWPOS *) msg->lParam;
1640 if (GetActiveWindow () == msg->hwnd &&
1641 impl->type_hint != GDK_WINDOW_TYPE_HINT_UTILITY &&
1642 impl->type_hint != GDK_WINDOW_TYPE_HINT_DIALOG &&
1643 impl->transient_owner == NULL)
1645 /* Make sure the window stays behind any transient-type windows
1646 * of the same window group.
1648 * If the window is not active and being activated, we let
1649 * Windows bring it to the top and rely on the WM_ACTIVATEAPP
1650 * handling to bring any utility windows on top of it.
1653 gboolean restacking;
1655 rover = windowpos->hwndInsertAfter;
1659 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1661 /* Checking window group not implemented yet */
1664 GdkWindowImplWin32 *rover_impl =
1665 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1667 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1668 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1669 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1670 rover_impl->transient_owner != NULL))
1673 windowpos->hwndInsertAfter = rover;
1676 rover = GetNextWindow (rover, GW_HWNDNEXT);
1681 GDK_NOTE (EVENTS, g_print (" restacking: %p", windowpos->hwndInsertAfter));
1689 ensure_stacking_on_activate_app (MSG *msg,
1692 GdkWindowImplWin32 *impl = (GdkWindowImplWin32 *)((GdkWindowObject *) window)->impl;
1694 if (impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1695 impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1696 impl->transient_owner != NULL)
1698 SetWindowPos (msg->hwnd, HWND_TOP, 0, 0, 0, 0,
1699 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1703 if (IsWindowVisible (msg->hwnd) &&
1704 msg->hwnd == GetActiveWindow ())
1706 /* This window is not a transient-type window and it is the
1707 * activated window. Make sure this window is as visible as
1708 * possible, just below the lowest transient-type window of this
1714 while ((rover = GetNextWindow (rover, GW_HWNDPREV)))
1716 GdkWindow *rover_gdkw = gdk_win32_handle_table_lookup (rover);
1718 /* Checking window group not implemented yet */
1721 GdkWindowImplWin32 *rover_impl =
1722 (GdkWindowImplWin32 *)((GdkWindowObject *)rover_gdkw)->impl;
1724 if (GDK_WINDOW_IS_MAPPED (rover_gdkw) &&
1725 (rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_UTILITY ||
1726 rover_impl->type_hint == GDK_WINDOW_TYPE_HINT_DIALOG ||
1727 rover_impl->transient_owner != NULL))
1729 GDK_NOTE (EVENTS, g_print (" restacking: %p", rover));
1730 SetWindowPos (msg->hwnd, rover, 0, 0, 0, 0,
1731 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
1740 gdk_event_translate (MSG *msg,
1743 RECT rect, *drag, orig_drag;
1748 BYTE key_state[256];
1750 WINDOWPOS *windowpos;
1757 GdkWindow *window = NULL;
1758 GdkWindowImplWin32 *impl;
1760 GdkWindow *orig_window, *new_window, *toplevel;
1762 GdkDeviceManager *device_manager;
1764 GdkDeviceGrabInfo *keyboard_grab = NULL;
1765 GdkDeviceGrabInfo *pointer_grab = NULL;
1766 GdkWindow *grab_window = NULL;
1772 gboolean return_val = FALSE;
1776 if (_gdk_default_filters)
1778 /* Apply global filters */
1780 GdkFilterReturn result = apply_event_filters (NULL, msg, &_gdk_default_filters);
1782 /* If result is GDK_FILTER_CONTINUE, we continue as if nothing
1783 * happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
1784 * we return TRUE, and DefWindowProcW() will not be called.
1786 if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
1790 window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd);
1791 orig_window = window;
1795 /* XXX Handle WM_QUIT here ? */
1796 if (msg->message == WM_QUIT)
1798 GDK_NOTE (EVENTS, g_print (" %d", (int) msg->wParam));
1801 else if (msg->message == WM_MOVE ||
1802 msg->message == WM_SIZE)
1804 /* It's quite normal to get these messages before we have
1805 * had time to register the window in our lookup table, or
1806 * when the window is being destroyed and we already have
1807 * removed it. Repost the same message to our queue so that
1808 * we will get it later when we are prepared.
1810 GDK_NOTE (EVENTS, g_print (" (posted)"));
1812 PostMessageW (msg->hwnd, msg->message, msg->wParam, msg->lParam);
1814 else if (msg->message == WM_CREATE)
1816 window = (UNALIGNED GdkWindow*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams);
1817 GDK_WINDOW_HWND (window) = msg->hwnd;
1821 GDK_NOTE (EVENTS, g_print (" (no GdkWindow)"));
1826 device_manager = gdk_display_get_device_manager (_gdk_display);
1828 keyboard_grab = _gdk_display_get_last_device_grab (_gdk_display,
1829 GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
1830 pointer_grab = _gdk_display_get_last_device_grab (_gdk_display,
1831 GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_pointer);
1833 g_object_ref (window);
1835 /* window's refcount has now been increased, so code below should
1836 * not just return from this function, but instead goto done (or
1837 * break out of the big switch). To protect against forgetting this,
1838 * #define return to a syntax error...
1840 #define return GOTO_DONE_INSTEAD
1842 if (!GDK_WINDOW_DESTROYED (window) && ((GdkWindowObject *) window)->filters)
1844 /* Apply per-window filters */
1846 GdkFilterReturn result = apply_event_filters (window, msg, &((GdkWindowObject *) window)->filters);
1848 if (result == GDK_FILTER_REMOVE || result == GDK_FILTER_TRANSLATE)
1855 if (msg->message == client_message)
1858 GdkFilterReturn result = GDK_FILTER_CONTINUE;
1861 GDK_NOTE (EVENTS, g_print (" client_message"));
1863 event = gdk_event_new (GDK_NOTHING);
1864 ((GdkEventPrivate *)event)->flags |= GDK_EVENT_PENDING;
1866 node = _gdk_event_queue_append (_gdk_display, event);
1868 tmp_list = client_filters;
1871 GdkClientFilter *filter = tmp_list->data;
1873 tmp_list = tmp_list->next;
1875 if (filter->type == GDK_POINTER_TO_ATOM (msg->wParam))
1877 GDK_NOTE (EVENTS, g_print (" (match)"));
1879 result = (*filter->function) (msg, event, filter->data);
1881 if (result != GDK_FILTER_CONTINUE)
1888 case GDK_FILTER_REMOVE:
1889 _gdk_event_queue_remove_link (_gdk_display, node);
1890 g_list_free_1 (node);
1891 gdk_event_free (event);
1895 case GDK_FILTER_TRANSLATE:
1896 ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
1897 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
1901 case GDK_FILTER_CONTINUE:
1902 /* Send unknown client messages on to Gtk for it to use */
1904 event->client.type = GDK_CLIENT_EVENT;
1905 event->client.window = window;
1906 event->client.message_type = GDK_POINTER_TO_ATOM (msg->wParam);
1907 event->client.data_format = 32;
1908 event->client.data.l[0] = msg->lParam;
1909 for (i = 1; i < 5; i++)
1910 event->client.data.l[i] = 0;
1911 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
1917 switch (msg->message)
1919 case WM_INPUTLANGCHANGE:
1920 _gdk_input_locale = (HKL) msg->lParam;
1921 _gdk_input_locale_is_ime = ImmIsIME (_gdk_input_locale);
1922 GetLocaleInfo (MAKELCID (LOWORD (_gdk_input_locale), SORT_DEFAULT),
1923 LOCALE_IDEFAULTANSICODEPAGE,
1925 _gdk_input_codepage = atoi (buf);
1926 _gdk_keymap_serial++;
1928 g_print (" cs:%lu hkl:%p%s cp:%d",
1929 (gulong) msg->wParam,
1930 (gpointer) msg->lParam, _gdk_input_locale_is_ime ? " (IME)" : "",
1931 _gdk_input_codepage));
1937 g_print (" %s ch:%.02x %s",
1938 _gdk_win32_key_to_string (msg->lParam),
1940 decode_key_lparam (msg->lParam)));
1942 /* If posted without us having keyboard focus, ignore */
1943 if ((msg->wParam != VK_F10 && msg->wParam != VK_MENU) &&
1944 !(HIWORD (msg->lParam) & KF_ALTDOWN))
1947 /* Let the system handle Alt-Tab, Alt-Space and Alt-F4 unless
1948 * the keyboard is grabbed.
1950 if (!keyboard_grab &&
1951 (msg->wParam == VK_TAB ||
1952 msg->wParam == VK_SPACE ||
1953 msg->wParam == VK_F4))
1956 /* Jump to code in common with WM_KEYUP and WM_KEYDOWN */
1962 g_print (" %s ch:%.02x %s",
1963 _gdk_win32_key_to_string (msg->lParam),
1965 decode_key_lparam (msg->lParam)));
1969 /* Ignore key messages intended for the IME */
1970 if (msg->wParam == VK_PROCESSKEY ||
1974 if (keyboard_grab &&
1975 !propagate (&window, msg,
1976 keyboard_grab->window,
1977 keyboard_grab->owner_events,
1978 GDK_ALL_EVENTS_MASK,
1979 doesnt_want_key, FALSE))
1982 if (GDK_WINDOW_DESTROYED (window))
1985 event = gdk_event_new ((msg->message == WM_KEYDOWN ||
1986 msg->message == WM_SYSKEYDOWN) ?
1987 GDK_KEY_PRESS : GDK_KEY_RELEASE);
1988 event->key.window = window;
1989 event->key.time = _gdk_win32_get_next_tick (msg->time);
1990 event->key.keyval = GDK_KEY_VoidSymbol;
1991 event->key.string = NULL;
1992 event->key.length = 0;
1993 event->key.hardware_keycode = msg->wParam;
1994 gdk_event_set_device (event, GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
1995 if (HIWORD (msg->lParam) & KF_EXTENDED)
1997 switch (msg->wParam)
2000 event->key.hardware_keycode = VK_RCONTROL;
2002 case VK_SHIFT: /* Actually, KF_EXTENDED is not set
2003 * for the right shift key.
2005 event->key.hardware_keycode = VK_RSHIFT;
2008 event->key.hardware_keycode = VK_RMENU;
2012 else if (msg->wParam == VK_SHIFT &&
2013 LOBYTE (HIWORD (msg->lParam)) == _scancode_rshift)
2014 event->key.hardware_keycode = VK_RSHIFT;
2016 API_CALL (GetKeyboardState, (key_state));
2018 /* 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]); */
2020 build_key_event_state (event, key_state);
2022 gdk_keymap_translate_keyboard_state (NULL,
2023 event->key.hardware_keycode,
2029 fill_key_event_string (event);
2031 /* Reset MOD1_MASK if it is the Alt key itself */
2032 if (msg->wParam == VK_MENU)
2033 event->key.state &= ~GDK_MOD1_MASK;
2035 append_event (event);
2041 if (msg->wParam != VK_SPACE)
2043 /* To prevent beeps, don't let DefWindowProcW() be called */
2049 case WM_IME_STARTCOMPOSITION:
2050 in_ime_composition = TRUE;
2053 case WM_IME_ENDCOMPOSITION:
2054 in_ime_composition = FALSE;
2057 case WM_IME_COMPOSITION:
2058 /* On Win2k WM_IME_CHAR doesn't work correctly for non-Unicode
2059 * applications. Thus, handle WM_IME_COMPOSITION with
2060 * GCS_RESULTSTR instead, fetch the Unicode chars from the IME
2061 * with ImmGetCompositionStringW().
2064 * http://groups.google.com/groups?selm=natX5.57%24g77.19788%40nntp2.onemain.com
2066 * http://groups.google.com/groups?selm=u2XfrXw5BHA.1628%40tkmsftngp02
2067 * for comments by other people that seems to have the same
2068 * experience. WM_IME_CHAR just gives question marks, apparently
2069 * because of going through some conversion to the current code
2072 * WM_IME_CHAR might work on NT4 or Win9x with ActiveIMM, but
2073 * use WM_IME_COMPOSITION there, too, to simplify the code.
2075 GDK_NOTE (EVENTS, g_print (" %#lx", (long) msg->lParam));
2077 if (!(msg->lParam & GCS_RESULTSTR))
2080 if (keyboard_grab &&
2081 !propagate (&window, msg,
2082 keyboard_grab->window,
2083 keyboard_grab->owner_events,
2084 GDK_ALL_EVENTS_MASK,
2085 doesnt_want_char, FALSE))
2088 if (GDK_WINDOW_DESTROYED (window))
2091 himc = ImmGetContext (msg->hwnd);
2092 ccount = ImmGetCompositionStringW (himc, GCS_RESULTSTR,
2093 wbuf, sizeof (wbuf));
2094 ImmReleaseContext (msg->hwnd, himc);
2098 API_CALL (GetKeyboardState, (key_state));
2100 for (i = 0; i < ccount; i++)
2102 if (((GdkWindowObject *) window)->event_mask & GDK_KEY_PRESS_MASK)
2104 /* Build a key press event */
2105 event = gdk_event_new (GDK_KEY_PRESS);
2106 event->key.window = window;
2107 gdk_event_set_device (event, GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
2108 build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
2110 append_event (event);
2113 if (((GdkWindowObject *) window)->event_mask & GDK_KEY_RELEASE_MASK)
2115 /* Build a key release event. */
2116 event = gdk_event_new (GDK_KEY_RELEASE);
2117 event->key.window = window;
2118 gdk_event_set_device (event, GDK_DEVICE_MANAGER_WIN32 (device_manager)->core_keyboard);
2119 build_wm_ime_composition_event (event, msg, wbuf[i], key_state);
2121 append_event (event);
2127 case WM_LBUTTONDOWN:
2131 case WM_MBUTTONDOWN:
2135 case WM_RBUTTONDOWN:
2139 case WM_XBUTTONDOWN:
2140 if (HIWORD (msg->wParam) == XBUTTON1)
2147 g_print (" (%d,%d)",
2148 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2150 assign_object (&window, find_window_for_mouse_event (window, msg));
2151 /* TODO_CSW?: there used to some synthesize and propagate */
2152 if (GDK_WINDOW_DESTROYED (window))
2155 /* TODO_CSW? Emulate X11's automatic active grab */
2156 generate_button_event (GDK_BUTTON_PRESS, button,
2175 if (HIWORD (msg->wParam) == XBUTTON1)
2182 g_print (" (%d,%d)",
2183 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2185 assign_object (&window, find_window_for_mouse_event (window, msg));
2187 if (((GdkWindowObject *) window)->extension_events != 0 &&
2188 _gdk_input_ignore_core)
2190 GDK_NOTE (EVENTS, g_print (" (ignored)"));
2195 generate_button_event (GDK_BUTTON_RELEASE, button,
2203 g_print (" %p (%d,%d)",
2204 (gpointer) msg->wParam,
2205 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2207 assign_object (&window, find_window_for_mouse_event (window, msg));
2208 toplevel = gdk_window_get_toplevel (window);
2209 if (current_toplevel != toplevel)
2211 GDK_NOTE (EVENTS, g_print (" toplevel %p -> %p",
2212 current_toplevel ? GDK_WINDOW_HWND (current_toplevel) : NULL,
2213 toplevel ? GDK_WINDOW_HWND (toplevel) : NULL));
2214 if (current_toplevel)
2215 synthesize_enter_or_leave_event (current_toplevel, msg,
2216 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2217 synthesize_enter_or_leave_event (toplevel, msg,
2218 GDK_ENTER_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2219 assign_object (¤t_toplevel, toplevel);
2220 track_mouse_event (TME_LEAVE, GDK_WINDOW_HWND (toplevel));
2223 /* If we haven't moved, don't create any GDK event. Windows
2224 * sends WM_MOUSEMOVE messages after a new window is shows under
2225 * the mouse, even if the mouse hasn't moved. This disturbs gtk.
2227 if (msg->pt.x + _gdk_offset_x == current_root_x &&
2228 msg->pt.y + _gdk_offset_y == current_root_y)
2231 current_root_x = msg->pt.x + _gdk_offset_x;
2232 current_root_y = msg->pt.y + _gdk_offset_y;
2234 event = gdk_event_new (GDK_MOTION_NOTIFY);
2235 event->motion.window = window;
2236 event->motion.time = _gdk_win32_get_next_tick (msg->time);
2237 event->motion.x = current_x = (gint16) GET_X_LPARAM (msg->lParam);
2238 event->motion.y = current_y = (gint16) GET_Y_LPARAM (msg->lParam);
2239 event->motion.x_root = current_root_x;
2240 event->motion.y_root = current_root_y;
2241 event->motion.axes = NULL;
2242 event->motion.state = build_pointer_event_state (msg);
2243 event->motion.is_hint = FALSE;
2244 gdk_event_set_device (event, _gdk_display->core_pointer);
2246 append_event (event);
2251 case WM_NCMOUSEMOVE:
2253 g_print (" (%d,%d)",
2254 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2255 #if 0 /* TODO_CSW? */
2256 if (current_toplevel != NULL &&
2257 (((GdkWindowObject *) current_toplevel)->event_mask & GDK_LEAVE_NOTIFY_MASK))
2259 synthesize_enter_or_leave_event (current_toplevel, msg,
2260 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2266 GDK_NOTE (EVENTS, g_print (" %d (%ld,%ld)",
2267 HIWORD (msg->wParam), msg->pt.x, msg->pt.y));
2269 if (!gdk_win32_handle_table_lookup ((GdkNativeWindow) WindowFromPoint (msg->pt)))
2271 /* we are only interested if we don't know the new window */
2272 if (current_toplevel)
2273 synthesize_enter_or_leave_event (current_toplevel, msg,
2274 GDK_LEAVE_NOTIFY, GDK_CROSSING_NORMAL, GDK_NOTIFY_ANCESTOR);
2275 assign_object (¤t_toplevel, NULL);
2279 GDK_NOTE (EVENTS, g_print (" (ignored)"));
2286 GDK_NOTE (EVENTS, g_print (" %d", (short) HIWORD (msg->wParam)));
2288 /* WM_MOUSEWHEEL is delivered to the focus window. Work around
2289 * that. Also, the position is in screen coordinates, not client
2290 * coordinates as with the button messages. I love the
2291 * consistency of Windows.
2293 point.x = GET_X_LPARAM (msg->lParam);
2294 point.y = GET_Y_LPARAM (msg->lParam);
2296 if ((hwnd = WindowFromPoint (point)) == NULL)
2300 if ((new_window = gdk_win32_handle_table_lookup ((GdkNativeWindow) msg->hwnd)) == NULL)
2303 if (new_window != window)
2305 assign_object (&window, new_window);
2308 ScreenToClient (msg->hwnd, &point);
2310 event = gdk_event_new (GDK_SCROLL);
2311 event->scroll.window = window;
2312 event->scroll.direction = (((short) HIWORD (msg->wParam)) > 0) ?
2313 GDK_SCROLL_UP : GDK_SCROLL_DOWN;
2314 event->scroll.time = _gdk_win32_get_next_tick (msg->time);
2315 event->scroll.x = (gint16) point.x;
2316 event->scroll.y = (gint16) point.y;
2317 event->scroll.x_root = (gint16) GET_X_LPARAM (msg->lParam) + _gdk_offset_x;
2318 event->scroll.y_root = (gint16) GET_Y_LPARAM (msg->lParam) + _gdk_offset_y;
2319 event->scroll.state = build_pointer_event_state (msg);
2320 gdk_event_set_device (event, _gdk_display->core_pointer);
2322 append_event (event);
2328 /* Just print more debugging information, don't actually handle it. */
2331 (LOWORD (msg->wParam) == SB_ENDSCROLL ? "ENDSCROLL" :
2332 (LOWORD (msg->wParam) == SB_LEFT ? "LEFT" :
2333 (LOWORD (msg->wParam) == SB_RIGHT ? "RIGHT" :
2334 (LOWORD (msg->wParam) == SB_LINELEFT ? "LINELEFT" :
2335 (LOWORD (msg->wParam) == SB_LINERIGHT ? "LINERIGHT" :
2336 (LOWORD (msg->wParam) == SB_PAGELEFT ? "PAGELEFT" :
2337 (LOWORD (msg->wParam) == SB_PAGERIGHT ? "PAGERIGHT" :
2338 (LOWORD (msg->wParam) == SB_THUMBPOSITION ? "THUMBPOSITION" :
2339 (LOWORD (msg->wParam) == SB_THUMBTRACK ? "THUMBTRACK" :
2341 (LOWORD (msg->wParam) == SB_THUMBPOSITION ||
2342 LOWORD (msg->wParam) == SB_THUMBTRACK) ?
2343 (g_print (" %d", HIWORD (msg->wParam)), 0) : 0));
2347 /* Just print more debugging information, don't actually handle it. */
2350 (LOWORD (msg->wParam) == SB_ENDSCROLL ? "ENDSCROLL" :
2351 (LOWORD (msg->wParam) == SB_BOTTOM ? "BOTTOM" :
2352 (LOWORD (msg->wParam) == SB_TOP ? "TOP" :
2353 (LOWORD (msg->wParam) == SB_LINEDOWN ? "LINDOWN" :
2354 (LOWORD (msg->wParam) == SB_LINEUP ? "LINEUP" :
2355 (LOWORD (msg->wParam) == SB_PAGEDOWN ? "PAGEDOWN" :
2356 (LOWORD (msg->wParam) == SB_PAGEUP ? "PAGEUP" :
2357 (LOWORD (msg->wParam) == SB_THUMBPOSITION ? "THUMBPOSITION" :
2358 (LOWORD (msg->wParam) == SB_THUMBTRACK ? "THUMBTRACK" :
2360 (LOWORD (msg->wParam) == SB_THUMBPOSITION ||
2361 LOWORD (msg->wParam) == SB_THUMBTRACK) ?
2362 (g_print (" %d", HIWORD (msg->wParam)), 0) : 0));
2365 case WM_MOUSEACTIVATE:
2369 if (gdk_window_get_window_type (window) == GDK_WINDOW_TEMP
2370 || !((GdkWindowObject *)window)->accept_focus)
2372 *ret_valp = MA_NOACTIVATE;
2376 tmp = _gdk_modal_current ();
2380 if (gdk_window_get_toplevel (window) != tmp)
2382 *ret_valp = MA_NOACTIVATEANDEAT;
2391 if (keyboard_grab != NULL &&
2392 !GDK_WINDOW_DESTROYED (keyboard_grab->window))
2394 generate_grab_broken_event (device_manager, keyboard_grab->window, TRUE, NULL);
2399 if (keyboard_grab != NULL &&
2400 !keyboard_grab->owner_events)
2403 if (!(((GdkWindowObject *) window)->event_mask & GDK_FOCUS_CHANGE_MASK))
2406 if (GDK_WINDOW_DESTROYED (window))
2409 generate_focus_event (device_manager, window, (msg->message == WM_SETFOCUS));
2414 GDK_NOTE (EVENTS, g_print (" %p", (HANDLE) msg->wParam));
2416 if (GDK_WINDOW_DESTROYED (window))
2424 sync_timer = SetTimer (GDK_WINDOW_HWND (window),
2426 200, sync_timer_proc);
2430 handle_wm_paint (msg, window, FALSE, NULL);
2434 GDK_NOTE (EVENTS, g_print (" %#x %#x",
2435 LOWORD (msg->lParam), HIWORD (msg->lParam)));
2437 if (pointer_grab != NULL)
2438 grab_window = pointer_grab->window;
2440 if (grab_window == NULL && LOWORD (msg->lParam) != HTCLIENT)
2443 if (grab_window != NULL && p_grab_cursor != NULL)
2444 hcursor = p_grab_cursor;
2445 else if (!GDK_WINDOW_DESTROYED (window))
2446 hcursor = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl)->hcursor;
2450 if (hcursor != NULL)
2452 GDK_NOTE (EVENTS, g_print (" (SetCursor(%p)", hcursor));
2453 SetCursor (hcursor);
2460 GDK_NOTE (EVENTS, g_print (" %s %s",
2461 (msg->wParam ? "YES" : "NO"),
2462 (msg->lParam == 0 ? "ShowWindow" :
2463 (msg->lParam == SW_OTHERUNZOOM ? "OTHERUNZOOM" :
2464 (msg->lParam == SW_OTHERZOOM ? "OTHERZOOM" :
2465 (msg->lParam == SW_PARENTCLOSING ? "PARENTCLOSING" :
2466 (msg->lParam == SW_PARENTOPENING ? "PARENTOPENING" :
2469 if (!(((GdkWindowObject *) window)->event_mask & GDK_STRUCTURE_MASK))
2472 if (msg->lParam == SW_OTHERUNZOOM ||
2473 msg->lParam == SW_OTHERZOOM)
2476 if (GDK_WINDOW_DESTROYED (window))
2479 event = gdk_event_new (msg->wParam ? GDK_MAP : GDK_UNMAP);
2480 event->any.window = window;
2482 append_event (event);
2484 if (event->any.type == GDK_UNMAP)
2486 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
2488 if (impl->transient_owner && GetForegroundWindow () == GDK_WINDOW_HWND (window))
2490 SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner));
2493 if (pointer_grab != NULL)
2495 if (pointer_grab->window == window)
2496 gdk_pointer_ungrab (msg->time);
2499 if (keyboard_grab &&
2500 keyboard_grab->window == window)
2501 gdk_keyboard_ungrab (msg->time);
2508 switch (msg->wParam)
2512 do_show_window (window, msg->wParam == SC_MINIMIZE ? TRUE : FALSE);
2520 g_print (" %s %dx%d",
2521 (msg->wParam == SIZE_MAXHIDE ? "MAXHIDE" :
2522 (msg->wParam == SIZE_MAXIMIZED ? "MAXIMIZED" :
2523 (msg->wParam == SIZE_MAXSHOW ? "MAXSHOW" :
2524 (msg->wParam == SIZE_MINIMIZED ? "MINIMIZED" :
2525 (msg->wParam == SIZE_RESTORED ? "RESTORED" : "?"))))),
2526 LOWORD (msg->lParam), HIWORD (msg->lParam)));
2528 if (msg->wParam == SIZE_MINIMIZED)
2530 /* Don't generate any GDK event. This is *not* an UNMAP. */
2531 if (pointer_grab != NULL)
2533 if (pointer_grab->window == window)
2534 gdk_pointer_ungrab (msg->time);
2536 if (keyboard_grab &&
2537 keyboard_grab->window == window)
2538 gdk_keyboard_ungrab (msg->time);
2540 gdk_synthesize_window_state (window,
2541 GDK_WINDOW_STATE_WITHDRAWN,
2542 GDK_WINDOW_STATE_ICONIFIED);
2543 do_show_window (window, TRUE);
2545 else if ((msg->wParam == SIZE_RESTORED ||
2546 msg->wParam == SIZE_MAXIMIZED) &&
2547 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD)
2549 GdkWindowState withdrawn_bit =
2550 IsWindowVisible (msg->hwnd) ? GDK_WINDOW_STATE_WITHDRAWN : 0;
2552 if (((GdkWindowObject *) window)->state & GDK_WINDOW_STATE_ICONIFIED)
2553 ensure_stacking_on_unminimize (msg);
2555 if (!GDK_WINDOW_DESTROYED (window))
2556 handle_configure_event (msg, window);
2558 if (msg->wParam == SIZE_RESTORED)
2560 gdk_synthesize_window_state (window,
2561 GDK_WINDOW_STATE_ICONIFIED |
2562 GDK_WINDOW_STATE_MAXIMIZED |
2566 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_TEMP && !GDK_WINDOW_IS_MAPPED (window))
2568 do_show_window (window, FALSE);
2571 else if (msg->wParam == SIZE_MAXIMIZED)
2573 gdk_synthesize_window_state (window,
2574 GDK_WINDOW_STATE_ICONIFIED |
2576 GDK_WINDOW_STATE_MAXIMIZED);
2579 if (((GdkWindowObject *) window)->resize_count > 1)
2580 ((GdkWindowObject *) window)->resize_count -= 1;
2582 if (((GdkWindowObject *) window)->extension_events != 0)
2583 _gdk_device_wintab_update_window_coords (window);
2589 case WM_ENTERSIZEMOVE:
2590 case WM_ENTERMENULOOP:
2591 _gdk_win32_begin_modal_call ();
2594 case WM_EXITSIZEMOVE:
2595 case WM_EXITMENULOOP:
2596 _gdk_win32_end_modal_call ();
2599 case WM_WINDOWPOSCHANGING:
2600 GDK_NOTE (EVENTS, (windowpos = (WINDOWPOS *) msg->lParam,
2601 g_print (" %s %s %dx%d@%+d%+d now below %p",
2602 _gdk_win32_window_pos_bits_to_string (windowpos->flags),
2603 (windowpos->hwndInsertAfter == HWND_BOTTOM ? "BOTTOM" :
2604 (windowpos->hwndInsertAfter == HWND_NOTOPMOST ? "NOTOPMOST" :
2605 (windowpos->hwndInsertAfter == HWND_TOP ? "TOP" :
2606 (windowpos->hwndInsertAfter == HWND_TOPMOST ? "TOPMOST" :
2607 (sprintf (buf, "%p", windowpos->hwndInsertAfter),
2609 windowpos->cx, windowpos->cy, windowpos->x, windowpos->y,
2610 GetNextWindow (msg->hwnd, GW_HWNDPREV))));
2612 if (GDK_WINDOW_IS_MAPPED (window))
2613 return_val = ensure_stacking_on_window_pos_changing (msg, window);
2616 case WM_WINDOWPOSCHANGED:
2617 windowpos = (WINDOWPOS *) msg->lParam;
2618 GDK_NOTE (EVENTS, g_print (" %s %s %dx%d@%+d%+d",
2619 _gdk_win32_window_pos_bits_to_string (windowpos->flags),
2620 (windowpos->hwndInsertAfter == HWND_BOTTOM ? "BOTTOM" :
2621 (windowpos->hwndInsertAfter == HWND_NOTOPMOST ? "NOTOPMOST" :
2622 (windowpos->hwndInsertAfter == HWND_TOP ? "TOP" :
2623 (windowpos->hwndInsertAfter == HWND_TOPMOST ? "TOPMOST" :
2624 (sprintf (buf, "%p", windowpos->hwndInsertAfter),
2626 windowpos->cx, windowpos->cy, windowpos->x, windowpos->y));
2628 /* If position and size haven't changed, don't do anything */
2629 if (_modal_operation_in_progress &&
2630 (windowpos->flags & SWP_NOMOVE) &&
2631 (windowpos->flags & SWP_NOSIZE))
2634 /* Once we've entered the moving or sizing modal loop, we won't
2635 * return to the main loop until we're done sizing or moving.
2637 if (_modal_operation_in_progress &&
2638 GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
2639 !GDK_WINDOW_DESTROYED (window))
2641 if (((GdkWindowObject *) window)->event_mask & GDK_STRUCTURE_MASK)
2643 GDK_NOTE (EVENTS, g_print (" do magic"));
2644 if (((GdkWindowObject *) window)->resize_count > 1)
2645 ((GdkWindowObject *) window)->resize_count -= 1;
2647 handle_configure_event (msg, window);
2648 g_main_context_iteration (NULL, FALSE);
2650 /* Dispatch main loop - to realize resizes... */
2651 modal_timer_proc (msg->hwnd, msg->message, 0, msg->time);
2653 /* Claim as handled, so that WM_SIZE and WM_MOVE are avoided */
2661 GetWindowRect (GDK_WINDOW_HWND (window), &rect);
2662 drag = (RECT *) msg->lParam;
2663 GDK_NOTE (EVENTS, g_print (" %s curr:%s drag:%s",
2664 (msg->wParam == WMSZ_BOTTOM ? "BOTTOM" :
2665 (msg->wParam == WMSZ_BOTTOMLEFT ? "BOTTOMLEFT" :
2666 (msg->wParam == WMSZ_LEFT ? "LEFT" :
2667 (msg->wParam == WMSZ_TOPLEFT ? "TOPLEFT" :
2668 (msg->wParam == WMSZ_TOP ? "TOP" :
2669 (msg->wParam == WMSZ_TOPRIGHT ? "TOPRIGHT" :
2670 (msg->wParam == WMSZ_RIGHT ? "RIGHT" :
2672 (msg->wParam == WMSZ_BOTTOMRIGHT ? "BOTTOMRIGHT" :
2674 _gdk_win32_rect_to_string (&rect),
2675 _gdk_win32_rect_to_string (drag)));
2677 impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
2679 if (impl->hint_flags & GDK_HINT_RESIZE_INC)
2681 GDK_NOTE (EVENTS, g_print (" (RESIZE_INC)"));
2682 if (impl->hint_flags & GDK_HINT_BASE_SIZE)
2684 /* Resize in increments relative to the base size */
2685 rect.left = rect.top = 0;
2686 rect.right = impl->hints.base_width;
2687 rect.bottom = impl->hints.base_height;
2688 _gdk_win32_adjust_client_rect (window, &rect);
2689 point.x = rect.left;
2691 ClientToScreen (GDK_WINDOW_HWND (window), &point);
2692 rect.left = point.x;
2694 point.x = rect.right;
2695 point.y = rect.bottom;
2696 ClientToScreen (GDK_WINDOW_HWND (window), &point);
2697 rect.right = point.x;
2698 rect.bottom = point.y;
2700 GDK_NOTE (EVENTS, g_print (" (also BASE_SIZE, using %s)",
2701 _gdk_win32_rect_to_string (&rect)));
2704 switch (msg->wParam)
2707 if (drag->bottom == rect.bottom)
2709 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2712 case WMSZ_BOTTOMLEFT:
2713 if (drag->bottom == rect.bottom && drag->left == rect.left)
2715 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2716 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2720 if (drag->left == rect.left)
2722 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2726 if (drag->top == rect.top && drag->left == rect.left)
2728 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2729 adjust_drag (&drag->left, rect.left, impl->hints.width_inc);
2733 if (drag->top == rect.top)
2735 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2739 if (drag->top == rect.top && drag->right == rect.right)
2741 adjust_drag (&drag->top, rect.top, impl->hints.height_inc);
2742 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2746 if (drag->right == rect.right)
2748 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2751 case WMSZ_BOTTOMRIGHT:
2752 if (drag->bottom == rect.bottom && drag->right == rect.right)
2754 adjust_drag (&drag->bottom, rect.bottom, impl->hints.height_inc);
2755 adjust_drag (&drag->right, rect.right, impl->hints.width_inc);
2759 if (drag->bottom != orig_drag.bottom || drag->left != orig_drag.left ||
2760 drag->top != orig_drag.top || drag->right != orig_drag.right)
2764 GDK_NOTE (EVENTS, g_print (" (handled RESIZE_INC: %s)",
2765 _gdk_win32_rect_to_string (drag)));
2769 /* WM_GETMINMAXINFO handles min_size and max_size hints? */
2771 if (impl->hint_flags & GDK_HINT_ASPECT)
2773 RECT decorated_rect;
2774 RECT undecorated_drag;
2775 int decoration_width, decoration_height;
2776 gdouble drag_aspect;
2777 int drag_width, drag_height, new_width, new_height;
2779 GetClientRect (GDK_WINDOW_HWND (window), &rect);
2780 decorated_rect = rect;
2781 _gdk_win32_adjust_client_rect (window, &decorated_rect);
2783 /* Set undecorated_drag to the client area being dragged
2784 * out, in screen coordinates.
2786 undecorated_drag = *drag;
2787 undecorated_drag.left -= decorated_rect.left - rect.left;
2788 undecorated_drag.right -= decorated_rect.right - rect.right;
2789 undecorated_drag.top -= decorated_rect.top - rect.top;
2790 undecorated_drag.bottom -= decorated_rect.bottom - rect.bottom;
2792 decoration_width = (decorated_rect.right - decorated_rect.left) - (rect.right - rect.left);
2793 decoration_height = (decorated_rect.bottom - decorated_rect.top) - (rect.bottom - rect.top);
2795 drag_width = undecorated_drag.right - undecorated_drag.left;
2796 drag_height = undecorated_drag.bottom - undecorated_drag.top;
2798 drag_aspect = (gdouble) drag_width / drag_height;
2800 GDK_NOTE (EVENTS, g_print (" (ASPECT:%g--%g curr: %g)",
2801 impl->hints.min_aspect, impl->hints.max_aspect, drag_aspect));
2803 if (drag_aspect < impl->hints.min_aspect)
2805 /* Aspect is getting too narrow */
2806 switch (msg->wParam)
2810 /* User drags top or bottom edge outward. Keep height, increase width. */
2811 new_width = impl->hints.min_aspect * drag_height;
2812 drag->left -= (new_width - drag_width) / 2;
2813 drag->right = drag->left + new_width + decoration_width;
2815 case WMSZ_BOTTOMLEFT:
2816 case WMSZ_BOTTOMRIGHT:
2817 /* User drags bottom-left or bottom-right corner down. Adjust height. */
2818 new_height = drag_width / impl->hints.min_aspect;
2819 drag->bottom = drag->top + new_height + decoration_height;
2823 /* User drags left or right edge inward. Decrease height */
2824 new_height = drag_width / impl->hints.min_aspect;
2825 drag->top += (drag_height - new_height) / 2;
2826 drag->bottom = drag->top + new_height + decoration_height;
2830 /* User drags top-left or top-right corner up. Adjust height. */
2831 new_height = drag_width / impl->hints.min_aspect;
2832 drag->top = drag->bottom - new_height - decoration_height;
2835 else if (drag_aspect > impl->hints.max_aspect)
2837 /* Aspect is getting too wide */
2838 switch (msg->wParam)
2842 /* User drags top or bottom edge inward. Decrease width. */
2843 new_width = impl->hints.max_aspect * drag_height;
2844 drag->left += (drag_width - new_width) / 2;
2845 drag->right = drag->left + new_width + decoration_width;
2847 case WMSZ_BOTTOMLEFT:
2849 /* User drags bottom-left or top-left corner left. Adjust width. */
2850 new_width = impl->hints.max_aspect * drag_height;
2851 drag->left = drag->right - new_width - decoration_width;
2853 case WMSZ_BOTTOMRIGHT:
2855 /* User drags bottom-right or top-right corner right. Adjust width. */
2856 new_width = impl->hints.max_aspect * drag_height;
2857 drag->right = drag->left + new_width + decoration_width;
2861 /* User drags left or right edge outward. Increase height. */
2862 new_height = drag_width / impl->hints.max_aspect;
2863 drag->top -= (new_height - drag_height) / 2;
2864 drag->bottom = drag->top + new_height + decoration_height;
2871 GDK_NOTE (EVENTS, g_print (" (handled ASPECT: %s)",
2872 _gdk_win32_rect_to_string (drag)));
2876 case WM_GETMINMAXINFO:
2877 if (GDK_WINDOW_DESTROYED (window))
2880 impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) window)->impl);
2881 mmi = (MINMAXINFO*) msg->lParam;
2882 GDK_NOTE (EVENTS, g_print (" (mintrack:%ldx%ld maxtrack:%ldx%ld "
2883 "maxpos:%+ld%+ld maxsize:%ldx%ld)",
2884 mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y,
2885 mmi->ptMaxTrackSize.x, mmi->ptMaxTrackSize.y,
2886 mmi->ptMaxPosition.x, mmi->ptMaxPosition.y,
2887 mmi->ptMaxSize.x, mmi->ptMaxSize.y));
2889 if (impl->hint_flags & GDK_HINT_MIN_SIZE)
2891 rect.left = rect.top = 0;
2892 rect.right = impl->hints.min_width;
2893 rect.bottom = impl->hints.min_height;
2895 _gdk_win32_adjust_client_rect (window, &rect);
2897 mmi->ptMinTrackSize.x = rect.right - rect.left;
2898 mmi->ptMinTrackSize.y = rect.bottom - rect.top;
2901 if (impl->hint_flags & GDK_HINT_MAX_SIZE)
2905 rect.left = rect.top = 0;
2906 rect.right = impl->hints.max_width;
2907 rect.bottom = impl->hints.max_height;
2909 _gdk_win32_adjust_client_rect (window, &rect);
2911 /* at least on win9x we have the 16 bit trouble */
2912 maxw = rect.right - rect.left;
2913 maxh = rect.bottom - rect.top;
2914 mmi->ptMaxTrackSize.x = maxw > 0 && maxw < G_MAXSHORT ? maxw : G_MAXSHORT;
2915 mmi->ptMaxTrackSize.y = maxh > 0 && maxh < G_MAXSHORT ? maxh : G_MAXSHORT;
2918 if (impl->hint_flags & (GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE))
2920 /* Don't call DefWindowProcW() */
2921 GDK_NOTE (EVENTS, g_print (" (handled, mintrack:%ldx%ld maxtrack:%ldx%ld "
2922 "maxpos:%+ld%+ld maxsize:%ldx%ld)",
2923 mmi->ptMinTrackSize.x, mmi->ptMinTrackSize.y,
2924 mmi->ptMaxTrackSize.x, mmi->ptMaxTrackSize.y,
2925 mmi->ptMaxPosition.x, mmi->ptMaxPosition.y,
2926 mmi->ptMaxSize.x, mmi->ptMaxSize.y));
2932 GDK_NOTE (EVENTS, g_print (" (%d,%d)",
2933 GET_X_LPARAM (msg->lParam), GET_Y_LPARAM (msg->lParam)));
2935 if (GDK_WINDOW_TYPE (window) != GDK_WINDOW_CHILD &&
2936 !IsIconic (msg->hwnd))
2938 if (!GDK_WINDOW_DESTROYED (window))
2939 handle_configure_event (msg, window);
2946 if (GDK_WINDOW_DESTROYED (window))
2949 event = gdk_event_new (GDK_DELETE);
2950 event->any.window = window;
2952 append_event (event);
2954 impl = GDK_WINDOW_IMPL_WIN32 (GDK_WINDOW_OBJECT (window)->impl);
2956 if (impl->transient_owner && GetForegroundWindow() == GDK_WINDOW_HWND (window))
2958 SetForegroundWindow (GDK_WINDOW_HWND (impl->transient_owner));
2965 if (pointer_grab != NULL)
2967 if (pointer_grab->window == window)
2968 gdk_pointer_ungrab (msg->time);
2971 if (keyboard_grab &&
2972 keyboard_grab->window == window)
2973 gdk_keyboard_ungrab (msg->time);
2975 if ((window != NULL) && (msg->hwnd != GetDesktopWindow ()))
2976 gdk_window_destroy_notify (window);
2978 if (window == NULL || GDK_WINDOW_DESTROYED (window))
2981 event = gdk_event_new (GDK_DESTROY);
2982 event->any.window = window;
2984 append_event (event);
2989 case WM_DISPLAYCHANGE:
2990 handle_display_change ();
2993 case WM_DESTROYCLIPBOARD:
2994 if (!_ignore_destroy_clipboard)
2996 event = gdk_event_new (GDK_SELECTION_CLEAR);
2997 event->selection.window = window;
2998 event->selection.selection = GDK_SELECTION_CLIPBOARD;
2999 event->selection.time = _gdk_win32_get_next_tick (msg->time);
3000 append_event (event);
3009 case WM_RENDERFORMAT:
3010 GDK_NOTE (EVENTS, g_print (" %s", _gdk_win32_cf_to_string (msg->wParam)));
3012 if (!(target = g_hash_table_lookup (_format_atom_table, GINT_TO_POINTER (msg->wParam))))
3014 GDK_NOTE (EVENTS, g_print (" (target not found)"));
3019 /* We need to render to clipboard immediately, don't call
3022 if (_gdk_event_func)
3024 event = gdk_event_new (GDK_SELECTION_REQUEST);
3025 event->selection.window = window;
3026 event->selection.send_event = FALSE;
3027 event->selection.selection = GDK_SELECTION_CLIPBOARD;
3028 event->selection.target = target;
3029 event->selection.property = _gdk_selection;
3030 event->selection.requestor = msg->hwnd;
3031 event->selection.time = msg->time;
3033 fixup_event (event);
3034 GDK_NOTE (EVENTS, g_print (" (calling gdk_event_func)"));
3035 GDK_NOTE (EVENTS, _gdk_win32_print_event (event));
3036 (*_gdk_event_func) (event, _gdk_event_data);
3037 gdk_event_free (event);
3039 /* Now the clipboard owner should have rendered */
3040 if (!_delayed_rendering_data)
3042 GDK_NOTE (EVENTS, g_print (" (no _delayed_rendering_data?)"));
3046 if (msg->wParam == CF_DIB)
3048 _delayed_rendering_data =
3049 _gdk_win32_selection_convert_to_dib (_delayed_rendering_data,
3051 if (!_delayed_rendering_data)
3053 g_warning ("Cannot convert to DIB from delayed rendered image");
3058 /* The requestor is holding the clipboard, no
3059 * OpenClipboard() is required/possible
3062 g_print (" SetClipboardData(%s,%p)",
3063 _gdk_win32_cf_to_string (msg->wParam),
3064 _delayed_rendering_data));
3066 API_CALL (SetClipboardData, (msg->wParam, _delayed_rendering_data));
3067 _delayed_rendering_data = NULL;
3073 GDK_NOTE (EVENTS, g_print (" %s%s %p",
3074 (LOWORD (msg->wParam) == WA_ACTIVE ? "ACTIVE" :
3075 (LOWORD (msg->wParam) == WA_CLICKACTIVE ? "CLICKACTIVE" :
3076 (LOWORD (msg->wParam) == WA_INACTIVE ? "INACTIVE" : "???"))),
3077 HIWORD (msg->wParam) ? " minimized" : "",
3078 (HWND) msg->lParam));
3079 /* We handle mouse clicks for modally-blocked windows under WM_MOUSEACTIVATE,
3080 * but we still need to deal with alt-tab, or with SetActiveWindow() type
3083 if (is_modally_blocked (window) && LOWORD (msg->wParam) == WA_ACTIVE)
3085 GdkWindow *modal_current = _gdk_modal_current ();
3086 SetActiveWindow (GDK_WINDOW_HWND (modal_current));
3092 /* Bring any tablet contexts to the top of the overlap order when
3093 * one of our windows is activated.
3094 * NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP
3097 if (LOWORD(msg->wParam) != WA_INACTIVE)
3098 _gdk_input_set_tablet_active ();
3101 case WM_ACTIVATEAPP:
3102 GDK_NOTE (EVENTS, g_print (" %s thread: %I64d",
3103 msg->wParam ? "YES" : "NO",
3104 (gint64) msg->lParam));
3105 if (msg->wParam && GDK_WINDOW_IS_MAPPED (window))
3106 ensure_stacking_on_activate_app (msg, window);
3109 /* Handle WINTAB events here, as we know that gdkinput.c will
3110 * use the fixed WT_DEFBASE as lcMsgBase, and we thus can use the
3111 * constants as case labels.
3114 GDK_NOTE (EVENTS, g_print (" %d %p",
3115 (int) msg->wParam, (gpointer) msg->lParam));
3119 GDK_NOTE (EVENTS, g_print (" %d %p",
3120 (int) msg->wParam, (gpointer) msg->lParam));
3124 GDK_NOTE (EVENTS, g_print (" %p %d %d",
3125 (gpointer) msg->wParam,
3126 LOWORD (msg->lParam),
3127 HIWORD (msg->lParam)));
3131 event = gdk_event_new (GDK_NOTHING);
3132 event->any.window = window;
3133 g_object_ref (window);
3135 if (_gdk_input_other_event (event, msg, window))
3136 append_event (event);
3138 gdk_event_free (event);
3146 g_object_unref (window);
3153 _gdk_events_queue (GdkDisplay *display)
3157 if (modal_win32_dialog != NULL)
3160 while (!_gdk_event_queue_find_first (display) &&
3161 PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3163 TranslateMessage (&msg);
3164 DispatchMessageW (&msg);
3169 gdk_event_prepare (GSource *source,
3175 GDK_THREADS_ENTER ();
3179 retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
3180 (modal_win32_dialog == NULL &&
3181 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
3183 GDK_THREADS_LEAVE ();
3189 gdk_event_check (GSource *source)
3194 GDK_THREADS_ENTER ();
3196 if (event_poll_fd.revents & G_IO_IN)
3198 retval = (_gdk_event_queue_find_first (_gdk_display) != NULL ||
3199 (modal_win32_dialog == NULL &&
3200 PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE)));
3207 GDK_THREADS_LEAVE ();
3213 gdk_event_dispatch (GSource *source,
3214 GSourceFunc callback,
3219 GDK_THREADS_ENTER ();
3221 _gdk_events_queue (_gdk_display);
3222 event = _gdk_event_unqueue (_gdk_display);
3226 if (_gdk_event_func)
3227 (*_gdk_event_func) (event, _gdk_event_data);
3229 gdk_event_free (event);
3231 /* Do drag & drop if it is still pending */
3232 if (_dnd_source_state == GDK_WIN32_DND_PENDING)
3234 _dnd_source_state = GDK_WIN32_DND_DRAGGING;
3235 _gdk_win32_dnd_do_dragdrop ();
3236 _dnd_source_state = GDK_WIN32_DND_NONE;
3240 GDK_THREADS_LEAVE ();
3246 gdk_win32_set_modal_dialog_libgtk_only (HWND window)
3248 modal_win32_dialog = window;
3252 is_modally_blocked (GdkWindow *window)
3254 GdkWindow *modal_current = _gdk_modal_current ();
3255 return modal_current != NULL ? gdk_window_get_toplevel (window) != modal_current : FALSE;
3259 check_for_too_much_data (GdkEvent *event)
3261 if (event->client.data.l[1] ||
3262 event->client.data.l[2] ||
3263 event->client.data.l[3] ||
3264 event->client.data.l[4])
3266 g_warning ("Only four bytes of data are passed in client messages on Win32\n");
3271 gdk_event_send_client_message_for_display (GdkDisplay *display,
3273 GdkNativeWindow winid)
3275 check_for_too_much_data (event);
3277 return PostMessageW ((HWND) winid, client_message,
3278 (WPARAM) event->client.message_type,
3279 event->client.data.l[0]);
3283 gdk_screen_broadcast_client_message (GdkScreen *screen,
3286 check_for_too_much_data (event);
3288 PostMessageW (HWND_BROADCAST, client_message,
3289 (WPARAM) event->client.message_type,
3290 event->client.data.l[0]);
3299 /* Process all messages currently available */
3300 while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3302 TranslateMessage (&msg);
3303 DispatchMessageW (&msg);
3311 gdk_display_sync (GdkDisplay * display)
3315 g_return_if_fail (display == _gdk_display);
3317 /* Process all messages currently available */
3318 while (PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE))
3319 DispatchMessageW (&msg);
3323 gdk_display_flush (GdkDisplay * display)
3325 g_return_if_fail (display == _gdk_display);
3331 gdk_net_wm_supports (GdkAtom property)
3337 _gdk_windowing_event_data_copy (const GdkEvent *src,
3343 _gdk_windowing_event_data_free (GdkEvent *event)