W32: Use correct hinstance values
authorРуслан Ижбулатов <lrn1986@gmail.com>
Sat, 16 Jun 2018 18:24:56 +0000 (18:24 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Sat, 16 Jun 2018 18:24:56 +0000 (18:24 +0000)
According to the old new thing[0], we should use the instance handle
of the GDK/GTK DLL when registering GDK-specific types in the system.
Using the instance handle for the whole application in these circumstances
is not an error, but can potentially clash with the types registered
by the application itself.

Also, extract window class icons from the GDK/GTK DLL, not from the
application executable.

[0]: https://blogs.msdn.microsoft.com/oldnewthing/20050418-59/?p=35873

gdk/win32/gdksurface-win32.c

index 8b3cfa15bd1aa97f04d9117fe44b4ab65d55812f..ce10a17055938fbe90c25091679984d0deead680 100644 (file)
@@ -401,7 +401,7 @@ RegisterGdkClass (GdkSurfaceType wtype, GdkSurfaceTypeHint wtype_hint)
   wcl.lpfnWndProc = _gdk_win32_surface_procedure;
   wcl.cbClsExtra = 0;
   wcl.cbWndExtra = 0;
-  wcl.hInstance = _gdk_app_hmodule;
+  wcl.hInstance = _gdk_dll_hinstance;
   wcl.hIcon = 0;
   wcl.hIconSm = 0;
 
@@ -410,7 +410,7 @@ RegisterGdkClass (GdkSurfaceType wtype, GdkSurfaceTypeHint wtype_hint)
     {
       gchar sLoc [MAX_PATH+1];
 
-      if (0 != GetModuleFileName (_gdk_app_hmodule, sLoc, MAX_PATH))
+      if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
         {
           ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
 
@@ -682,7 +682,7 @@ _gdk_win32_display_create_surface_impl (GdkDisplay    *display,
                             window_width, window_height,
                             hparent,
                             NULL,
-                            _gdk_app_hmodule,
+                            _gdk_dll_hinstance,
                             window);
   if (GDK_SURFACE_HWND (window) != hwndNew)
     {
@@ -3176,7 +3176,7 @@ RegisterGdkDumbClass ()
   wcl.lpfnWndProc = DefWindowProcW;
   wcl.cbClsExtra = 0;
   wcl.cbWndExtra = 0;
-  wcl.hInstance = _gdk_app_hmodule;
+  wcl.hInstance = _gdk_dll_hinstance;
   wcl.hIcon = 0;
   wcl.hIconSm = 0;
   wcl.lpszMenuName = NULL;
@@ -3217,7 +3217,7 @@ ensure_snap_indicator_exists (GdkW32DragMoveResizeContext *context)
                                 0, 0,
                                 NULL,
                                 NULL,
-                                _gdk_app_hmodule,
+                                _gdk_dll_hinstance,
                                 NULL);
 
       context->shape_indicator = handle;