Port to gdk_display_get_root_window

This is the replacement for the GdkScreen api of the same name.
This commit is contained in:
Matthias Clasen 2017-10-31 21:22:57 -04:00
parent 68a61e9ac6
commit 463fba18a6
22 changed files with 46 additions and 73 deletions

View File

@ -333,12 +333,10 @@ gdk_broadway_device_window_at_position (GdkDevice *device,
GdkModifierType *mask,
gboolean get_toplevel)
{
GdkScreen *screen;
GdkWindow *root_window;
GdkWindow *window;
screen = gdk_display_get_default_screen (gdk_device_get_display (device));
root_window = gdk_screen_get_root_window (screen);
root_window = gdk_display_get_root_window (gdk_device_get_display (device));
gdk_broadway_device_query_state (device, root_window, &window, NULL, NULL, win_x, win_y, mask);

View File

@ -351,7 +351,7 @@ _gdk_broadway_events_got_input (BroadwayInputMsg *message)
case BROADWAY_EVENT_SCREEN_SIZE_CHANGED:
screen = gdk_display_get_default_screen (display);
window = gdk_screen_get_root_window (screen);
window = gdk_display_get_root_window (display);
window->width = message->screen_resize_notify.width;
window->height = message->screen_resize_notify.height;

View File

@ -2250,6 +2250,12 @@ gdk_display_setting_changed (GdkDisplay *display,
g_signal_emit (display, signals[SETTING_CHANGED], 0, name);
}
GdkWindow *
gdk_display_get_root_window (GdkDisplay *display)
{
return GDK_DISPLAY_GET_CLASS (display)->get_root_window (display);
}
GList *
gdk_display_get_toplevel_windows (GdkDisplay *display)
{
@ -2257,7 +2263,7 @@ gdk_display_get_toplevel_windows (GdkDisplay *display)
GList *new_list = NULL;
GList *tmp_list;
root_window = GDK_DISPLAY_GET_CLASS (display)->get_root_window (display);
root_window = gdk_display_get_root_window (display);
tmp_list = root_window->children;
while (tmp_list)

View File

@ -308,6 +308,7 @@ void gdk_display_emit_opened (GdkDisplay *display
void gdk_display_setting_changed (GdkDisplay *display,
const char *name);
GdkWindow * gdk_display_get_root_window (GdkDisplay *display);
GList * gdk_display_get_toplevel_windows (GdkDisplay *display);
G_END_DECLS

View File

@ -983,7 +983,7 @@ gdk_window_new (GdkDisplay *display,
g_return_val_if_fail (attributes != NULL, NULL);
if (!parent)
parent = gdk_screen_get_root_window (gdk_display_get_default_screen (display));
parent = gdk_display_get_root_window (display);
g_return_val_if_fail (GDK_IS_WINDOW (parent), NULL);
@ -3378,7 +3378,7 @@ gdk_window_get_device_position (GdkWindow *window,
GdkWindow *
gdk_get_default_root_window (void)
{
return gdk_screen_get_root_window (gdk_screen_get_default ());
return gdk_display_get_root_window (gdk_display_get_default ());
}
@ -4581,7 +4581,7 @@ gdk_window_get_geometry (GdkWindow *window,
GdkWindowImplClass *impl_class;
if (!window)
window = gdk_screen_get_root_window ((gdk_screen_get_default ()));
window = gdk_display_get_root_window ((gdk_display_get_default ()));
g_return_if_fail (GDK_IS_WINDOW (window));
@ -6162,17 +6162,11 @@ gdk_window_create_similar_image_surface (GdkWindow * window,
{
GdkWindowImplClass *impl_class;
cairo_surface_t *window_surface, *surface;
GdkDisplay *display;
GdkScreen *screen;
g_return_val_if_fail (window ==NULL || GDK_IS_WINDOW (window), NULL);
if (window == NULL)
{
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
window = gdk_screen_get_root_window (screen);
}
window = gdk_display_get_root_window (gdk_display_get_default ());
impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);

View File

@ -3814,9 +3814,7 @@ gdk_wayland_window_new_subsurface (GdkDisplay *display,
attr.height = position->height;
attr.window_type = GDK_WINDOW_SUBSURFACE;
return gdk_window_new (display,
gdk_screen_get_root_window (gdk_display_get_default_screen (display)),
&attr);
return gdk_window_new (display, gdk_display_get_root_window (display), &attr);
}
/**

View File

@ -222,7 +222,7 @@ _gdk_device_wintab_translate_axes (GdkDeviceWintab *device_wintab,
gint i;
device = GDK_DEVICE (device_wintab);
root_window = gdk_screen_get_root_window (gdk_window_get_screen (window));
root_window = gdk_display_get_root_window (gdk_window_get_display (window));
impl_window = _gdk_window_get_impl_window (window);
temp_x = temp_y = 0;

View File

@ -353,7 +353,7 @@ static void
wintab_init_check (GdkDeviceManagerWin32 *device_manager)
{
GdkDisplay *display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager));
GdkWindow *root = gdk_screen_get_root_window (gdk_display_get_default_screen (display));
GdkWindow *root = gdk_display_get_root_window (display);
static gboolean wintab_initialized = FALSE;
GdkDeviceWintab *device;
WORD specversion;

View File

@ -2169,7 +2169,7 @@ gdk_event_translate (MSG *msg,
{
/* Apply global filters */
GdkFilterReturn result = apply_event_filters (window ? window : gdk_screen_get_root_window (gdk_display_get_default_screen (display)),
GdkFilterReturn result = apply_event_filters (window ? window : gdk_display_get_root_window (display),
msg,
&_gdk_default_filters);

View File

@ -294,12 +294,7 @@ _gdk_win32_window_delete_property (GdkWindow *window,
if (property == _gdk_selection)
_gdk_selection_property_delete (window);
else if (property == _wm_transient_for)
{
GdkScreen *screen;
screen = gdk_window_get_screen (window);
gdk_window_set_transient_for (window, gdk_screen_get_root_window (screen));
}
gdk_window_set_transient_for (window, gdk_display_get_root_window (gdk_window_get_display (window)));
else
{
prop_name = gdk_atom_name (property);

View File

@ -486,7 +486,7 @@ _gdk_win32_window_enable_transparency (GdkWindow *window)
if (!gdk_display_is_composited (gdk_window_get_display (window)))
return FALSE;
if (window == gdk_screen_get_root_window (screen))
if (window == gdk_display_get_root_window (gdk_window_get_display (window)))
return FALSE;
thiswindow = GDK_WINDOW_HWND (window);

View File

@ -208,15 +208,13 @@ gdk_x11_cursor_init (GdkX11Cursor *cursor)
static Cursor
get_blank_cursor (GdkDisplay *display)
{
GdkScreen *screen;
Pixmap pixmap;
XColor color;
Cursor cursor;
cairo_surface_t *surface;
cairo_t *cr;
screen = gdk_display_get_default_screen (display);
surface = _gdk_x11_window_create_bitmap_surface (gdk_screen_get_root_window (screen), 1, 1);
surface = _gdk_x11_window_create_bitmap_surface (gdk_display_get_root_window (display), 1, 1);
/* Clear surface */
cr = cairo_create (surface);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
@ -845,9 +843,7 @@ _gdk_x11_display_get_cursor_for_surface (GdkDisplay *display,
g_object_unref (pixbuf);
screen = gdk_display_get_default_screen (display);
pixmap = _gdk_x11_window_create_bitmap_surface (gdk_screen_get_root_window (screen),
pixmap = _gdk_x11_window_create_bitmap_surface (gdk_display_get_root_window (display),
width, height);
cr = cairo_create (pixmap);
image = cairo_image_surface_create_for_data (data, CAIRO_FORMAT_A1,
@ -858,7 +854,7 @@ _gdk_x11_display_get_cursor_for_surface (GdkDisplay *display,
cairo_paint (cr);
cairo_destroy (cr);
mask = _gdk_x11_window_create_bitmap_surface (gdk_screen_get_root_window (screen),
mask = _gdk_x11_window_create_bitmap_surface (gdk_display_get_root_window (display),
width, height);
cr = cairo_create (mask);
image = cairo_image_surface_create_for_data (mask_data, CAIRO_FORMAT_A1,
@ -920,13 +916,11 @@ _gdk_x11_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
GdkScreen *screen;
GdkWindow *window;
g_return_if_fail (GDK_IS_DISPLAY (display));
screen = gdk_display_get_default_screen (display);
window = gdk_screen_get_root_window (screen);
window = gdk_display_get_root_window (display);
XQueryBestCursor (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XID (window),
128, 128, width, height);

View File

@ -239,7 +239,7 @@ gdk_x11_device_core_warp (GdkDevice *device,
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_device_get_display (device));
screen = gdk_display_get_default_screen (gdk_device_get_display (device));
dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
dest = GDK_WINDOW_XID (gdk_display_get_root_window (gdk_device_get_display (device)));
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0,
round (x * GDK_X11_SCREEN (screen)->window_scale),
@ -266,7 +266,7 @@ gdk_x11_device_core_query_state (GdkDevice *device,
display = gdk_device_get_display (device);
default_screen = gdk_display_get_default_screen (display);
if (window == NULL)
window = gdk_screen_get_root_window (default_screen);
window = gdk_display_get_root_window (display);
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (!GDK_X11_DISPLAY (display)->trusted_client ||

View File

@ -244,7 +244,7 @@ gdk_x11_device_xi2_get_state (GdkDevice *device,
GdkWindow *root_window;
gint root_x, root_y;
root_window = gdk_screen_get_root_window (gdk_display_get_default_screen (gdk_window_get_display (window)));
root_window = gdk_display_get_root_window (gdk_window_get_display (window));
/* FIXME: Maybe root coords chaching should happen here */
gdk_window_get_origin (window, &root_x, &root_y);
_gdk_device_translate_screen_coord (device, window,
@ -306,7 +306,7 @@ gdk_x11_device_xi2_warp (GdkDevice *device,
Window dest;
GdkScreen *screen = gdk_screen_get_default ();
dest = GDK_WINDOW_XID (gdk_screen_get_root_window (screen));
dest = GDK_WINDOW_XID (gdk_display_get_root_window (gdk_device_get_display (device)));
XIWarpPointer (GDK_SCREEN_XDISPLAY (screen),
device_xi2->device_id,
@ -339,7 +339,7 @@ gdk_x11_device_xi2_query_state (GdkDevice *device,
display = gdk_device_get_display (device);
default_screen = gdk_display_get_default_screen (display);
if (window == NULL)
window = gdk_screen_get_root_window (default_screen);
window = gdk_display_get_root_window (display);
impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_SLAVE)

View File

@ -679,7 +679,6 @@ gdk_x11_device_manager_xi2_constructed (GObject *object)
{
GdkX11DeviceManagerXI2 *device_manager;
GdkDisplay *display;
GdkScreen *screen;
GHashTable *masters, *slaves;
Display *xdisplay;
XIDeviceInfo *info, *dev;
@ -736,7 +735,6 @@ gdk_x11_device_manager_xi2_constructed (GObject *object)
g_hash_table_destroy (slaves);
/* Connect to hierarchy change events */
screen = gdk_display_get_default_screen (display);
XISetMask (mask, XI_HierarchyChanged);
XISetMask (mask, XI_DeviceChanged);
XISetMask (mask, XI_PropertyEvent);
@ -746,7 +744,7 @@ gdk_x11_device_manager_xi2_constructed (GObject *object)
event_mask.mask = mask;
_gdk_x11_device_manager_xi2_select_events (GDK_DEVICE_MANAGER (object),
GDK_WINDOW_XID (gdk_screen_get_root_window (screen)),
GDK_WINDOW_XID (gdk_display_get_root_window (display)),
&event_mask);
}

View File

@ -2236,8 +2236,7 @@ broadcast_xmessage (GdkDisplay *display,
const char *message)
{
Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
GdkScreen *screen = gdk_display_get_default_screen (display);
GdkWindow *root_window = gdk_screen_get_root_window (screen);
GdkWindow *root_window = gdk_display_get_root_window (display);
Window xroot_window = GDK_WINDOW_XID (root_window);
Atom type_atom;

View File

@ -564,7 +564,7 @@ gdk_window_cache_new (GdkDisplay *display)
XWindowAttributes xwa;
GdkScreen *screen = gdk_display_get_default_screen (display);
Display *xdisplay = GDK_SCREEN_XDISPLAY (screen);
GdkWindow *root_window = gdk_screen_get_root_window (screen);
GdkWindow *root_window = gdk_display_get_root_window (display);
GdkChildInfoX11 *children;
guint nchildren, i;
#ifdef HAVE_XCOMPOSITE
@ -649,7 +649,7 @@ gdk_window_cache_new (GdkDisplay *display)
static void
gdk_window_cache_destroy (GdkWindowCache *cache)
{
GdkWindow *root_window = gdk_screen_get_root_window (gdk_display_get_default_screen (cache->display));
GdkWindow *root_window = gdk_display_get_root_window (cache->display);
XSelectInput (GDK_WINDOW_XDISPLAY (root_window),
GDK_WINDOW_XID (root_window),
@ -858,7 +858,7 @@ get_client_window_at_coords (GdkWindowCache *cache,
if (retval)
return retval;
else
return GDK_WINDOW_XID (gdk_screen_get_root_window (gdk_display_get_default_screen (cache->display)));
return GDK_WINDOW_XID (gdk_display_get_root_window (cache->display));
}
#ifdef G_ENABLE_DEBUG
@ -2678,7 +2678,7 @@ drag_context_grab (GdkDragContext *context)
if (!x11_context->ipc_window)
return FALSE;
root = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (x11_context->ipc_window));
root = gdk_display_get_root_window (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
seat = gdk_device_get_seat (gdk_drag_context_get_device (context));
#ifdef XINPUT_2
@ -2767,7 +2767,7 @@ drag_context_ungrab (GdkDragContext *context)
gdk_seat_ungrab (x11_context->grab_seat);
keyboard = gdk_seat_get_keyboard (x11_context->grab_seat);
root = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (x11_context->ipc_window));
root = gdk_display_get_root_window (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
g_clear_object (&x11_context->grab_seat);
for (i = 0; i < G_N_ELEMENTS (grab_keys); ++i)
@ -3030,7 +3030,7 @@ gdk_dnd_handle_key_event (GdkDragContext *context,
* to query it here. We could use XGetModifierMapping, but
* that would be overkill.
*/
root_window = gdk_screen_get_root_window (GDK_WINDOW_SCREEN (x11_context->ipc_window));
root_window = gdk_display_get_root_window (GDK_WINDOW_DISPLAY (x11_context->ipc_window));
gdk_window_get_device_position (root_window, pointer, NULL, NULL, &state);
if (dx != 0 || dy != 0)

View File

@ -22,6 +22,7 @@
#include "gdkmonitor-x11.h"
#include "gdkscreen-x11.h"
#include "gdkdisplayprivate.h"
G_DEFINE_TYPE (GdkX11Monitor, gdk_x11_monitor, GDK_TYPE_MONITOR)

View File

@ -379,10 +379,7 @@ _gdk_x11_window_get_property (GdkWindow *window,
g_return_val_if_fail (!window || GDK_WINDOW_IS_X11 (window), FALSE);
if (!window)
{
GdkScreen *screen = gdk_screen_get_default ();
window = gdk_screen_get_root_window (screen);
}
window = gdk_display_get_root_window (gdk_display_get_default ());
else if (!GDK_WINDOW_IS_X11 (window))
return FALSE;
@ -513,12 +510,7 @@ _gdk_x11_window_change_property (GdkWindow *window,
g_return_if_fail (!window || GDK_WINDOW_IS_X11 (window));
if (!window)
{
GdkScreen *screen;
screen = gdk_screen_get_default ();
window = gdk_screen_get_root_window (screen);
}
window = gdk_display_get_root_window (gdk_display_get_default ());
else if (!GDK_WINDOW_IS_X11 (window))
return;
@ -568,10 +560,7 @@ _gdk_x11_window_delete_property (GdkWindow *window,
g_return_if_fail (!window || GDK_WINDOW_IS_X11 (window));
if (!window)
{
GdkScreen *screen = gdk_screen_get_default ();
window = gdk_screen_get_root_window (screen);
}
window = gdk_display_get_root_window (gdk_display_get_default ());
else if (!GDK_WINDOW_IS_X11 (window))
return;

View File

@ -223,7 +223,7 @@ gdk_x11_screen_get_work_area (GdkScreen *screen,
display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
disp_screen = GDK_SCREEN_XNUMBER (screen);
root_window = gdk_screen_get_root_window (screen);
root_window = gdk_display_get_root_window (gdk_screen_get_display (screen));
workarea = XInternAtom (display, "_NET_WORKAREA", True);
/* Defaults in case of error */
@ -923,7 +923,7 @@ _gdk_x11_screen_get_edge_monitors (GdkScreen *screen,
{
#ifdef HAVE_XFREE_XINERAMA
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
GdkWindow *root_window = gdk_screen_get_root_window (screen);
GdkWindow *root_window = gdk_display_get_root_window (gdk_screen_get_display (screen));
gint top_most_pos = gdk_window_get_height (root_window);
gint left_most_pos = gdk_window_get_width (root_window);
gint bottom_most_pos = 0;

View File

@ -1136,7 +1136,7 @@ gdk_x11_window_foreign_new_for_display (GdkDisplay *display,
impl->window_scale = GDK_X11_SCREEN (screen)->window_scale;
/* Always treat foreigns as toplevels */
win->parent = gdk_screen_get_root_window (screen);
win->parent = gdk_display_get_root_window (display);
win->parent->children = g_list_concat (&win->children_list_node, win->parent->children);

View File

@ -572,7 +572,7 @@ gdk_xsettings_manager_window_filter (GdkXEvent *xevent,
void
_gdk_x11_xsettings_init (GdkX11Screen *x11_screen)
{
gdk_window_add_filter (gdk_screen_get_root_window (GDK_SCREEN (x11_screen)), gdk_xsettings_root_window_filter, x11_screen);
gdk_window_add_filter (gdk_display_get_root_window (x11_screen->display), gdk_xsettings_root_window_filter, x11_screen);
check_manager_window (x11_screen, FALSE);
}
@ -586,7 +586,7 @@ _gdk_x11_settings_force_reread (GdkX11Screen *x11_screen)
void
_gdk_x11_xsettings_finish (GdkX11Screen *x11_screen)
{
gdk_window_remove_filter (gdk_screen_get_root_window (GDK_SCREEN (x11_screen)), gdk_xsettings_root_window_filter, x11_screen);
gdk_window_remove_filter (gdk_display_get_root_window (x11_screen->display), gdk_xsettings_root_window_filter, x11_screen);
if (x11_screen->xsettings_manager_window)
{
gdk_window_remove_filter (x11_screen->xsettings_manager_window, gdk_xsettings_manager_window_filter, x11_screen);