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
This commit is contained in:
Robert Mader 2019-02-26 21:06:20 +01:00
parent 72be8eeb31
commit 94a674c008
3 changed files with 24 additions and 32 deletions

View File

@ -212,13 +212,7 @@ void
shell_tray_manager_manage_screen (ShellTrayManager *manager, shell_tray_manager_manage_screen (ShellTrayManager *manager,
StWidget *theme_widget) StWidget *theme_widget)
{ {
GdkDisplay *display; na_tray_manager_manage_screen (manager->priv->na_manager);
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);
g_signal_connect_object (theme_widget, "style-changed", g_signal_connect_object (theme_widget, "style-changed",
G_CALLBACK (shell_tray_manager_style_changed), G_CALLBACK (shell_tray_manager_style_changed),

View File

@ -70,7 +70,7 @@ static guint manager_signals[LAST_SIGNAL];
#define SYSTEM_TRAY_ORIENTATION_VERT 1 #define SYSTEM_TRAY_ORIENTATION_VERT 1
#ifdef GDK_WINDOWING_X11 #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 #endif
static void na_tray_manager_finalize (GObject *object); static void na_tray_manager_finalize (GObject *object);
@ -682,15 +682,15 @@ na_tray_manager_set_colors_property (NaTrayManager *manager)
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
static gboolean static gboolean
na_tray_manager_manage_screen_x11 (NaTrayManager *manager, na_tray_manager_manage_screen_x11 (NaTrayManager *manager)
GdkScreen *screen)
{ {
GdkDisplay *display; GdkDisplay *display;
Screen *xscreen; GdkScreen *screen;
GtkWidget *invisible; Screen *xscreen;
GdkWindow *window; GtkWidget *invisible;
char *selection_atom_name; GdkWindow *window;
guint32 timestamp; char *selection_atom_name;
guint32 timestamp;
g_return_val_if_fail (NA_IS_TRAY_MANAGER (manager), FALSE); g_return_val_if_fail (NA_IS_TRAY_MANAGER (manager), FALSE);
g_return_val_if_fail (manager->screen == NULL, 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. * we can't create another one.
*/ */
#if 0 #if 0
if (na_tray_manager_check_running_screen_x11 (screen)) if (na_tray_manager_check_running_screen_x11 ())
return FALSE; return FALSE;
#endif #endif
screen = gdk_screen_get_default ();
manager->screen = screen; manager->screen = screen;
display = gdk_screen_get_display (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); GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);
selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d", 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); manager->selection_atom = gdk_atom_intern (selection_atom_name, FALSE);
g_free (selection_atom_name); g_free (selection_atom_name);
@ -793,14 +794,12 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
#endif #endif
gboolean gboolean
na_tray_manager_manage_screen (NaTrayManager *manager, na_tray_manager_manage_screen (NaTrayManager *manager)
GdkScreen *screen)
{ {
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
g_return_val_if_fail (manager->screen == NULL, FALSE); g_return_val_if_fail (manager->screen == NULL, FALSE);
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
return na_tray_manager_manage_screen_x11 (manager, screen); return na_tray_manager_manage_screen_x11 (manager);
#else #else
return FALSE; return FALSE;
#endif #endif
@ -809,15 +808,17 @@ na_tray_manager_manage_screen (NaTrayManager *manager,
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
static gboolean static gboolean
na_tray_manager_check_running_screen_x11 (GdkScreen *screen) na_tray_manager_check_running_screen_x11 ()
{ {
GdkDisplay *display; GdkDisplay *display;
Atom selection_atom; GdkScreen *screen;
char *selection_atom_name; Atom selection_atom;
char *selection_atom_name;
screen = gdk_screen_get_default ();
display = gdk_screen_get_display (screen); display = gdk_screen_get_display (screen);
selection_atom_name = g_strdup_printf ("_NET_SYSTEM_TRAY_S%d", 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 = gdk_x11_get_xatom_by_name_for_display (display,
selection_atom_name); selection_atom_name);
g_free (selection_atom_name); g_free (selection_atom_name);
@ -832,12 +833,10 @@ na_tray_manager_check_running_screen_x11 (GdkScreen *screen)
#endif #endif
gboolean 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 #ifdef GDK_WINDOWING_X11
return na_tray_manager_check_running_screen_x11 (screen); return na_tray_manager_check_running_screen_x11 ();
#else #else
return FALSE; return FALSE;
#endif #endif

View File

@ -88,10 +88,9 @@ struct _NaTrayManagerClass
GType na_tray_manager_get_type (void); 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); NaTrayManager *na_tray_manager_new (void);
gboolean na_tray_manager_manage_screen (NaTrayManager *manager, gboolean na_tray_manager_manage_screen (NaTrayManager *manager);
GdkScreen *screen);
void na_tray_manager_set_orientation (NaTrayManager *manager, void na_tray_manager_set_orientation (NaTrayManager *manager,
GtkOrientation orientation); GtkOrientation orientation);
GtkOrientation na_tray_manager_get_orientation (NaTrayManager *manager); GtkOrientation na_tray_manager_get_orientation (NaTrayManager *manager);