wclass.lpszClassName = "GdkClipboardNotification";
wclass.lpfnWndProc = _clipboard_window_procedure;
- wclass.hInstance = _gdk_dll_hinstance;
+ wclass.hInstance = this_module ();
wclass.cbWndExtra = sizeof (GdkWin32ClipboardThread *);
klass = RegisterClass (&wclass);
clipboard_thread_data->clipboard_window = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
- _gdk_dll_hinstance, NULL);
+ this_module (), NULL);
if (clipboard_thread_data->clipboard_window == NULL)
goto failed;
failed:
g_critical ("Failed to install clipboard viewer");
- UnregisterClass (MAKEINTRESOURCE (klass), _gdk_dll_hinstance);
+ UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
return FALSE;
}
#undef SET_BIT
#undef RESET_BIT
- rv = CreateCursor (_gdk_app_hmodule, cursors[i].hotx, cursors[i].hoty,
+ rv = CreateCursor (NULL, cursors[i].hotx, cursors[i].hoty,
w, h, and_plane, xor_plane);
}
else
{
- rv = CreateCursor (_gdk_app_hmodule, 0, 0,
- w, h, and_plane, xor_plane);
+ rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
}
if (rv == NULL)
break;
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_THIS:
result = gdk_win32_hcursor_new (display,
- LoadImageA (_gdk_app_hmodule,
+ LoadImageA (GetModuleHandle (NULL),
(const char *) cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
break;
case GDK_WIN32_CURSOR_LOAD_FROM_RESOURCE_GTK:
result = gdk_win32_hcursor_new (display,
- LoadImageA (_gdk_dll_hinstance,
+ LoadImageA (this_module (),
(const char *) cursor->resource_name,
IMAGE_CURSOR,
cursor->width,
xor_plane = g_malloc ((w/8) * h);
memset (xor_plane, 0, (w/8) * h);
- rv = CreateCursor (_gdk_app_hmodule, 0, 0,
- w, h, and_plane, xor_plane);
-
+ rv = CreateCursor (NULL, 0, 0, w, h, and_plane, xor_plane);
if (rv == NULL)
WIN32_API_FAILED ("CreateCursor");
gdk_win32hcursor_create_for_name (GdkWin32Display *display,
const char *name)
{
+ const HINSTANCE hinstance = GetModuleHandle (NULL);
GdkWin32HCursor *win32hcursor = NULL;
/* Blank cursor case */
/* Allow to load named cursor resources linked into the executable.
* Cursors obtained with LoadCursor() cannot be destroyed.
*/
- return gdk_win32_hcursor_new (display, LoadCursor (_gdk_app_hmodule, name), FALSE);
+ return gdk_win32_hcursor_new (display, LoadCursor (hinstance, name), FALSE);
}
static HICON
wclass.lpszClassName = "GdkDisplayChange";
wclass.lpfnWndProc = display_change_window_procedure;
- wclass.hInstance = _gdk_app_hmodule;
+ wclass.hInstance = this_module ();
wclass.style = CS_OWNDC;
klass = RegisterClass (&wclass);
display_win32->hwnd = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
- _gdk_app_hmodule, NULL);
+ this_module (), NULL);
if (!display_win32->hwnd)
{
- UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
+ UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
}
}
}
hook_handle = SetWindowsHookEx (WH_KEYBOARD_LL,
(HOOKPROC) low_level_keyboard_proc,
- _gdk_dll_hinstance,
- 0);
+ this_module (), 0);
if (hook_handle != NULL)
keyboard_hook = hook_handle;
wclass.lpszClassName = "GdkGLDummyWindow";
wclass.lpfnWndProc = DefWindowProc;
- wclass.hInstance = _gdk_app_hmodule;
+ wclass.hInstance = this_module ();
wclass.style = CS_OWNDC;
klass = RegisterClass (&wclass);
hwnd = CreateWindow (MAKEINTRESOURCE (klass),
NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL,
- _gdk_app_hmodule, NULL);
+ this_module (), NULL);
if (!hwnd)
{
- UnregisterClass (MAKEINTRESOURCE (klass), _gdk_app_hmodule);
+ UnregisterClass (MAKEINTRESOURCE (klass), this_module ());
}
}
GdkDeviceManagerWin32 *_gdk_device_manager = NULL;
HDC _gdk_display_hdc;
-HINSTANCE _gdk_dll_hinstance;
-HINSTANCE _gdk_app_hmodule;
int _gdk_input_ignore_core;
wndclassex.cbSize = sizeof (wndclassex);
wndclassex.lpszClassName = L"GdkWin32WinpointerNotificationsWindowClass";
wndclassex.lpfnWndProc = winpointer_notifications_window_procedure;
- wndclassex.hInstance = _gdk_dll_hinstance;
+ wndclassex.hInstance = this_module ();
if ((notifications_window_class = RegisterClassExW (&wndclassex)) == 0)
{
0, 0, 0, 0,
HWND_MESSAGE,
NULL,
- _gdk_dll_hinstance,
+ this_module (),
NULL)))
{
WIN32_API_FAILED ("CreateWindowExW");
if (gdk_synchronize)
GdiSetBatchLimit (1);
- _gdk_app_hmodule = GetModuleHandle (NULL);
_gdk_display_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
_gdk_input_locale = GetKeyboardLayout (0);
_gdk_win32_keymap_set_active_layout (win32_keymap, _gdk_input_locale);
extern GdkDeviceManagerWin32 *_gdk_device_manager;
extern HDC _gdk_display_hdc;
-extern HINSTANCE _gdk_dll_hinstance;
-extern HINSTANCE _gdk_app_hmodule;
extern int _gdk_input_ignore_core;
gpointer gdk_win32_handle_table_lookup_ (HWND handle);
+extern IMAGE_DOS_HEADER __ImageBase;
+
+static inline HMODULE
+this_module (void)
+{
+ return (HMODULE) &__ImageBase;
+}
+
wcl.lpfnWndProc = _gdk_win32_surface_procedure;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
- wcl.hInstance = _gdk_dll_hinstance;
+ wcl.hInstance = this_module ();
wcl.hIcon = 0;
wcl.hIconSm = 0;
if (0 == hAppIcon && 0 == hAppIconSm)
{
// fallback : load icon from GTK DLL
- if (0 != GetModuleFileName (_gdk_dll_hinstance, sLoc, MAX_PATH))
+ if (0 != GetModuleFileName (this_module (), sLoc, MAX_PATH))
{
ExtractIconEx (sLoc, 0, &hAppIcon, &hAppIconSm, 1);
}
CW_USEDEFAULT, CW_USEDEFAULT,
owner,
NULL,
- _gdk_dll_hinstance,
+ this_module (),
surface);
if (impl->handle == NULL)
{
wcl.lpfnWndProc = DefWindowProcW;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
- wcl.hInstance = _gdk_dll_hinstance;
+ wcl.hInstance = this_module ();
wcl.hIcon = 0;
wcl.hIconSm = 0;
wcl.lpszMenuName = NULL;
0, 0,
NULL,
NULL,
- _gdk_dll_hinstance,
+ this_module (),
NULL);
context->shape_indicator = handle;
#include "gdkprivate-win32.h"
#include "gdkwin32misc.h"
-extern HINSTANCE _gdk_dll_hinstance;
-
G_DEFINE_TYPE (GdkWin32VulkanContext, gdk_win32_vulkan_context, GDK_TYPE_VULKAN_CONTEXT)
static VkResult
info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
info.pNext = NULL;
info.flags = 0;
- info.hinstance = _gdk_dll_hinstance;
+ info.hinstance = this_module ();
info.hwnd = GDK_SURFACE_HWND (window);
/* This is necessary so that Vulkan sees the Window.
memset (&page, 0, sizeof (page));
page.dwSize = sizeof (page);
page.dwFlags = PSP_DLGINDIRECT | PSP_USETITLE | PSP_PREMATURE;
- page.hInstance = GetModuleHandle (NULL);
+ page.hInstance = NULL;
page.pResource = template;
tab_label = op->priv->custom_tab_label;
#include <commctrl.h>
#undef STRICT
+extern IMAGE_DOS_HEADER __ImageBase;
+
+static inline HMODULE
+this_module ()
+{
+ return (HMODULE) &__ImageBase;
+}
+
/* In practice, resulting DLL will have manifest resource under index 2.
* Fall back to that value if we can't find resource index programmatically.
*/
#define EMPIRIC_MANIFEST_RESOURCE_INDEX 2
-
-static HMODULE gtk_dll;
-extern HINSTANCE _gdk_dll_hinstance;
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved);
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved)
-{
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- gtk_dll = (HMODULE) hinstDLL;
- _gdk_dll_hinstance = hinstDLL;
- break;
- default:
- break;
- }
-
- return TRUE;
-}
-
static BOOL CALLBACK
find_first_manifest (HMODULE module_handle,
LPCSTR resource_type,
DWORD error_code;
resource_name = NULL;
- EnumResourceNames (gtk_dll, RT_MANIFEST, find_first_manifest,
+ EnumResourceNames (this_module (), RT_MANIFEST, find_first_manifest,
(LONG_PTR) &resource_name);
if (resource_name == NULL)
activation_ctx_descriptor.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID |
ACTCTX_FLAG_HMODULE_VALID |
ACTCTX_FLAG_SET_PROCESS_DEFAULT;
- activation_ctx_descriptor.hModule = gtk_dll;
+ activation_ctx_descriptor.hModule = this_module ();
activation_ctx_descriptor.lpResourceName = resource_name;
activation_ctx_handle = CreateActCtx (&activation_ctx_descriptor);
error_code = GetLastError ();
if (activation_ctx_handle == INVALID_HANDLE_VALUE &&
error_code != ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET)
g_warning ("Failed to CreateActCtx for module %p, resource %p: %lu",
- gtk_dll, resource_name, GetLastError ());
+ this_module (), resource_name, GetLastError ());
else if (error_code != ERROR_SXS_PROCESS_DEFAULT_ALREADY_SET)
{
activation_cookie = 0;
static char *gtk_libdir = NULL;
if (gtk_libdir == NULL)
{
- char *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
+ char *root = g_win32_get_package_installation_directory_of_module (this_module ());
char *slash = strrchr (root, '\\');
if (slash != NULL &&
g_ascii_strcasecmp (slash + 1, ".libs") == 0)
while (*--p != '/')
;
- root = g_win32_get_package_installation_directory_of_module (gtk_dll);
+ root = g_win32_get_package_installation_directory_of_module (this_module ());
temp = g_build_filename (root, p, NULL);
g_free (root);
static char *gtk_datadir = NULL;
if (gtk_datadir == NULL)
{
- char *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
+ char *root = g_win32_get_package_installation_directory_of_module (this_module ());
gtk_datadir = g_build_filename (root, "share", NULL);
g_free (root);
}
static char *gtk_sysconfdir = NULL;
if (gtk_sysconfdir == NULL)
{
- char *root = g_win32_get_package_installation_directory_of_module (gtk_dll);
+ char *root = g_win32_get_package_installation_directory_of_module (this_module ());
gtk_sysconfdir = g_build_filename (root, "etc", NULL);
g_free (root);
}
{
static char *gtk_data_prefix = NULL;
if (gtk_data_prefix == NULL)
- gtk_data_prefix = g_win32_get_package_installation_directory_of_module (gtk_dll);
+ gtk_data_prefix = g_win32_get_package_installation_directory_of_module (this_module ());
return gtk_data_prefix;
}