[gtk+] GDK W32: Use a dumb window class for decorative windows



commit bde5281ae811179b11e8344c8312e58698e658cb
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Tue Mar 15 16:10:34 2016 +0000

    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 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 50814cb..e6601a8 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_<H,V>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),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]