From bde5281ae811179b11e8344c8312e58698e658cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Tue, 15 Mar 2016 16:10:34 +0000 Subject: [PATCH] GDK W32: Use a dumb window class for decorative windows Currently only one kind of decorative window is in use - the shape indicator that is shown when snapping windows to the edge of the screen. When normal toplevel class is used, its window procedure expects certain motions from GDK (passing user data to CreateWindowEx(), registering handle in a hash map etc), and might crash if that is not done. Dumb window doesn't require anything, it can just be. https://bugzilla.gnome.org/show_bug.cgi?id=763013 --- gdk/win32/gdkwindow-win32.c | 43 ++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c index 50814cbf53..e6601a85c5 100644 --- a/gdk/win32/gdkwindow-win32.c +++ b/gdk/win32/gdkwindow-win32.c @@ -3546,6 +3546,47 @@ apply_snap (GdkWindow *window, } } +/* Registers a dumb window class. This window + * has DefWindowProc() for a window procedure and + * does not do anything that GdkWindow-bound HWNDs do. + */ +static ATOM +RegisterGdkDumbClass () +{ + static ATOM klassDUMB = 0; + static WNDCLASSEXW wcl; + ATOM klass = 0; + + wcl.cbSize = sizeof (WNDCLASSEX); + wcl.style = 0; /* DON'T set CS_REDRAW. It causes total redraw + * on WM_SIZE and WM_MOVE. Flicker, Performance! + */ + wcl.lpfnWndProc = DefWindowProcW; + wcl.cbClsExtra = 0; + wcl.cbWndExtra = 0; + wcl.hInstance = _gdk_app_hmodule; + wcl.hIcon = 0; + wcl.hIconSm = 0; + wcl.lpszMenuName = NULL; + wcl.hbrBackground = NULL; + wcl.hCursor = LoadCursor (NULL, IDC_ARROW); + wcl.style |= CS_OWNDC; + wcl.lpszClassName = L"gdkWindowDumb"; + + if (klassDUMB == 0) + klassDUMB = RegisterClassExW (&wcl); + + klass = klassDUMB; + + if (klass == 0) + { + WIN32_API_FAILED ("RegisterClassExW"); + g_error ("That is a fatal error"); + } + + return klass; +} + static gboolean ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context) { @@ -3553,7 +3594,7 @@ ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context) { HWND handle; ATOM klass; - klass = RegisterGdkClass (GDK_WINDOW_TOPLEVEL, GDK_WINDOW_TYPE_HINT_SPLASHSCREEN); + klass = RegisterGdkDumbClass (); handle = CreateWindowExW (WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_NOACTIVATE, MAKEINTRESOURCEW (klass),