[gnome-shell] na-tray-manager: Use gdk_screen_get_default() and gdk_x11_get_default_screen()



commit 94a674c0084cebed5e79a132c109a61a71cfa5e9
Author: Robert Mader <robert mader posteo de>
Date:   Tue Feb 26 21:06:20 2019 +0100

    na-tray-manager: Use gdk_screen_get_default() and gdk_x11_get_default_screen()
    
    instead of explicit screen arguments and `gdk_screen_get_number()`, as nowadays there
    is always only one screen. This silences some deprecation warnings and removes
    deprecated API.
    
    Bonus: some code style cleanups
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/422

 src/shell-tray-manager.c   |  8 +-------
 src/tray/na-tray-manager.c | 43 +++++++++++++++++++++----------------------
 src/tray/na-tray-manager.h |  5 ++---
 3 files changed, 24 insertions(+), 32 deletions(-)
---
diff --git a/src/shell-tray-manager.c b/src/shell-tray-manager.c
index bce79bbd7..3311deb40 100644
--- a/src/shell-tray-manager.c
+++ b/src/shell-tray-manager.c
@@ -212,13 +212,7 @@ void
 shell_tray_manager_manage_screen (ShellTrayManager *manager,
                                   StWidget         *theme_widget)
 {
-  GdkDisplay *display;
-  GdkScreen *gdk_screen;
-
-  display = gdk_display_get_default ();
-  gdk_screen = gdk_display_get_default_screen (display);
-
-  na_tray_manager_manage_screen (manager->priv->na_manager, gdk_screen);
+  na_tray_manager_manage_screen (manager->priv->na_manager);
 
   g_signal_connect_object (theme_widget, "style-changed",
                            G_CALLBACK (shell_tray_manager_style_changed),
diff --git a/src/tray/na-tray-manager.c b/src/tray/na-tray-manager.c
index 081170adb..fdf47da55 100644
--- a/src/tray/na-tray-manager.c
+++ b/src/tray/na-tray-manager.c
@@ -70,7 +70,7 @@ static guint manager_signals[LAST_SIGNAL];
 #define SYSTEM_TRAY_ORIENTATION_VERT 1
 
 #ifdef GDK_WINDOWING_X11
-static gboolean na_tray_manager_check_running_screen_x11 (GdkScreen *screen);
+static gboolean na_tray_manager_check_running_screen_x11 ();
 #endif
 
 static void na_tray_manager_finalize     (GObject      *object);
@@ -682,15 +682,15 @@ na_tray_manager_set_colors_property (NaTrayManager *manager)
 #ifdef GDK_WINDOWING_X11
 
 static gboolean
-na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
-                                  GdkScreen     *screen)
+na_tray_manager_manage_screen_x11 (NaTrayManager *manager)
 {
   GdkDisplay *display;
-  Screen     *xscreen;
-  GtkWidget  *invisible;
-  GdkWindow  *window;
-  char       *selection_atom_name;
-  guint32     timestamp;
+  GdkScreen *screen;
+  Screen *xscreen;
+  GtkWidget *invisible;
+  GdkWindow *window;
+  char *selection_atom_name;
+  guint32 timestamp;
   
   g_return_val_if_fail (NA_IS_TRAY_MANAGER (manager), FALSE);
   g_return_val_if_fail (manager->screen == NULL, FALSE);
@@ -699,10 +699,11 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
    * we can't create another one.
    */
 #if 0
-  if (na_tray_manager_check_running_screen_x11 (screen))
+  if (na_tray_manager_check_running_screen_x11 ())
     return FALSE;
 #endif
   
+  screen = gdk_screen_get_default ();
   manager->screen = screen;
 
   display = gdk_screen_get_display (screen);
@@ -715,7 +716,7 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
                          GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);
 
   selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d",
-                                        gdk_screen_get_number (screen));
+                                         gdk_x11_get_default_screen ());
   manager->selection_atom = gdk_atom_intern (selection_atom_name, FALSE);
   g_free (selection_atom_name);
 
@@ -793,14 +794,12 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
 #endif
 
 gboolean
-na_tray_manager_manage_screen (NaTrayManager *manager,
-                              GdkScreen     *screen)
+na_tray_manager_manage_screen (NaTrayManager *manager)
 {
-  g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
   g_return_val_if_fail (manager->screen == NULL, FALSE);
 
 #ifdef GDK_WINDOWING_X11
-  return na_tray_manager_manage_screen_x11 (manager, screen);
+  return na_tray_manager_manage_screen_x11 (manager);
 #else
   return FALSE;
 #endif
@@ -809,15 +808,17 @@ na_tray_manager_manage_screen (NaTrayManager *manager,
 #ifdef GDK_WINDOWING_X11
 
 static gboolean
-na_tray_manager_check_running_screen_x11 (GdkScreen *screen)
+na_tray_manager_check_running_screen_x11 ()
 {
   GdkDisplay *display;
-  Atom        selection_atom;
-  char       *selection_atom_name;
+  GdkScreen *screen;
+  Atom selection_atom;
+  char *selection_atom_name;
 
+  screen = gdk_screen_get_default ();
   display = gdk_screen_get_display (screen);
   selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d",
-                                         gdk_screen_get_number (screen));
+                                         gdk_x11_get_default_screen ());
   selection_atom = gdk_x11_get_xatom_by_name_for_display (display,
                                                           selection_atom_name);
   g_free (selection_atom_name);
@@ -832,12 +833,10 @@ na_tray_manager_check_running_screen_x11 (GdkScreen *screen)
 #endif
 
 gboolean
-na_tray_manager_check_running (GdkScreen *screen)
+na_tray_manager_check_running ()
 {
-  g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
-
 #ifdef GDK_WINDOWING_X11
-  return na_tray_manager_check_running_screen_x11 (screen);
+  return na_tray_manager_check_running_screen_x11 ();
 #else
   return FALSE;
 #endif
diff --git a/src/tray/na-tray-manager.h b/src/tray/na-tray-manager.h
index 95ccdfd3e..727b02d40 100644
--- a/src/tray/na-tray-manager.h
+++ b/src/tray/na-tray-manager.h
@@ -88,10 +88,9 @@ struct _NaTrayManagerClass
 
 GType           na_tray_manager_get_type        (void);
 
-gboolean        na_tray_manager_check_running   (GdkScreen          *screen);
+gboolean        na_tray_manager_check_running   (void);
 NaTrayManager  *na_tray_manager_new             (void);
-gboolean        na_tray_manager_manage_screen   (NaTrayManager      *manager,
-                                                GdkScreen          *screen);
+gboolean        na_tray_manager_manage_screen   (NaTrayManager      *manager);
 void            na_tray_manager_set_orientation (NaTrayManager      *manager,
                                                 GtkOrientation      orientation);
 GtkOrientation  na_tray_manager_get_orientation (NaTrayManager      *manager);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]