summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexei Sorokin <[email protected]>2018-08-21 20:59:20 +0300
committerraveit65 <[email protected]>2018-08-24 15:40:43 +0200
commit465734b765fcfa28a8b63a877bedd65cd2de959e (patch)
tree46ea1eaa465c6c49503a9dc3b11e3bb97e8c9957
parent762ae73b4aefcb943b4b573789ea25cbb9f4cbd5 (diff)
downloadmate-screensaver-465734b765fcfa28a8b63a877bedd65cd2de959e.tar.bz2
mate-screensaver-465734b765fcfa28a8b63a877bedd65cd2de959e.tar.xz
fix more GdkScreen related deprecations
This is a follow-up to 5d4416a to fix #152
-rw-r--r--src/gs-manager.c136
1 files changed, 62 insertions, 74 deletions
diff --git a/src/gs-manager.c b/src/gs-manager.c
index fe2e4fe..7993539 100644
--- a/src/gs-manager.c
+++ b/src/gs-manager.c
@@ -1268,11 +1268,8 @@ apply_background_to_window (GSManager *manager,
GSWindow *window)
{
cairo_surface_t *surface;
- GdkDisplay *display;
- GdkScreen *screen;
int width;
int height;
- gint scale;
mate_bg_load_from_preferences (manager->priv->bg);
@@ -1282,11 +1279,8 @@ apply_background_to_window (GSManager *manager,
gs_window_set_background_surface (window, NULL);
}
- display = gs_window_get_display (window);
- screen = gdk_display_get_default_screen (display);
- scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
- width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
- height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ gtk_widget_get_preferred_width (GTK_WIDGET (window), &width, NULL);
+ gtk_widget_get_preferred_height (GTK_WIDGET (window), &height, NULL);
gs_debug ("Creating background w:%d h:%d", width, height);
surface = mate_bg_create_surface (manager->priv->bg,
gs_window_get_gdk_window (window),
@@ -1563,84 +1557,73 @@ gs_manager_create_window_for_monitor (GSManager *manager,
}
static void
-on_screen_monitors_changed (GdkScreen *screen,
- GSManager *manager)
+on_display_monitor_added (GdkDisplay *display,
+ GdkMonitor *monitor,
+ GSManager *manager)
{
GSList *l;
- GdkDisplay *display;
int n_monitors;
- int n_windows;
- int i;
- display = gdk_screen_get_display (screen);
n_monitors = gdk_display_get_n_monitors (display);
- n_windows = g_slist_length (manager->priv->windows);
- gs_debug ("Monitors changed for display %s: num=%d",
- gdk_display_get_name (display),
- n_monitors);
+ gs_debug ("Monitor added on display %s, now there are %d",
+ gdk_display_get_name (display), n_monitors);
- if (n_monitors > n_windows)
+ /* Tear down the unlock dialog in case we want to move it
+ * to the new monitor
+ */
+ l = manager->priv->windows;
+ while (l != NULL)
{
+ gs_window_cancel_unlock_request (GS_WINDOW (l->data));
+ l = l->next;
+ }
- /* Tear down unlock dialog in case we want to move it
- * to a new monitor
- */
- l = manager->priv->windows;
- while (l != NULL)
- {
- gs_window_cancel_unlock_request (GS_WINDOW (l->data));
- l = l->next;
- }
+ /* add a new window */
+ gs_manager_create_window_for_monitor (manager, monitor);
- /* add more windows */
- for (i = n_windows; i < n_monitors; i++)
- {
- GdkMonitor *mon = gdk_display_get_monitor (display, i);
- gs_manager_create_window_for_monitor (manager, mon);
- }
+ /* and put unlock dialog up whereever it's supposed to be */
+ gs_manager_request_unlock (manager);
+}
- /* And put unlock dialog up where ever it's supposed to be
- */
- gs_manager_request_unlock (manager);
- }
- else
- {
+static void
+on_display_monitor_removed (GdkDisplay *display,
+ GdkMonitor *monitor,
+ GSManager *manager)
+{
+ GSList *l;
+ int n_monitors;
- gdk_x11_grab_server ();
+ n_monitors = gdk_display_get_n_monitors (display);
- /* remove the extra windows */
- l = manager->priv->windows;
- while (l != NULL)
- {
- GdkDisplay *this_display;
- GdkMonitor *this_monitor;
- GSList *next = l->next;
-
- this_display = gs_window_get_display (GS_WINDOW (l->data));
- this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
- if (this_display == display &&
- !GDK_IS_MONITOR (this_monitor))
- {
- manager_maybe_stop_job_for_window (manager, GS_WINDOW (l->data));
- g_hash_table_remove (manager->priv->jobs, l->data);
- gs_window_destroy (GS_WINDOW (l->data));
- manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
- }
- l = next;
- }
+ gs_debug ("Monitor removed on display %s, now there are %d",
+ gdk_display_get_name (display), n_monitors);
- /* make sure there is a lock dialog on a connected monitor,
- * and that the keyboard is still properly grabbed after all
- * the windows above got destroyed*/
- if (n_windows > n_monitors)
+ gdk_x11_grab_server ();
+
+ /* remove the now extra window */
+ l = manager->priv->windows;
+ while (l != NULL)
+ {
+ GdkDisplay *this_display;
+ GdkMonitor *this_monitor;
+ GSList *next = l->next;
+
+ this_display = gs_window_get_display (GS_WINDOW (l->data));
+ this_monitor = gs_window_get_monitor (GS_WINDOW (l->data));
+ if (this_display == display && this_monitor == monitor)
{
- gs_manager_request_unlock (manager);
+ manager_maybe_stop_job_for_window (manager,
+ GS_WINDOW (l->data));
+ g_hash_table_remove (manager->priv->jobs, l->data);
+ gs_window_destroy (GS_WINDOW (l->data));
+ manager->priv->windows = g_slist_delete_link (manager->priv->windows, l);
}
-
- gdk_flush ();
- gdk_x11_ungrab_server ();
+ l = next;
}
+
+ gdk_display_flush (display);
+ gdk_x11_ungrab_server ();
}
static void
@@ -1659,8 +1642,11 @@ gs_manager_destroy_windows (GSManager *manager)
display = gdk_display_get_default ();
- g_signal_handlers_disconnect_by_func (gdk_display_get_default_screen (display),
- on_screen_monitors_changed,
+ g_signal_handlers_disconnect_by_func (display,
+ on_display_monitor_removed,
+ manager);
+ g_signal_handlers_disconnect_by_func (display,
+ on_display_monitor_added,
manager);
for (l = manager->priv->windows; l; l = l->next)
@@ -1753,9 +1739,11 @@ gs_manager_create_windows (GSManager *manager)
g_assert (manager->priv->windows == NULL);
display = gdk_display_get_default ();
- g_signal_connect (gdk_display_get_default_screen (display),
- "monitors-changed",
- G_CALLBACK (on_screen_monitors_changed),
+ g_signal_connect (display, "monitor-added",
+ G_CALLBACK (on_display_monitor_added),
+ manager);
+ g_signal_connect (display, "monitor-removed",
+ G_CALLBACK (on_display_monitor_removed),
manager);
gs_manager_create_windows_for_display (manager, display);