[gtk+] win32: Remove all uses of get_root_window
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] win32: Remove all uses of get_root_window
- Date: Tue, 14 Nov 2017 23:16:28 +0000 (UTC)
commit e2682e62a819bc4244689adcea17673f874db421
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Nov 14 18:05:41 2017 -0500
win32: Remove all uses of get_root_window
This is following similar changes done in the x11 and
broadway backends, but it has not been built.
Some fixups may be needed.
gdk/win32/gdkdevice-win32.c | 42 +++++++++++++++------------
gdk/win32/gdkdevice-wintab.c | 42 +++++++++++++++++----------
gdk/win32/gdkdevicemanager-win32.c | 10 ++----
gdk/win32/gdkdisplay-win32.c | 8 +----
gdk/win32/gdkdnd-win32.c | 8 +----
gdk/win32/gdkevents-win32.c | 4 +--
gdk/win32/gdkproperty-win32.c | 2 +-
gdk/win32/gdkscreen-win32.c | 55 ++++++------------------------------
gdk/win32/gdkwindow-win32.c | 7 +----
9 files changed, 69 insertions(+), 109 deletions(-)
---
diff --git a/gdk/win32/gdkdevice-win32.c b/gdk/win32/gdkdevice-win32.c
index 10914e9..d0e9654 100644
--- a/gdk/win32/gdkdevice-win32.c
+++ b/gdk/win32/gdkdevice-win32.c
@@ -108,30 +108,39 @@ gdk_device_win32_query_state (GdkDevice *device,
{
POINT point;
HWND hwnd, hwndc;
- GdkWindowImplWin32 *impl;
+ gint scale;
- if (window == NULL)
- window = gdk_win32_display_get_root_window (gdk_display_get_default ());
- impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
+ if (window)
+ {
+ scale = GDK_WINDOW_IMPL_WIN32 (window->impl)->window_scale;
+ hwnd = GDK_WINDOW_HWND (window);
+ }
+ else
+ {
+ GdkDisplay *display = gdk_device_get_display (device);
+
+ scale = GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY (display)->screen)->window_scale;
+ hwnd = NULL;
+ }
- hwnd = GDK_WINDOW_HWND (window);
GetCursorPos (&point);
if (root_x)
- *root_x = point.x / impl->window_scale;
+ *root_x = point.x / scale;
if (root_y)
- *root_y = point.y / impl->window_scale;
+ *root_y = point.y / scale;
- ScreenToClient (hwnd, &point);
+ if (hwnd)
+ ScreenToClient (hwnd, &point);
if (win_x)
- *win_x = point.x / impl->window_scale;
+ *win_x = point.x / scale;
if (win_y)
- *win_y = point.y / impl->window_scale;
+ *win_y = point.y / scale;
- if (window == gdk_win32_display_get_root_window (gdk_display_get_default ()))
+ if (window)
{
if (win_x)
*win_x += _gdk_offset_x;
@@ -146,7 +155,7 @@ gdk_device_win32_query_state (GdkDevice *device,
*root_y += _gdk_offset_y;
}
- if (child_window)
+ if (hwnd && child_window)
{
hwndc = ChildWindowFromPoint (hwnd, point);
@@ -247,15 +256,12 @@ _gdk_device_win32_window_at_position (GdkDevice *device,
/* If we didn't hit any window at that point, return the desktop */
if (hwnd == NULL)
{
- window = gdk_win32_display_get_root_window (gdk_display_get_default ());
- impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
-
if (win_x)
- *win_x = (screen_pt.x + _gdk_offset_x) / impl->window_scale;
+ *win_x = screen_pt.x + _gdk_offset_x;
if (win_y)
- *win_y = (screen_pt.y + _gdk_offset_y) / impl->window_scale;
+ *win_y = screen_pt.y + _gdk_offset_y;
- return window;
+ return NULL;
}
window = gdk_win32_handle_table_lookup (hwnd);
diff --git a/gdk/win32/gdkdevice-wintab.c b/gdk/win32/gdkdevice-wintab.c
index 573f8da..8b5d321 100644
--- a/gdk/win32/gdkdevice-wintab.c
+++ b/gdk/win32/gdkdevice-wintab.c
@@ -120,30 +120,40 @@ gdk_device_wintab_query_state (GdkDevice *device,
POINT point;
HWND hwnd, hwndc;
GdkWindowImplWin32 *impl;
+ int scale;
device_wintab = GDK_DEVICE_WINTAB (device);
- if (window == NULL)
- window = gdk_win32_display_get_root_window (gdk_display_get_default ());
- impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
+ if (window)
+ {
+ scale = GDK_WINDOW_IMPL_WIN32 (window->impl)->window_scale;
+ hwnd = GDK_WINDOW_HWND (window);
+ }
+ else
+ {
+ GdkDisplay *display = gdk_device_get_display (device);
+
+ scale = GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY (display)->screen)->window_scale;
+ hwnd = NULL;
+ }
- hwnd = GDK_WINDOW_HWND (window);
GetCursorPos (&point);
if (root_x)
- *root_x = point.x / impl->window_scale;
+ *root_x = point.x / scale;
if (root_y)
- *root_y = point.y / impl->window_scale;
+ *root_y = point.y / scale;
- ScreenToClient (hwnd, &point);
+ if (hwn)
+ ScreenToClient (hwnd, &point);
if (win_x)
- *win_x = point.x / impl->window_scale;
+ *win_x = point.x / scale;
if (win_y)
- *win_y = point.y / impl->window_scale;
+ *win_y = point.y / scale;
- if (window == gdk_win32_display_get_root_window (gdk_display_get_default ()))
+ if (!window)
{
if (win_x)
*win_x += _gdk_offset_x;
@@ -152,7 +162,7 @@ gdk_device_wintab_query_state (GdkDevice *device,
*win_y += _gdk_offset_y;
}
- if (child_window)
+ if (hwnd && child_window)
{
hwndc = ChildWindowFromPoint (hwnd, point);
@@ -217,18 +227,20 @@ _gdk_device_wintab_translate_axes (GdkDeviceWintab *device_wintab,
gdouble *y)
{
GdkDevice *device;
- GdkWindow *impl_window, *root_window;
+ GdkWindow *impl_window;
gint root_x, root_y;
gdouble temp_x, temp_y;
gint i;
+ GdkDisplay *display;
device = GDK_DEVICE (device_wintab);
- root_window = gdk_win32_display_get_root_window (gdk_window_get_display (window));
impl_window = _gdk_window_get_impl_window (window);
temp_x = temp_y = 0;
gdk_window_get_origin (impl_window, &root_x, &root_y);
+ display = gdk_device_get_display (device);
+
for (i = 0; i < gdk_device_get_n_axes (device); i++)
{
GdkAxisUse use;
@@ -246,8 +258,8 @@ _gdk_device_wintab_translate_axes (GdkDeviceWintab *device_wintab,
else
_gdk_device_translate_screen_coord (device, window,
root_x, root_y,
- gdk_window_get_width (root_window),
- gdk_window_get_height (root_window),
+ GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY
(display)->screen)->width,
+ GDK_WIN32_SCREEN (GDK_WIN32_DISPLAY
(display)->screen)->height,
i,
device_wintab->last_axis_data[i],
&axes[i]);
diff --git a/gdk/win32/gdkdevicemanager-win32.c b/gdk/win32/gdkdevicemanager-win32.c
index fc05292..69a3da6 100644
--- a/gdk/win32/gdkdevicemanager-win32.c
+++ b/gdk/win32/gdkdevicemanager-win32.c
@@ -353,7 +353,6 @@ static void
wintab_init_check (GdkDeviceManagerWin32 *device_manager)
{
GdkDisplay *display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager));
- GdkWindow *root = gdk_win32_display_get_root_window (display);
static gboolean wintab_initialized = FALSE;
GdkDeviceWintab *device;
WORD specversion;
@@ -960,14 +959,13 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
device_manager = GDK_DEVICE_MANAGER_WIN32 (gdk_display_get_device_manager (display));
G_GNUC_END_IGNORE_DEPRECATIONS;
window = gdk_device_get_window_at_position (device_manager->core_pointer, &x, &y);
- if (window == NULL)
- window = gdk_win32_display_get_root_window (gdk_display_get_default ());
- g_object_ref (window);
+ if (window)
+ g_object_ref (window);
GDK_NOTE (EVENTS_OR_INPUT,
g_print ("gdk_input_other_event: window=%p %+d%+d\n",
- GDK_WINDOW_HWND (window), x, y));
+ window ? GDK_WINDOW_HWND (window) : NULL, x, y));
if (msg->message == WT_PACKET || msg->message == WT_CSRCHANGE)
{
@@ -1004,7 +1002,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS;
window = g_object_ref (last_grab->window);
}
- if (window == gdk_win32_display_get_root_window (gdk_display_get_default ()))
+ if (window == NULL)
{
GDK_NOTE (EVENTS_OR_INPUT, g_print ("... is root\n"));
return FALSE;
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index e37e0c5..04b2f77 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -619,7 +619,7 @@ inner_clipboard_window_procedure (HWND hwnd,
GDK_NOTE (DND, g_print (" \n"));
event = gdk_event_new (GDK_OWNER_CHANGE);
- event->owner_change.window = gdk_win32_display_get_root_window (gdk_display_get_default ());
+ event->owner_change.window = NULL;
event->owner_change.reason = GDK_OWNER_CHANGE_NEW_OWNER;
event->owner_change.selection = GDK_SELECTION_CLIPBOARD;
event->owner_change.time = _gdk_win32_get_next_tick (0);
@@ -1225,12 +1225,6 @@ gdk_win32_display_get_setting (GdkDisplay *display,
value);
}
-GdkWindow *
-gdk_win32_display_get_root_window (GdkDisplay *display)
-{
- return gdk_win32_screen_get_root_window (GDK_WIN32_DISPLAY (display)->screen);
-}
-
static void
gdk_win32_display_class_init (GdkWin32DisplayClass *klass)
{
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index 07c457f..3219df2 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -729,11 +729,6 @@ idropsource_givefeedback (LPDROPSOURCE This,
ctx->context->dest_window = NULL;
}
}
- else
- {
- if (ctx->context->dest_window == NULL)
- ctx->context->dest_window = g_object_ref (gdk_win32_display_get_root_window (gdk_display_get_default
()));
- }
return DRAGDROP_S_USEDEFAULTCURSORS;
}
@@ -1431,8 +1426,7 @@ gdk_dropfiles_filter (GdkXEvent *xev,
context->protocol = GDK_DRAG_PROTO_WIN32_DROPFILES;
context->is_source = FALSE;
- context->source_window = gdk_win32_display_get_root_window (gdk_display_get_default ());
- g_object_ref (context->source_window);
+ context->source_window = NULL;
context->dest_window = event->any.window;
g_object_ref (context->dest_window);
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 9e21c68..0df1805 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -2160,9 +2160,7 @@ gdk_event_translate (MSG *msg,
{
/* Apply global filters */
- GdkFilterReturn result = apply_event_filters (window ? window : gdk_win32_display_get_root_window
(display),
- msg,
- &_gdk_default_filters);
+ GdkFilterReturn result = apply_event_filters (window, msg, &_gdk_default_filters);
/* If result is GDK_FILTER_CONTINUE, we continue as if nothing
* happened. If it is GDK_FILTER_REMOVE or GDK_FILTER_TRANSLATE,
diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c
index 29e8fe5..24e778d 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -295,7 +295,7 @@ _gdk_win32_window_delete_property (GdkWindow *window,
if (property == _gdk_selection)
_gdk_selection_property_delete (window);
else if (property == _wm_transient_for)
- gdk_window_set_transient_for (window, gdk_win32_display_get_root_window (gdk_window_get_display
(window)));
+ gdk_window_set_transient_for (window, NULL);
else
{
prop_name = gdk_atom_name (property);
diff --git a/gdk/win32/gdkscreen-win32.c b/gdk/win32/gdkscreen-win32.c
index 0ce999c..546c367 100644
--- a/gdk/win32/gdkscreen-win32.c
+++ b/gdk/win32/gdkscreen-win32.c
@@ -33,7 +33,8 @@ struct _GdkWin32Screen
{
GdkScreen parent_instance;
- GdkWindow *root_window;
+ int width, height;
+ int window_scale;
};
struct _GdkWin32ScreenClass
@@ -66,61 +67,29 @@ init_root_window_size (GdkWin32Screen *screen)
gdk_rectangle_union (&result, &rect, &result);
}
- screen->root_window->width = result.width;
- screen->root_window->height = result.height;
- root_impl = GDK_WINDOW_IMPL_WIN32 (screen->root_window->impl);
-
- root_impl->unscaled_width = result.width * root_impl->window_scale;
- root_impl->unscaled_height = result.height * root_impl->window_scale;
+ screen->width = result.width;
+ screen->height = result.height;
}
static void
init_root_window (GdkWin32Screen *screen_win32)
{
GdkScreen *screen;
- GdkWindow *window;
- GdkWindowImplWin32 *impl_win32;
GdkWin32Display *win32_display;
screen = GDK_SCREEN (screen_win32);
- g_assert (screen_win32->root_window == NULL);
-
- window = _gdk_display_create_window (_gdk_display);
- window->impl = g_object_new (GDK_TYPE_WINDOW_IMPL_WIN32, NULL);
- impl_win32 = GDK_WINDOW_IMPL_WIN32 (window->impl);
- impl_win32->wrapper = window;
-
- window->impl_window = window;
-
- window->window_type = GDK_WINDOW_ROOT;
-
- screen_win32->root_window = window;
-
init_root_window_size (screen_win32);
- window->x = 0;
- window->y = 0;
- window->abs_x = 0;
- window->abs_y = 0;
- /* width and height already initialised in init_root_window_size() */
- window->viewable = TRUE;
win32_display = GDK_WIN32_DISPLAY (_gdk_display);
if (win32_display->dpi_aware_type != PROCESS_DPI_UNAWARE)
- impl_win32->window_scale = _gdk_win32_display_get_monitor_scale_factor (win32_display,
- NULL,
- impl_win32->handle,
- NULL);
+ screen_win32->window_scale = _gdk_win32_display_get_monitor_scale_factor (win32_display,
+ NULL,
+ NULL,
+ NULL);
else
- impl_win32->window_scale = 1;
-
- impl_win32->unscaled_width = window->width * impl_win32->window_scale;
- impl_win32->unscaled_height = window->height * impl_win32->window_scale;
-
- gdk_win32_handle_table_insert ((HANDLE *) &impl_win32->handle, window);
-
- GDK_NOTE (MISC, g_print ("screen->root_window=%p\n", window));
+ screen_win32->window_scale = 1;
}
static void
@@ -140,12 +109,6 @@ _gdk_win32_screen_on_displaychange_event (GdkWin32Screen *screen)
init_root_window_size (screen);
}
-GdkWindow *
-gdk_win32_screen_get_root_window (GdkScreen *screen)
-{
- return GDK_WIN32_SCREEN (screen)->root_window;
-}
-
static void
gdk_win32_screen_finalize (GObject *object)
{
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index bef238c..ae1f243 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -465,9 +465,6 @@ _gdk_win32_window_enable_transparency (GdkWindow *window)
if (!gdk_display_is_composited (gdk_window_get_display (window)))
return FALSE;
- if (window == gdk_win32_display_get_root_window (gdk_window_get_display (window)))
- return FALSE;
-
thiswindow = GDK_WINDOW_HWND (window);
/* Blurbehind only works on toplevel windows */
@@ -744,9 +741,7 @@ _gdk_win32_display_create_window_impl (GdkDisplay *display,
case GDK_WINDOW_TEMP:
/* A temp window is not necessarily a top level window */
- dwStyle = (real_parent == NULL ||
- gdk_win32_display_get_root_window (display) == real_parent) ?
- WS_POPUP : WS_CHILDWINDOW;
+ dwStyle = real_parent == NULL ? WS_POPUP : WS_CHILDWINDOW;
dwStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
dwExStyle |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST;
offset_x = _gdk_offset_x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]