summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gs-fade.c8
-rw-r--r--src/gs-grab-x11.c119
-rw-r--r--src/gs-grab.h16
-rw-r--r--src/gs-job.c12
-rw-r--r--src/gs-manager.c156
-rw-r--r--src/gs-visual-gl.c20
-rw-r--r--src/gs-visual-gl.h2
-rw-r--r--src/gs-window-x11.c178
-rw-r--r--src/gs-window.h24
-rw-r--r--src/mate-screensaver-gl-helper.c4
-rw-r--r--src/mate-screensaver-preferences.c38
-rw-r--r--src/test-window.c28
12 files changed, 371 insertions, 234 deletions
diff --git a/src/gs-fade.c b/src/gs-fade.c
index d775918..f949ee5 100644
--- a/src/gs-fade.c
+++ b/src/gs-fade.c
@@ -310,7 +310,7 @@ gamma_fade_setup (GSFade *fade)
res = XF86VidModeGetGammaRampSize (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- gdk_screen_get_number (gdk_screen_get_default ()),
+ GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
&screen_priv->info->size);
if (!res || screen_priv->info->size <= 0)
{
@@ -329,7 +329,7 @@ gamma_fade_setup (GSFade *fade)
}
res = XF86VidModeGetGammaRamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- gdk_screen_get_number (gdk_screen_get_default ()),
+ GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
screen_priv->info->size,
screen_priv->info->r,
screen_priv->info->g,
@@ -349,7 +349,7 @@ test_number:
/* only have gamma parameter, not ramps. */
res = XF86VidModeGetGamma (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
- gdk_screen_get_number (gdk_screen_get_default ()),
+ GDK_SCREEN_XNUMBER (gdk_screen_get_default ()),
&screen_priv->vmg);
if (! res)
{
@@ -406,7 +406,7 @@ gamma_fade_set_alpha_gamma (GSFade *fade,
gdouble alpha)
{
struct GSFadeScreenPrivate *screen_priv;
- int screen_idx = gdk_screen_get_number (gdk_screen_get_default ());
+ int screen_idx = GDK_SCREEN_XNUMBER (gdk_screen_get_default ());
screen_priv = &fade->priv->screen_priv;
xf86_whack_gamma (screen_idx, screen_priv, alpha);
diff --git a/src/gs-grab-x11.c b/src/gs-grab-x11.c
index 5163995..c2fba38 100644
--- a/src/gs-grab-x11.c
+++ b/src/gs-grab-x11.c
@@ -49,11 +49,11 @@ static gpointer grab_object = NULL;
struct GSGrabPrivate
{
- guint mouse_hide_cursor : 1;
- GdkWindow *mouse_grab_window;
- GdkWindow *keyboard_grab_window;
- GdkScreen *mouse_grab_screen;
- GdkScreen *keyboard_grab_screen;
+ guint mouse_hide_cursor : 1;
+ GdkWindow *mouse_grab_window;
+ GdkWindow *keyboard_grab_window;
+ GdkDisplay *mouse_grab_display;
+ GdkDisplay *keyboard_grab_display;
GtkWidget *invisible;
};
@@ -154,14 +154,14 @@ xorg_lock_smasher_set_active (GSGrab *grab,
#endif /* HAVE_XF86MISCSETGRABKEYSSTATE */
static int
-gs_grab_get_keyboard (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen)
+gs_grab_get_keyboard (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display)
{
GdkGrabStatus status;
g_return_val_if_fail (window != NULL, FALSE);
- g_return_val_if_fail (screen != NULL, FALSE);
+ g_return_val_if_fail (display != NULL, FALSE);
gs_debug ("Grabbing keyboard widget=%X", (guint32) GDK_WINDOW_XID (window));
status = gdk_keyboard_grab (window, FALSE, GDK_CURRENT_TIME);
@@ -178,7 +178,7 @@ gs_grab_get_keyboard (GSGrab *grab,
g_object_add_weak_pointer (G_OBJECT (grab->priv->keyboard_grab_window),
(gpointer *) &grab->priv->keyboard_grab_window);
- grab->priv->keyboard_grab_screen = screen;
+ grab->priv->keyboard_grab_display = display;
}
else
{
@@ -189,26 +189,18 @@ gs_grab_get_keyboard (GSGrab *grab,
}
static int
-gs_grab_get_mouse (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen,
- gboolean hide_cursor)
+gs_grab_get_mouse (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display,
+ gboolean hide_cursor)
{
GdkGrabStatus status;
-#if GTK_CHECK_VERSION (3, 16, 0)
- GdkDisplay *display;
-#endif
GdkCursor *cursor;
g_return_val_if_fail (window != NULL, FALSE);
- g_return_val_if_fail (screen != NULL, FALSE);
+ g_return_val_if_fail (display != NULL, FALSE);
-#if GTK_CHECK_VERSION (3, 16, 0)
- display = gdk_window_get_display (window);
cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
-#else
- cursor = gdk_cursor_new (GDK_BLANK_CURSOR);
-#endif
gs_debug ("Grabbing mouse widget=%X", (guint32) GDK_WINDOW_XID (window));
status = gdk_pointer_grab (window, TRUE, 0, NULL,
@@ -227,7 +219,7 @@ gs_grab_get_mouse (GSGrab *grab,
g_object_add_weak_pointer (G_OBJECT (grab->priv->mouse_grab_window),
(gpointer *) &grab->priv->mouse_grab_window);
- grab->priv->mouse_grab_screen = screen;
+ grab->priv->mouse_grab_display = display;
grab->priv->mouse_hide_cursor = hide_cursor;
}
@@ -245,7 +237,7 @@ gs_grab_keyboard_reset (GSGrab *grab)
(gpointer *) &grab->priv->keyboard_grab_window);
}
grab->priv->keyboard_grab_window = NULL;
- grab->priv->keyboard_grab_screen = NULL;
+ grab->priv->keyboard_grab_display = NULL;
}
static gboolean
@@ -269,7 +261,7 @@ gs_grab_mouse_reset (GSGrab *grab)
}
grab->priv->mouse_grab_window = NULL;
- grab->priv->mouse_grab_screen = NULL;
+ grab->priv->mouse_grab_display = NULL;
}
gboolean
@@ -284,15 +276,15 @@ gs_grab_release_mouse (GSGrab *grab)
}
static gboolean
-gs_grab_move_mouse (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen,
- gboolean hide_cursor)
+gs_grab_move_mouse (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display,
+ gboolean hide_cursor)
{
gboolean result;
GdkWindow *old_window;
- GdkScreen *old_screen;
- gboolean old_hide_cursor;
+ GdkDisplay *old_display;
+ gboolean old_hide_cursor;
/* if the pointer is not grabbed and we have a
@@ -331,7 +323,7 @@ gs_grab_move_mouse (GSGrab *grab,
gdk_x11_grab_server ();
old_window = grab->priv->mouse_grab_window;
- old_screen = grab->priv->mouse_grab_screen;
+ old_display = grab->priv->mouse_grab_display;
old_hide_cursor = grab->priv->mouse_hide_cursor;
if (old_window)
@@ -339,18 +331,18 @@ gs_grab_move_mouse (GSGrab *grab,
gs_grab_release_mouse (grab);
}
- result = gs_grab_get_mouse (grab, window, screen, hide_cursor);
+ result = gs_grab_get_mouse (grab, window, display, hide_cursor);
if (result != GDK_GRAB_SUCCESS)
{
sleep (1);
- result = gs_grab_get_mouse (grab, window, screen, hide_cursor);
+ result = gs_grab_get_mouse (grab, window, display, hide_cursor);
}
if ((result != GDK_GRAB_SUCCESS) && old_window)
{
gs_debug ("Could not grab mouse for new window. Resuming previous grab.");
- gs_grab_get_mouse (grab, old_window, old_screen, old_hide_cursor);
+ gs_grab_get_mouse (grab, old_window, old_display, old_hide_cursor);
}
gs_debug ("*** releasing X server grab");
@@ -361,13 +353,13 @@ gs_grab_move_mouse (GSGrab *grab,
}
static gboolean
-gs_grab_move_keyboard (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen)
+gs_grab_move_keyboard (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display)
{
gboolean result;
GdkWindow *old_window;
- GdkScreen *old_screen;
+ GdkDisplay *old_display;
if (grab->priv->keyboard_grab_window == window)
{
@@ -393,25 +385,25 @@ gs_grab_move_keyboard (GSGrab *grab,
gdk_x11_grab_server ();
old_window = grab->priv->keyboard_grab_window;
- old_screen = grab->priv->keyboard_grab_screen;
+ old_display = grab->priv->keyboard_grab_display;
if (old_window)
{
gs_grab_release_keyboard (grab);
}
- result = gs_grab_get_keyboard (grab, window, screen);
+ result = gs_grab_get_keyboard (grab, window, display);
if (result != GDK_GRAB_SUCCESS)
{
sleep (1);
- result = gs_grab_get_keyboard (grab, window, screen);
+ result = gs_grab_get_keyboard (grab, window, display);
}
if ((result != GDK_GRAB_SUCCESS) && old_window)
{
- gs_debug ("Could not grab keyboard for new window. Resuming previous grab.");
- gs_grab_get_keyboard (grab, old_window, old_screen);
+ gs_debug ("Could not grab keyboard for new window. Resuming previous grab.");
+ gs_grab_get_keyboard (grab, old_window, old_display);
}
gs_debug ("*** releasing X server grab");
@@ -453,10 +445,10 @@ gs_grab_release (GSGrab *grab)
}
gboolean
-gs_grab_grab_window (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen,
- gboolean hide_cursor)
+gs_grab_grab_window (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display,
+ gboolean hide_cursor)
{
gboolean mstatus = FALSE;
gboolean kstatus = FALSE;
@@ -468,7 +460,7 @@ AGAIN:
for (i = 0; i < retries; i++)
{
- kstatus = gs_grab_get_keyboard (grab, window, screen);
+ kstatus = gs_grab_get_keyboard (grab, window, display);
if (kstatus == GDK_GRAB_SUCCESS)
{
break;
@@ -490,7 +482,7 @@ AGAIN:
for (i = 0; i < retries; i++)
{
- mstatus = gs_grab_get_mouse (grab, window, screen, hide_cursor);
+ mstatus = gs_grab_get_mouse (grab, window, display, hide_cursor);
if (mstatus == GDK_GRAB_SUCCESS)
{
break;
@@ -565,7 +557,7 @@ gs_grab_grab_root (GSGrab *grab,
gdk_device_get_position (device, &screen, NULL, NULL);
root = gdk_screen_get_root_window (screen);
- res = gs_grab_grab_window (grab, root, screen, hide_cursor);
+ res = gs_grab_grab_window (grab, root, display, hide_cursor);
return res;
}
@@ -575,23 +567,28 @@ gboolean
gs_grab_grab_offscreen (GSGrab *grab,
gboolean hide_cursor)
{
- GdkScreen *screen;
- gboolean res;
+ GdkDisplay *display;
+ GdkScreen *screen;
+ gboolean res;
gs_debug ("Grabbing an offscreen window");
screen = gtk_invisible_get_screen (GTK_INVISIBLE (grab->priv->invisible));
- res = gs_grab_grab_window (grab, gtk_widget_get_window (GTK_WIDGET (grab->priv->invisible)), screen, hide_cursor);
+ display = gdk_screen_get_display (screen);
+ res = gs_grab_grab_window (grab,
+ gtk_widget_get_window (GTK_WIDGET (grab->priv->invisible)),
+ display,
+ hide_cursor);
return res;
}
/* This is similar to gs_grab_grab_window but doesn't fail */
void
-gs_grab_move_to_window (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen,
- gboolean hide_cursor)
+gs_grab_move_to_window (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display,
+ gboolean hide_cursor)
{
gboolean result = FALSE;
@@ -601,14 +598,14 @@ gs_grab_move_to_window (GSGrab *grab,
do
{
- result = gs_grab_move_keyboard (grab, window, screen);
+ result = gs_grab_move_keyboard (grab, window, display);
gdk_flush ();
}
while (!result);
do
{
- result = gs_grab_move_mouse (grab, window, screen, hide_cursor);
+ result = gs_grab_move_mouse (grab, window, display, hide_cursor);
gdk_flush ();
}
while (!result);
diff --git a/src/gs-grab.h b/src/gs-grab.h
index 0cba10c..dad9379 100644
--- a/src/gs-grab.h
+++ b/src/gs-grab.h
@@ -56,20 +56,20 @@ GSGrab * gs_grab_new (void);
void gs_grab_release (GSGrab *grab);
gboolean gs_grab_release_mouse (GSGrab *grab);
-gboolean gs_grab_grab_window (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen,
- gboolean hide_cursor);
+gboolean gs_grab_grab_window (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display,
+ gboolean hide_cursor);
gboolean gs_grab_grab_root (GSGrab *grab,
gboolean hide_cursor);
gboolean gs_grab_grab_offscreen (GSGrab *grab,
gboolean hide_cursor);
-void gs_grab_move_to_window (GSGrab *grab,
- GdkWindow *window,
- GdkScreen *screen,
- gboolean hide_cursor);
+void gs_grab_move_to_window (GSGrab *grab,
+ GdkWindow *window,
+ GdkDisplay *display,
+ gboolean hide_cursor);
void gs_grab_mouse_reset (GSGrab *grab);
void gs_grab_keyboard_reset (GSGrab *grab);
diff --git a/src/gs-job.c b/src/gs-job.c
index 009de4d..e0d4d3e 100644
--- a/src/gs-job.c
+++ b/src/gs-job.c
@@ -260,9 +260,10 @@ nice_process (int pid,
static GPtrArray *
get_env_vars (GtkWidget *widget)
{
- GPtrArray *env;
- char *str;
- int i;
+ GPtrArray *env;
+ const gchar *display_name;
+ gchar *str;
+ int i;
static const char *allowed_env_vars [] =
{
"PATH",
@@ -276,9 +277,8 @@ get_env_vars (GtkWidget *widget)
env = g_ptr_array_new ();
- str = gdk_screen_make_display_name (gtk_widget_get_screen (widget));
- g_ptr_array_add (env, g_strdup_printf ("DISPLAY=%s", str));
- g_free (str);
+ display_name = gdk_display_get_name (gtk_widget_get_display (widget));
+ g_ptr_array_add (env, g_strdup_printf ("DISPLAY=%s", display_name));
g_ptr_array_add (env, g_strdup_printf ("HOME=%s",
g_get_home_dir ()));
diff --git a/src/gs-manager.c b/src/gs-manager.c
index 6795ff6..10e268e 100644
--- a/src/gs-manager.c
+++ b/src/gs-manager.c
@@ -1102,12 +1102,15 @@ static GSWindow *
find_window_at_pointer (GSManager *manager)
{
GdkDisplay *display;
- GdkScreen *screen;
GdkDevice *device;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor;
+#else
+ GdkScreen *screen;
int monitor;
+#endif
int x, y;
GSWindow *window;
- int screen_num;
GSList *l;
display = gdk_display_get_default ();
@@ -1117,17 +1120,21 @@ find_window_at_pointer (GSManager *manager)
#else
device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display));
#endif
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gdk_device_get_position (device, NULL, &x, &y);
+ monitor = gdk_display_get_monitor_at_point (display, x, y);
+#else
gdk_device_get_position (device, &screen, &x, &y);
monitor = gdk_screen_get_monitor_at_point (screen, x, y);
- screen_num = gdk_screen_get_number (screen);
+#endif
- /* Find the gs-window that is on that screen */
+ /* Find the gs-window that is on that monitor */
window = NULL;
for (l = manager->priv->windows; l; l = l->next)
{
GSWindow *win = GS_WINDOW (l->data);
- if (gs_window_get_screen (win) == screen
- && gs_window_get_monitor (win) == monitor)
+ if (gs_window_get_display (win) == display &&
+ gs_window_get_monitor (win) == monitor)
{
window = win;
}
@@ -1135,13 +1142,15 @@ find_window_at_pointer (GSManager *manager)
if (window == NULL)
{
- gs_debug ("WARNING: Could not find the GSWindow for screen %d", screen_num);
+ gs_debug ("WARNING: Could not find the GSWindow for display %s",
+ gdk_display_get_name (display));
/* take the first one */
window = manager->priv->windows->data;
}
else
{
- gs_debug ("Requesting unlock for screen %d", screen_num);
+ gs_debug ("Requesting unlock for display %s",
+ gdk_display_get_name (display));
}
return window;
@@ -1169,9 +1178,13 @@ manager_maybe_grab_window (GSManager *manager,
GSWindow *window)
{
GdkDisplay *display;
- GdkScreen *screen;
GdkDevice *device;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor;
+#else
+ GdkScreen *screen;
int monitor;
+#endif
int x, y;
gboolean grabbed;
@@ -1181,18 +1194,23 @@ manager_maybe_grab_window (GSManager *manager,
#else
device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display));
#endif
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gdk_device_get_position (device, NULL, &x, &y);
+ monitor = gdk_display_get_monitor_at_point (display, x, y);
+#else
gdk_device_get_position (device, &screen, &x, &y);
monitor = gdk_screen_get_monitor_at_point (screen, x, y);
+#endif
gdk_flush ();
grabbed = FALSE;
- if (gs_window_get_screen (window) == screen
- && gs_window_get_monitor (window) == monitor)
+ if (gs_window_get_display (window) == display &&
+ gs_window_get_monitor (window) == monitor)
{
gs_debug ("Moving grab to %p", window);
gs_grab_move_to_window (manager->priv->grab,
gs_window_get_gdk_window (window),
- gs_window_get_screen (window),
+ gs_window_get_display (window),
FALSE);
grabbed = TRUE;
}
@@ -1266,6 +1284,7 @@ apply_background_to_window (GSManager *manager,
GSWindow *window)
{
cairo_surface_t *surface;
+ GdkDisplay *display;
GdkScreen *screen;
int width;
int height;
@@ -1278,7 +1297,8 @@ apply_background_to_window (GSManager *manager,
gs_window_set_background_surface (window, NULL);
}
- screen = gs_window_get_screen (window);
+ display = gs_window_get_display (window);
+ screen = gdk_display_get_default_screen (display);
width = gdk_screen_get_width (screen);
height = gdk_screen_get_height (screen);
gs_debug ("Creating background w:%d h:%d", width, height);
@@ -1397,7 +1417,7 @@ handle_window_dialog_up (GSManager *manager,
/* Move keyboard and mouse grabs so dialog can be used */
gs_grab_move_to_window (manager->priv->grab,
gs_window_get_gdk_window (window),
- gs_window_get_screen (window),
+ gs_window_get_display (window),
FALSE);
/* Release the pointer grab while dialog is up so that
@@ -1426,7 +1446,7 @@ handle_window_dialog_down (GSManager *manager,
/* Regrab the mouse */
gs_grab_move_to_window (manager->priv->grab,
gs_window_get_gdk_window (window),
- gs_window_get_screen (window),
+ gs_window_get_display (window),
FALSE);
/* Make all windows sensitive so we get events */
@@ -1524,19 +1544,32 @@ connect_window_signals (GSManager *manager,
}
static void
-gs_manager_create_window_for_monitor (GSManager *manager,
- GdkScreen *screen,
- int monitor)
+gs_manager_create_window_for_monitor (GSManager *manager,
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor)
+#else
+ GdkDisplay *display,
+ int monitor)
+#endif
{
GSWindow *window;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkDisplay *display;
+#endif
GdkRectangle rect;
- gdk_screen_get_monitor_geometry (screen, monitor, &rect);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ display = gdk_monitor_get_display (monitor);
+ gdk_monitor_get_geometry (monitor, &rect);
+#else
+ gdk_screen_get_monitor_geometry (gdk_display_get_default_screen (display),
+ monitor, &rect);
+#endif
- gs_debug ("Creating window for monitor %d [%d,%d] (%dx%d)",
+ gs_debug ("Creating a window for the monitor [%d,%d] (%dx%d)",
monitor, rect.x, rect.y, rect.width, rect.height);
- window = gs_window_new (screen, monitor, manager->priv->lock_active);
+ window = gs_window_new (display, monitor, manager->priv->lock_active);
gs_window_set_user_switch_enabled (window, manager->priv->user_switch_enabled);
gs_window_set_logout_enabled (window, manager->priv->logout_enabled);
@@ -1560,16 +1593,22 @@ static void
on_screen_monitors_changed (GdkScreen *screen,
GSManager *manager)
{
- GSList *l;
- int n_monitors;
- int n_windows;
- int i;
+ GSList *l;
+ GdkDisplay *display;
+ int n_monitors;
+ int n_windows;
+ int i;
+ display = gdk_screen_get_display (screen);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ n_monitors = gdk_display_get_n_monitors (display);
+#else
n_monitors = gdk_screen_get_n_monitors (screen);
+#endif
n_windows = g_slist_length (manager->priv->windows);
- gs_debug ("Monitors changed for screen %d: num=%d",
- gdk_screen_get_number (screen),
+ gs_debug ("Monitors changed for display %s: num=%d",
+ gdk_display_get_name (display),
n_monitors);
if (n_monitors > n_windows)
@@ -1588,7 +1627,13 @@ on_screen_monitors_changed (GdkScreen *screen,
/* add more windows */
for (i = n_windows; i < n_monitors; i++)
{
- gs_manager_create_window_for_monitor (manager, screen, i);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *mon = gdk_display_get_monitor (display, i);
+ gs_manager_create_window_for_monitor (manager, mon);
+#else
+ gs_manager_create_window_for_monitor (manager,
+ display, i);
+#endif
}
/* And put unlock dialog up where ever it's supposed to be
@@ -1604,13 +1649,23 @@ on_screen_monitors_changed (GdkScreen *screen,
l = manager->priv->windows;
while (l != NULL)
{
- GdkScreen *this_screen;
- int this_monitor;
- GSList *next = l->next;
+ GdkDisplay *this_display;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *this_monitor;
+#else
+ int this_monitor;
+#endif
+ GSList *next = l->next;
- this_screen = gs_window_get_screen (GS_WINDOW (l->data));
+ this_display = gs_window_get_display (GS_WINDOW (l->data));
this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
- if (this_screen == screen && this_monitor >= n_monitors)
+#if GTK_CHECK_VERSION (3, 22, 0)
+ if (this_display == display &&
+ !GDK_IS_MONITOR (this_monitor))
+#else
+ if (this_display == display &&
+ this_monitor >= n_monitors)
+#endif
{
manager_maybe_stop_job_for_window (manager, GS_WINDOW (l->data));
g_hash_table_remove (manager->priv->jobs, l->data);
@@ -1704,29 +1759,43 @@ gs_manager_finalize (GObject *object)
}
static void
-gs_manager_create_windows_for_screen (GSManager *manager,
- GdkScreen *screen)
+gs_manager_create_windows_for_display (GSManager *manager,
+ GdkDisplay *display)
{
- int n_monitors;
- int i;
+#if !GTK_CHECK_VERSION (3, 22, 0)
+ GdkScreen *screen;
+#endif
+ int n_monitors;
+ int i;
g_return_if_fail (manager != NULL);
g_return_if_fail (GS_IS_MANAGER (manager));
- g_return_if_fail (GDK_IS_SCREEN (screen));
+ g_return_if_fail (GDK_IS_DISPLAY (display));
g_object_ref (manager);
- g_object_ref (screen);
+ g_object_ref (display);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ n_monitors = gdk_display_get_n_monitors (display);
+#else
+ screen = gdk_display_get_default_screen (display);
n_monitors = gdk_screen_get_n_monitors (screen);
+#endif
- gs_debug ("Creating %d windows for screen %d", n_monitors, gdk_screen_get_number (screen));
+ gs_debug ("Creating %d windows for display %s",
+ n_monitors, gdk_display_get_name (display));
for (i = 0; i < n_monitors; i++)
{
- gs_manager_create_window_for_monitor (manager, screen, i);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *mon = gdk_display_get_monitor (display, i);
+ gs_manager_create_window_for_monitor (manager, mon);
+#else
+ gs_manager_create_window_for_monitor (manager, display, i);
+#endif
}
- g_object_unref (screen);
+ g_object_unref (display);
g_object_unref (manager);
}
@@ -1746,8 +1815,7 @@ gs_manager_create_windows (GSManager *manager)
G_CALLBACK (on_screen_monitors_changed),
manager);
- gs_manager_create_windows_for_screen (manager,
- gdk_display_get_default_screen (display));
+ gs_manager_create_windows_for_display (manager, display);
}
GSManager *
diff --git a/src/gs-visual-gl.c b/src/gs-visual-gl.c
index 7dfe165..80bf8bb 100644
--- a/src/gs-visual-gl.c
+++ b/src/gs-visual-gl.c
@@ -38,13 +38,14 @@
#include "gs-debug.h"
GdkVisual *
-gs_visual_gl_get_best_for_screen (GdkScreen *screen)
+gs_visual_gl_get_best_for_display (GdkDisplay *display)
{
- GdkVisual *visual;
+ GdkVisual *visual;
#ifdef HAVE_LIBGL
- GdkDisplay *display;
- int screen_num;
- int i;
+ Display *xdisplay;
+ GdkScreen *screen;
+ int screen_num;
+ int i;
# define R GLX_RED_SIZE
# define G GLX_GREEN_SIZE
@@ -72,10 +73,11 @@ gs_visual_gl_get_best_for_screen (GdkScreen *screen)
{ GLX_RGBA, R, 1, G, 1, B, 1, D, 1, 0 } /* monochrome */
};
- g_return_val_if_fail (screen != NULL, NULL);
+ g_return_val_if_fail (display != NULL, NULL);
- display = gdk_screen_get_display (screen);
- screen_num = gdk_screen_get_number (screen);
+ xdisplay = GDK_DISPLAY_XDISPLAY (display);
+ screen = gdk_display_get_default_screen (display);
+ screen_num = GDK_SCREEN_XNUMBER (screen);
gdk_error_trap_push ();
@@ -84,7 +86,7 @@ gs_visual_gl_get_best_for_screen (GdkScreen *screen)
{
XVisualInfo *vi;
- vi = glXChooseVisual (GDK_DISPLAY_XDISPLAY (display), screen_num, attrs [i]);
+ vi = glXChooseVisual (xdisplay, screen_num, attrs [i]);
if (vi != NULL)
{
diff --git a/src/gs-visual-gl.h b/src/gs-visual-gl.h
index 09cbdd9..4b1493a 100644
--- a/src/gs-visual-gl.h
+++ b/src/gs-visual-gl.h
@@ -25,7 +25,7 @@
G_BEGIN_DECLS
-GdkVisual *gs_visual_gl_get_best_for_screen (GdkScreen *screen);
+GdkVisual *gs_visual_gl_get_best_for_display (GdkDisplay *display);
G_END_DECLS
diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c
index 4054e74..f87ccf9 100644
--- a/src/gs-window-x11.c
+++ b/src/gs-window-x11.c
@@ -62,7 +62,11 @@ enum
struct GSWindowPrivate
{
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor;
+#else
int monitor;
+#endif
GdkRectangle geometry;
guint obscured : 1;
@@ -298,23 +302,48 @@ gs_window_clear (GSWindow *window)
static cairo_region_t *
get_outside_region (GSWindow *window)
{
- int i;
+ GdkDisplay *display;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ int i;
+#else
+ GdkScreen *screen;
+ int mon;
+#endif
cairo_region_t *region;
+ display = gtk_widget_get_display (GTK_WIDGET (window));
+#if !GTK_CHECK_VERSION (3, 22, 0)
+ screen = gdk_display_get_default_screen (display);
+#endif
+
region = cairo_region_create ();
- for (i = 0; i < window->priv->monitor; i++)
+#if GTK_CHECK_VERSION (3, 22, 0)
+ for (i = 0; i < gdk_display_get_n_monitors (display); i++)
+#else
+ for (mon = 0; mon < gdk_screen_get_n_monitors (screen); mon++)
+#endif
{
- GdkRectangle geometry;
- cairo_rectangle_int_t rectangle;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *mon = gdk_display_get_monitor (display, i);
+#endif
+ if (mon != window->priv->monitor)
+ {
+ GdkRectangle geometry;
+ cairo_rectangle_int_t rectangle;
- gdk_screen_get_monitor_geometry (gtk_widget_get_screen (GTK_WIDGET (window)),
- i, &geometry);
- rectangle.x = geometry.x;
- rectangle.y = geometry.y;
- rectangle.width = geometry.width;
- rectangle.height = geometry.height;
- cairo_region_union_rectangle (region, &rectangle);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gdk_monitor_get_geometry (mon, &geometry);
+#else
+ gdk_screen_get_monitor_geometry (screen, mon,
+ &geometry);
+#endif
+ rectangle.x = geometry.x;
+ rectangle.y = geometry.y;
+ rectangle.width = geometry.width;
+ rectangle.height = geometry.height;
+ cairo_region_union_rectangle (region, &rectangle);
+ }
}
return region;
@@ -329,11 +358,14 @@ update_geometry (GSWindow *window)
outside_region = get_outside_region (window);
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gdk_monitor_get_geometry (window->priv->monitor, &geometry);
+#else
gdk_screen_get_monitor_geometry (gtk_widget_get_screen (GTK_WIDGET (window)),
window->priv->monitor,
&geometry);
- gs_debug ("got geometry for monitor %d: x=%d y=%d w=%d h=%d",
- window->priv->monitor,
+#endif
+ gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",
geometry.x,
geometry.y,
geometry.width,
@@ -345,8 +377,7 @@ update_geometry (GSWindow *window)
cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
cairo_region_destroy (monitor_region);
- gs_debug ("using geometry for monitor %d: x=%d y=%d w=%d h=%d",
- window->priv->monitor,
+ gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",
geometry.x,
geometry.y,
geometry.width,
@@ -426,15 +457,15 @@ gs_window_real_unrealize (GtkWidget *widget)
extern char **environ;
static gchar **
-spawn_make_environment_for_screen (GdkScreen *screen,
- gchar **envp)
+spawn_make_environment_for_display (GdkDisplay *display,
+ gchar **envp)
{
gchar **retval = NULL;
- gchar *display_name;
+ const gchar *display_name;
gint display_index = -1;
gint i, env_len;
- g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
if (envp == NULL)
envp = environ;
@@ -446,7 +477,7 @@ spawn_make_environment_for_screen (GdkScreen *screen,
retval = g_new (char *, env_len + 1);
retval[env_len] = NULL;
- display_name = gdk_screen_make_display_name (screen);
+ display_name = gdk_display_get_name (display);
for (i = 0; i < env_len; i++)
if (i == display_index)
@@ -456,18 +487,16 @@ spawn_make_environment_for_screen (GdkScreen *screen,
g_assert (i == env_len);
- g_free (display_name);
-
return retval;
}
static gboolean
-spawn_command_line_on_screen_sync (GdkScreen *screen,
- const gchar *command_line,
- char **standard_output,
- char **standard_error,
- int *exit_status,
- GError **error)
+spawn_command_line_on_display_sync (GdkDisplay *display,
+ const gchar *command_line,
+ char **standard_output,
+ char **standard_error,
+ int *exit_status,
+ GError **error)
{
char **argv = NULL;
char **envp = NULL;
@@ -480,7 +509,7 @@ spawn_command_line_on_screen_sync (GdkScreen *screen,
return FALSE;
}
- envp = spawn_make_environment_for_screen (screen, NULL);
+ envp = spawn_make_environment_for_display (display, NULL);
retval = g_spawn_sync (NULL,
argv,
@@ -500,8 +529,9 @@ spawn_command_line_on_screen_sync (GdkScreen *screen,
}
static GdkVisual *
-get_best_visual_for_screen (GdkScreen *screen)
+get_best_visual_for_display (GdkDisplay *display)
{
+ GdkScreen *screen;
char *command;
char *std_output;
int exit_status;
@@ -512,12 +542,13 @@ get_best_visual_for_screen (GdkScreen *screen)
gboolean res;
visual = NULL;
+ screen = gdk_display_get_default_screen (display);
command = g_build_filename (LIBEXECDIR, "mate-screensaver-gl-helper", NULL);
error = NULL;
std_output = NULL;
- res = spawn_command_line_on_screen_sync (screen,
+ res = spawn_command_line_on_display_sync (display,
command,
&std_output,
NULL,
@@ -539,8 +570,8 @@ get_best_visual_for_screen (GdkScreen *screen)
visual_id = (VisualID) v;
visual = gdk_x11_screen_lookup_visual (screen, visual_id);
- gs_debug ("Found best GL visual for screen %d: 0x%x",
- gdk_screen_get_number (screen),
+ gs_debug ("Found best GL visual for display %s: 0x%x",
+ gdk_display_get_name (display),
(unsigned int) visual_id);
}
}
@@ -558,7 +589,7 @@ widget_set_best_visual (GtkWidget *widget)
g_return_if_fail (widget != NULL);
- visual = get_best_visual_for_screen (gtk_widget_get_screen (widget));
+ visual = get_best_visual_for_display (gtk_widget_get_display (widget));
if (visual != NULL)
{
gtk_widget_set_visual (widget, visual);
@@ -1063,7 +1094,7 @@ spawn_on_window (GSWindow *window,
}
error = NULL;
- envp = spawn_make_environment_for_screen (gtk_window_get_screen (GTK_WINDOW (window)), NULL);
+ envp = spawn_make_environment_for_display (gtk_widget_get_display (GTK_WIDGET (window)), NULL);
result = g_spawn_async_with_pipes (NULL,
argv,
envp,
@@ -1810,23 +1841,12 @@ gs_window_set_lock_enabled (GSWindow *window,
g_object_notify (G_OBJECT (window), "lock-enabled");
}
-void
-gs_window_set_screen (GSWindow *window,
- GdkScreen *screen)
-{
-
- g_return_if_fail (GS_IS_WINDOW (window));
- g_return_if_fail (GDK_IS_SCREEN (screen));
-
- gtk_window_set_screen (GTK_WINDOW (window), screen);
-}
-
-GdkScreen *
-gs_window_get_screen (GSWindow *window)
+GdkDisplay *
+gs_window_get_display (GSWindow *window)
{
g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
- return gtk_widget_get_screen (GTK_WIDGET (window));
+ return gtk_widget_get_display (GTK_WIDGET (window));
}
void
@@ -1919,8 +1939,12 @@ gs_window_set_status_message (GSWindow *window,
}
void
-gs_window_set_monitor (GSWindow *window,
- int monitor)
+gs_window_set_monitor (GSWindow *window,
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor)
+#else
+ int monitor)
+#endif
{
g_return_if_fail (GS_IS_WINDOW (window));
@@ -1936,10 +1960,18 @@ gs_window_set_monitor (GSWindow *window,
g_object_notify (G_OBJECT (window), "monitor");
}
+#if GTK_CHECK_VERSION (3, 22, 0)
+GdkMonitor *
+#else
int
+#endif
gs_window_get_monitor (GSWindow *window)
{
+#if GTK_CHECK_VERSION (3, 22, 0)
+ g_return_val_if_fail (GS_IS_WINDOW (window), NULL);
+#else
g_return_val_if_fail (GS_IS_WINDOW (window), -1);
+#endif
return window->priv->monitor;
}
@@ -1978,7 +2010,11 @@ gs_window_set_property (GObject *object,
gs_window_set_logout_timeout (self, g_value_get_long (value));
break;
case PROP_MONITOR:
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gs_window_set_monitor (self, g_value_get_pointer (value));
+#else
gs_window_set_monitor (self, g_value_get_int (value));
+#endif
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -2020,7 +2056,11 @@ gs_window_get_property (GObject *object,
g_value_set_long (value, self->priv->logout_timeout);
break;
case PROP_MONITOR:
+#if GTK_CHECK_VERSION (3, 22, 0)
+ g_value_set_pointer (value, (gpointer) self->priv->monitor);
+#else
g_value_set_int (value, self->priv->monitor);
+#endif
break;
case PROP_OBSCURED:
g_value_set_boolean (value, self->priv->obscured);
@@ -2107,15 +2147,17 @@ static gboolean
gs_window_real_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event)
{
- GSWindow *window;
- gdouble distance;
- gdouble min_distance;
- gdouble min_percentage = 0.1;
- GdkScreen *screen;
+ GSWindow *window;
+ gdouble distance;
+ gdouble min_distance;
+ gdouble min_percentage = 0.1;
+ GdkDisplay *display;
+ GdkScreen *screen;
window = GS_WINDOW (widget);
- screen = gs_window_get_screen (window);
+ display = gs_window_get_display (window);
+ screen = gdk_display_get_default_screen (display);
min_distance = gdk_screen_get_width (screen) * min_percentage;
/* if the last position was not set then don't detect motion */
@@ -2419,13 +2461,20 @@ gs_window_class_init (GSWindowClass *klass)
g_object_class_install_property (object_class,
PROP_MONITOR,
+#if GTK_CHECK_VERSION (3, 22, 0)
+ g_param_spec_pointer ("monitor",
+ "Gdk monitor",
+ "The monitor (in terms of Gdk) which the window is on",
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+#else
g_param_spec_int ("monitor",
- "Xinerama monitor",
- "The monitor (in terms of Xinerama) which the window is on",
+ "RandR monitor",
+ "The monitor (in terms of RandR) which the window is on",
0,
G_MAXINT,
0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+#endif
}
@@ -2558,11 +2607,16 @@ gs_window_finalize (GObject *object)
}
GSWindow *
-gs_window_new (GdkScreen *screen,
- int monitor,
+gs_window_new (GdkDisplay *display,
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor,
+#else
+ int monitor,
+#endif
gboolean lock_enabled)
{
- GObject *result;
+ GObject *result;
+ GdkScreen *screen = gdk_display_get_default_screen (display);
result = g_object_new (GS_TYPE_WINDOW,
"type", GTK_WINDOW_POPUP,
diff --git a/src/gs-window.h b/src/gs-window.h
index 9cd64eb..7878a94 100644
--- a/src/gs-window.h
+++ b/src/gs-window.h
@@ -59,12 +59,16 @@ GType gs_window_get_type (void);
gboolean gs_window_is_obscured (GSWindow *window);
gboolean gs_window_is_dialog_up (GSWindow *window);
-void gs_window_set_screen (GSWindow *window,
- GdkScreen *screen);
-GdkScreen * gs_window_get_screen (GSWindow *window);
-void gs_window_set_monitor (GSWindow *window,
- int monitor);
+GdkDisplay * gs_window_get_display (GSWindow *window);
+#if GTK_CHECK_VERSION (3, 22, 0)
+void gs_window_set_monitor (GSWindow *window,
+ GdkMonitor *monitor);
+GdkMonitor * gs_window_get_monitor (GSWindow *window);
+#else
+void gs_window_set_monitor (GSWindow *window,
+ int monitor);
int gs_window_get_monitor (GSWindow *window);
+#endif
void gs_window_set_background_surface (GSWindow *window,
cairo_surface_t *surface);
@@ -92,9 +96,13 @@ void gs_window_show_message (GSWindow *window,
void gs_window_request_unlock (GSWindow *window);
void gs_window_cancel_unlock_request (GSWindow *window);
-GSWindow * gs_window_new (GdkScreen *screen,
- int monitor,
- gboolean lock_enabled);
+GSWindow * gs_window_new (GdkDisplay *display,
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor,
+#else
+ int monitor,
+#endif
+ gboolean lock_enabled);
void gs_window_show (GSWindow *window);
void gs_window_destroy (GSWindow *window);
GdkWindow * gs_window_get_gdk_window (GSWindow *window);
diff --git a/src/mate-screensaver-gl-helper.c b/src/mate-screensaver-gl-helper.c
index acf23ef..472aefd 100644
--- a/src/mate-screensaver-gl-helper.c
+++ b/src/mate-screensaver-gl-helper.c
@@ -35,7 +35,6 @@ main (int argc,
char **argv)
{
GdkDisplay *display;
- GdkScreen *screen;
GdkVisual *visual;
Visual *xvisual;
GError *error = NULL;
@@ -64,8 +63,7 @@ main (int argc,
}
display = gdk_display_get_default ();
- screen = gdk_display_get_default_screen (display);
- visual = gs_visual_gl_get_best_for_screen (screen);
+ visual = gs_visual_gl_get_best_for_display (display);
if (visual != NULL)
{
diff --git a/src/mate-screensaver-preferences.c b/src/mate-screensaver-preferences.c
index 7fd498c..ad38b36 100644
--- a/src/mate-screensaver-preferences.c
+++ b/src/mate-screensaver-preferences.c
@@ -1270,15 +1270,15 @@ setup_for_root_user (void)
extern char **environ;
static gchar **
-spawn_make_environment_for_screen (GdkScreen *screen,
- gchar **envp)
+spawn_make_environment_for_display (GdkDisplay *display,
+ gchar **envp)
{
gchar **retval = NULL;
- gchar *display_name;
+ const gchar *display_name;
gint display_index = -1;
gint i, env_len;
- g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
if (envp == NULL)
envp = environ;
@@ -1290,7 +1290,7 @@ spawn_make_environment_for_screen (GdkScreen *screen,
retval = g_new (char *, env_len + 1);
retval[env_len] = NULL;
- display_name = gdk_screen_make_display_name (screen);
+ display_name = gdk_display_get_name (display);
for (i = 0; i < env_len; i++)
if (i == display_index)
@@ -1300,18 +1300,16 @@ spawn_make_environment_for_screen (GdkScreen *screen,
g_assert (i == env_len);
- g_free (display_name);
-
return retval;
}
static gboolean
-spawn_command_line_on_screen_sync (GdkScreen *screen,
- const gchar *command_line,
- char **standard_output,
- char **standard_error,
- int *exit_status,
- GError **error)
+spawn_command_line_on_display_sync (GdkDisplay *display,
+ const gchar *command_line,
+ char **standard_output,
+ char **standard_error,
+ int *exit_status,
+ GError **error)
{
char **argv = NULL;
char **envp = NULL;
@@ -1324,7 +1322,7 @@ spawn_command_line_on_screen_sync (GdkScreen *screen,
return FALSE;
}
- envp = spawn_make_environment_for_screen (screen, NULL);
+ envp = spawn_make_environment_for_display (display, NULL);
retval = g_spawn_sync (NULL,
argv,
@@ -1345,8 +1343,9 @@ spawn_command_line_on_screen_sync (GdkScreen *screen,
static GdkVisual *
-get_best_visual_for_screen (GdkScreen *screen)
+get_best_visual_for_display (GdkDisplay *display)
{
+ GdkScreen *screen;
char *command;
char *std_output;
int exit_status;
@@ -1357,12 +1356,13 @@ get_best_visual_for_screen (GdkScreen *screen)
gboolean res;
visual = NULL;
+ screen = gdk_display_get_default_screen (display);
command = g_build_filename (LIBEXECDIR, "mate-screensaver-gl-helper", NULL);
error = NULL;
std_output = NULL;
- res = spawn_command_line_on_screen_sync (screen,
+ res = spawn_command_line_on_display_sync (display,
command,
&std_output,
NULL,
@@ -1384,8 +1384,8 @@ get_best_visual_for_screen (GdkScreen *screen)
visual_id = (VisualID) v;
visual = gdk_x11_screen_lookup_visual (screen, visual_id);
- gs_debug ("Found best GL visual for screen %d: 0x%x",
- gdk_screen_get_number (screen),
+ gs_debug ("Found best GL visual for display %s: 0x%x",
+ gdk_display_get_name (display),
(unsigned int) visual_id);
}
}
@@ -1404,7 +1404,7 @@ widget_set_best_visual (GtkWidget *widget)
g_return_if_fail (widget != NULL);
- visual = get_best_visual_for_screen (gtk_widget_get_screen (widget));
+ visual = get_best_visual_for_display (gtk_widget_get_display (widget));
if (visual != NULL)
{
gtk_widget_set_visual (widget, visual);
diff --git a/src/test-window.c b/src/test-window.c
index 05883a7..f07c5c7 100644
--- a/src/test-window.c
+++ b/src/test-window.c
@@ -60,7 +60,7 @@ window_show_cb (GSWindow *window,
/* Grab keyboard so dialog can be used */
gs_grab_move_to_window (grab,
gs_window_get_gdk_window (window),
- gs_window_get_screen (window),
+ gs_window_get_display (window),
FALSE);
}
@@ -120,18 +120,28 @@ connect_window_signals (GSWindow *window)
static void
test_window (void)
{
- GSWindow *window;
- gboolean lock_active;
- gboolean user_switch_enabled;
- GdkScreen *screen;
- int monitor;
+ GSWindow *window;
+ gboolean lock_active;
+ gboolean user_switch_enabled;
+ GdkDisplay *display;
+#if GTK_CHECK_VERSION (3, 22, 0)
+ GdkMonitor *monitor;
+#else
+ GdkScreen *screen;
+ int monitor;
+#endif
lock_active = TRUE;
user_switch_enabled = TRUE;
- screen = gdk_screen_get_default ();
- monitor = 0;
+ display = gdk_display_get_default ();
+#if GTK_CHECK_VERSION (3, 22, 0)
+ monitor = gdk_display_get_primary_monitor (display);
+#else
+ screen = gdk_display_get_default_screen (display);
+ monitor = gdk_screen_get_primary_monitor (screen);
+#endif
- window = gs_window_new (screen, monitor, lock_active);
+ window = gs_window_new (display, monitor, lock_active);
gs_window_set_user_switch_enabled (window, user_switch_enabled);