[Xfce4-commits] [apps/xfce4-screensaver] 417/425: Fix more GdkScreen related deprecations - See https://github.com/mate-desktop/mate-screensaver/commit/dbd37df02231b8f2fb57b064c05c4a6886ee0357 for the original commit and more information

noreply at xfce.org noreply at xfce.org
Mon Oct 15 01:54:24 CEST 2018


This is an automated email from the git hooks/post-receive script.

b   l   u   e   s   a   b   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-screensaver.

commit 6ea47a76e1ae28d7bf21a2e9b16fae16a4b2255e
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sat Oct 13 12:49:02 2018 -0400

    Fix more GdkScreen related deprecations
    - See https://github.com/mate-desktop/mate-screensaver/commit/dbd37df02231b8f2fb57b064c05c4a6886ee0357 for the original commit and more information
---
 src/gs-manager.c    | 144 ++++++++++++++++++++++++----------------------------
 src/gs-window-x11.c |  32 +++++++-----
 src/gs-window.h     |   3 +-
 src/test-window.c   |   2 +-
 4 files changed, 85 insertions(+), 96 deletions(-)

diff --git a/src/gs-manager.c b/src/gs-manager.c
index 13a64f7..ad1c8ba 100644
--- a/src/gs-manager.c
+++ b/src/gs-manager.c
@@ -1264,17 +1264,11 @@ apply_background_to_window (GSManager *manager,
                             GSWindow  *window)
 {
 	cairo_surface_t *surface;
-	GdkDisplay      *display;
-	GdkScreen       *screen;
 	GdkMonitor      *monitor;
 	GdkRectangle     geometry;
 	int              width, m_width;
 	int              height, m_height;
-	gint             scale;
 
-	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));
 	monitor = gs_window_get_monitor (window);
 
 	xfce_bg_load_from_preferences (manager->priv->bg, monitor);
@@ -1286,10 +1280,10 @@ apply_background_to_window (GSManager *manager,
 	}
 
 	gdk_monitor_get_geometry (monitor, &geometry);
-	m_width = geometry.width / scale;
-	m_height = geometry.height / scale;
-	width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
-	height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+	m_width = geometry.width;
+	m_height = geometry.height;
+	gtk_widget_get_preferred_width (GTK_WIDGET (window), &width, NULL);
+	gtk_widget_get_preferred_height (GTK_WIDGET (window), &height, NULL);
 	gs_debug ("Creating background (Screen: w:%d h:%d, Monitor: w:%d h: %d)", width, height, m_width, m_height);
 	surface = xfce_bg_create_surface (manager->priv->bg,
 	                                  gs_window_get_gdk_window (window),
@@ -1537,16 +1531,14 @@ gs_manager_create_window_for_monitor (GSManager  *manager,
                                       GdkMonitor *monitor)
 {
 	GSWindow    *window;
-	GdkDisplay  *display;
 	GdkRectangle rect;
 
-	display = gdk_monitor_get_display (monitor);
 	gdk_monitor_get_geometry (monitor, &rect);
 
 	gs_debug ("Creating a window [%d,%d] (%dx%d)",
 	          rect.x, rect.y, rect.width, rect.height);
 
-	window = gs_window_new (display, monitor, manager->priv->lock_active);
+	window = gs_window_new (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);
@@ -1567,84 +1559,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_display_flush (display);
-		gdk_x11_ungrab_server ();
+		l = next;
 	}
+
+	gdk_display_flush (display);
+	gdk_x11_ungrab_server ();
 }
 
 static void
@@ -1663,9 +1644,12 @@ 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)
 	{
@@ -1757,10 +1741,12 @@ 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);
 }
diff --git a/src/gs-window-x11.c b/src/gs-window-x11.c
index bfcfa36..7c066f1 100644
--- a/src/gs-window-x11.c
+++ b/src/gs-window-x11.c
@@ -363,10 +363,11 @@ update_geometry (GSWindow *window)
 }
 
 static void
-screen_size_changed (GdkScreen *screen,
-                     GSWindow  *window)
+monitor_geometry_notify (GdkMonitor *monitor,
+                         GParamSpec *pspec,
+                         GSWindow   *window)
 {
-	gs_debug ("Got screen size changed signal");
+	gs_debug ("Got monitor geometry notify signal");
 	gtk_widget_queue_resize (GTK_WIDGET (window));
 }
 
@@ -415,9 +416,10 @@ gs_window_move_resize_window (GSWindow *window,
 static void
 gs_window_real_unrealize (GtkWidget *widget)
 {
-	g_signal_handlers_disconnect_by_func (gtk_window_get_screen (GTK_WINDOW (widget)),
-	                                      screen_size_changed,
-	                                      widget);
+	GdkMonitor *monitor = GS_WINDOW (widget)->priv->monitor;
+
+	g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,
+										  widget);
 
 	if (GTK_WIDGET_CLASS (gs_window_parent_class)->unrealize)
 	{
@@ -572,6 +574,8 @@ widget_set_best_visual (GtkWidget *widget)
 static void
 gs_window_real_realize (GtkWidget *widget)
 {
+	GdkMonitor *monitor = GS_WINDOW (widget)->priv->monitor;
+
 	widget_set_best_visual (widget);
 
 	if (GTK_WIDGET_CLASS (gs_window_parent_class)->realize)
@@ -583,10 +587,10 @@ gs_window_real_realize (GtkWidget *widget)
 
 	gs_window_move_resize_window (GS_WINDOW (widget), TRUE, TRUE);
 
-	g_signal_connect (gtk_window_get_screen (GTK_WINDOW (widget)),
-	                  "size_changed",
-	                  G_CALLBACK (screen_size_changed),
-	                  widget);
+	g_signal_connect (monitor,
+	                  "notify::geometry",
+	                  G_CALLBACK (monitor_geometry_notify),
+					  widget);
 }
 
 /* every so often we should raise the window in case
@@ -2573,12 +2577,12 @@ gs_window_finalize (GObject *object)
 }
 
 GSWindow *
-gs_window_new (GdkDisplay *display,
-               GdkMonitor *monitor,
+gs_window_new (GdkMonitor *monitor,
                gboolean   lock_enabled)
 {
-	GObject   *result;
-	GdkScreen *screen = gdk_display_get_default_screen (display);
+	GObject    *result;
+	GdkDisplay *display = gdk_monitor_get_display (monitor);
+	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 903beae..33bad7f 100644
--- a/src/gs-window.h
+++ b/src/gs-window.h
@@ -91,8 +91,7 @@ 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                (GdkDisplay *display,
-                                          GdkMonitor *monitor,
+GSWindow  * gs_window_new                (GdkMonitor *monitor,
                                           gboolean   lock_enabled);
 void        gs_window_show               (GSWindow  *window);
 void        gs_window_destroy            (GSWindow  *window);
diff --git a/src/test-window.c b/src/test-window.c
index 36a792e..234e34b 100644
--- a/src/test-window.c
+++ b/src/test-window.c
@@ -130,7 +130,7 @@ test_window (void)
 	display = gdk_display_get_default ();
 	monitor = gdk_display_get_primary_monitor (display);
 
-	window = gs_window_new (display, monitor, lock_active);
+	window = gs_window_new (monitor, lock_active);
 
 	gs_window_set_user_switch_enabled (window, user_switch_enabled);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list