diff options
author | Alexei Sorokin <[email protected]> | 2017-01-17 00:10:40 +0300 |
---|---|---|
committer | Alexei Sorokin <[email protected]> | 2017-01-17 00:10:40 +0300 |
commit | 5d4416aa5853de486e62ca97207ee1da4b35b199 (patch) | |
tree | 41a3450d67f77f98b4b70392eec923ea54013cc0 /src/gs-manager.c | |
parent | 6672c9811a6c6fe76810d2c66c69c4727910d91d (diff) | |
download | mate-screensaver-5d4416aa5853de486e62ca97207ee1da4b35b199.tar.bz2 mate-screensaver-5d4416aa5853de486e62ca97207ee1da4b35b199.tar.xz |
GTK+3.22: fix some GdkScreen related deprecations
Diffstat (limited to 'src/gs-manager.c')
-rw-r--r-- | src/gs-manager.c | 156 |
1 files changed, 112 insertions, 44 deletions
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 * |