[Xfce4-commits] [xfce/xfce4-session] 02/06: replaced deprecated "gtk_display_get_screen" - For each display there is only one screen (See gtk3 doc of gdk_display_get_screen). So we can use gdk_display_get_default_screen (display) instead of looping on all screens. - The default screen is the screen of the default display ( no need to first get the default display if the default screen is required)
noreply at xfce.org
noreply at xfce.org
Sat Apr 6 23:38:27 CEST 2019
This is an automated email from the git hooks/post-receive script.
a n d 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 xfce/xfce4-session.
commit ef9da6722042b785abf4c10cea98cbec69b2c788
Author: Alexander Schwinn <alexxcons at xfce.org>
Date: Sat Mar 30 22:54:43 2019 +0100
replaced deprecated "gtk_display_get_screen"
- For each display there is only one screen (See gtk3 doc of gdk_display_get_screen). So we can use gdk_display_get_default_screen (display) instead of looping on all screens.
- The default screen is the screen of the default display ( no need to first get the default display if the default screen is required)
---
engines/balou/balou.c | 97 +++++++++++++++++---------------------
engines/mice/mice.c | 48 +++++++++----------
settings/module.c | 2 +-
xfce4-session/xfsm-fadeout.c | 11 ++---
xfce4-session/xfsm-legacy.c | 3 +-
xfce4-session/xfsm-manager.c | 18 ++-----
xfce4-session/xfsm-splash-screen.c | 2 +-
7 files changed, 75 insertions(+), 106 deletions(-)
diff --git a/engines/balou/balou.c b/engines/balou/balou.c
index 9e85cb5..7a41a29 100644
--- a/engines/balou/balou.c
+++ b/engines/balou/balou.c
@@ -80,9 +80,7 @@ balou_init (Balou *balou,
cairo_t *cr;
gint layout_height;
gint nmonitors;
- gint nscreens;
- gint i;
- gint n;
+ gint i = 0;
gint m;
gint px;
gint py;
@@ -100,69 +98,62 @@ balou_init (Balou *balou,
description = pango_font_description_from_string (balou_theme_get_font (theme));
/* determine number of required windows */
- nscreens = XScreenCount (gdk_x11_display_get_xdisplay (display));
- for (n = 0; n < nscreens; ++n)
- {
- screen = gdk_display_get_screen (display, n);
- nmonitors = gdk_screen_get_n_monitors (screen);
- for (m = 0; m < nmonitors; ++m)
- balou->nwindows++;
- }
+ screen = gdk_display_get_default_screen (display);
+ nmonitors = gdk_screen_get_n_monitors (screen);
+ for (m = 0; m < nmonitors; ++m)
+ balou->nwindows++;
/* create windows */
balou->windows = g_new (BalouWindow, balou->nwindows);
- for (i = n = 0; n < nscreens; ++n)
+ screen = gdk_display_get_default_screen (display);
+ nmonitors = gdk_screen_get_n_monitors (screen);
+ root = gdk_screen_get_root_window (screen);
+
+ /* create pango layout for this screen */
+ context = gdk_pango_context_get_for_screen (screen);
+ pango_context_set_font_description (context, description);
+ layout = pango_layout_new (context);
+ metrics = pango_context_get_metrics (context, description, NULL);
+ layout_height = (pango_font_metrics_get_ascent (metrics)
+ + pango_font_metrics_get_descent (metrics)) / PANGO_SCALE
+ + 3;
+ pango_font_metrics_unref (metrics);
+
+ for (m = 0; m < nmonitors; ++m)
{
- screen = gdk_display_get_screen (display, n);
- nmonitors = gdk_screen_get_n_monitors (screen);
- root = gdk_screen_get_root_window (screen);
-
- /* create pango layout for this screen */
- context = gdk_pango_context_get_for_screen (screen);
- pango_context_set_font_description (context, description);
- layout = pango_layout_new (context);
- metrics = pango_context_get_metrics (context, description, NULL);
- layout_height = (pango_font_metrics_get_ascent (metrics)
- + pango_font_metrics_get_descent (metrics)) / PANGO_SCALE
- + 3;
- pango_font_metrics_unref (metrics);
-
- for (m = 0; m < nmonitors; ++m)
- {
- cairo_t *window_cr;
- window = balou->windows + i;
- balou_window_init (window, screen, m, root, cursor);
-
- window->layout = PANGO_LAYOUT (g_object_ref (layout));
+ cairo_t *window_cr;
+ window = balou->windows + i;
+ balou_window_init (window, screen, m, root, cursor);
- /* calculate box dimensions */
- window->logobox = window->area;
- window->logobox.x = 0;
- window->logobox.height -= layout_height;
- window->textbox = window->area;
- window->textbox.x = 0;
- window->textbox.y += window->logobox.height;
- window->textbox.height -= window->logobox.height;
+ window->layout = PANGO_LAYOUT (g_object_ref (layout));
- window_cr = gdk_cairo_create (window->window);
+ /* calculate box dimensions */
+ window->logobox = window->area;
+ window->logobox.x = 0;
+ window->logobox.height -= layout_height;
+ window->textbox = window->area;
+ window->textbox.x = 0;
+ window->textbox.y += window->logobox.height;
+ window->textbox.height -= window->logobox.height;
- balou_theme_draw_gradient (balou->theme,
- window_cr,
- window->logobox,
- window->textbox);
+ window_cr = gdk_cairo_create (window->window);
- cairo_destroy (window_cr);
+ balou_theme_draw_gradient (balou->theme,
+ window_cr,
+ window->logobox,
+ window->textbox);
- if (mainscreen == screen && mainmonitor == m)
- balou->mainwin = window;
+ cairo_destroy (window_cr);
- ++i;
- }
+ if (mainscreen == screen && mainmonitor == m)
+ balou->mainwin = window;
- g_object_unref (context);
- g_object_unref (layout);
+ ++i;
}
+ g_object_unref (context);
+ g_object_unref (layout);
+
/* show splash windows */
for (i = 0; i < balou->nwindows; ++i)
{
diff --git a/engines/mice/mice.c b/engines/mice/mice.c
index 1f8e503..12b9f70 100644
--- a/engines/mice/mice.c
+++ b/engines/mice/mice.c
@@ -222,9 +222,8 @@ mice_setup (XfsmSplashEngine *engine,
cairo_t *cr;
GList *lp;
Mice *mice = MICE (engine->user_data);
- int nscreens;
int nmonitors;
- int n, m;
+ int m;
gdk_rgba_parse (&color, COLOR);
cursor = gdk_cursor_new_for_display (engine->display, GDK_WATCH);
@@ -242,37 +241,32 @@ mice_setup (XfsmSplashEngine *engine,
mice->step = 0;
mice->direction = 1;
- nscreens = XScreenCount (gdk_x11_display_get_xdisplay (engine->display));
- for (n = 0; n < nscreens; ++n)
- {
- screen = gdk_display_get_screen (engine->display, n);
- nmonitors = gdk_screen_get_n_monitors (screen);
- root = gdk_screen_get_root_window (screen);
+ screen = gdk_display_get_default_screen (engine->display);
+ nmonitors = gdk_screen_get_n_monitors (screen);
+ root = gdk_screen_get_root_window (screen);
- /* create graphics context for this screen */
- cr = gdk_cairo_create (root);
- gdk_cairo_set_source_rgba (cr, &color);
+ /* create graphics context for this screen */
+ cr = gdk_cairo_create (root);
+ gdk_cairo_set_source_rgba (cr, &color);
- cairo_rectangle (cr, 0, 0, mice->pixbuf_width, mice->pixbuf_height);
- cairo_fill (cr);
+ cairo_rectangle (cr, 0, 0, mice->pixbuf_width, mice->pixbuf_height);
+ cairo_fill (cr);
- cairo_move_to (cr, 0, 0);
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
- cairo_paint (cr);
-
- for (m = 0; m < nmonitors; ++m)
- {
- mice_window = mice_window_new (screen, m, pixbuf,
- &color, cursor, mice);
- mice->windows = g_list_append (mice->windows, mice_window);
+ cairo_move_to (cr, 0, 0);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
+ cairo_paint (cr);
- if (screen == engine->primary_screen && m == engine->primary_monitor)
- mice->mainwin = mice_window;
- }
+ for (m = 0; m < nmonitors; ++m)
+ {
+ mice_window = mice_window_new (screen, m, pixbuf,
+ &color, cursor, mice);
+ mice->windows = g_list_append (mice->windows, mice_window);
- /* cleanup for this screen */
- cairo_destroy (cr);
+ if (screen == engine->primary_screen && m == engine->primary_monitor)
+ mice->mainwin = mice_window;
}
+ cairo_destroy (cr);
+
/* show all windows and connect filters */
for (lp = mice->windows; lp != NULL; lp = lp->next)
diff --git a/settings/module.c b/settings/module.c
index 9cb7417..8b0dc3b 100644
--- a/settings/module.c
+++ b/settings/module.c
@@ -206,7 +206,7 @@ module_test (Module *module,
screen = xfce_gdk_screen_get_active (&monitor);
if (G_UNLIKELY (screen == NULL) || (gdk_screen_get_display(screen) != display))
{
- screen = gdk_display_get_screen (display, 0);
+ screen = gdk_display_get_default_screen (display);
monitor = 0;
}
diff --git a/xfce4-session/xfsm-fadeout.c b/xfce4-session/xfsm-fadeout.c
index 73e0aba..fe611de 100644
--- a/xfce4-session/xfsm-fadeout.c
+++ b/xfce4-session/xfsm-fadeout.c
@@ -152,19 +152,14 @@ xfsm_fadeout_new (GdkDisplay *display)
#ifdef GDK_WINDOWING_X11
Window xwindow;
#endif
- gint n;
fadeout = g_slice_new0 (XfsmFadeout);
#ifdef GDK_WINDOWING_X11
fadeout->xdisplay = gdk_x11_display_get_xdisplay (display);
-
- for (n = 0; n < XScreenCount (fadeout->xdisplay); ++n)
- {
- screen = gdk_display_get_screen (display, n);
- xwindow = xfsm_x11_fadeout_new_window (display, screen);
- fadeout->xwindows = g_slist_prepend (fadeout->xwindows, GINT_TO_POINTER (xwindow));
- }
+ screen = gdk_display_get_default_screen (display);
+ xwindow = xfsm_x11_fadeout_new_window (display, screen);
+ fadeout->xwindows = g_slist_prepend (fadeout->xwindows, GINT_TO_POINTER (xwindow));
#endif
return fadeout;
diff --git a/xfce4-session/xfsm-legacy.c b/xfce4-session/xfsm-legacy.c
index 6026673..9e6b009 100644
--- a/xfce4-session/xfsm-legacy.c
+++ b/xfce4-session/xfsm-legacy.c
@@ -629,8 +629,7 @@ xfsm_legacy_startup (void)
for (lp = restart_apps; lp != NULL; lp = lp->next)
{
- screen = gdk_display_get_screen (gdk_display_get_default (),
- SM_RESTART_APP (lp->data)->screen_num);
+ screen = gdk_screen_get_default ();
xfsm_start_application (SM_RESTART_APP (lp->data)->command, NULL,
screen, NULL, NULL, NULL);
g_strfreev (SM_RESTART_APP (lp->data)->command);
diff --git a/xfce4-session/xfsm-manager.c b/xfce4-session/xfsm-manager.c
index bf189a4..3d26134 100644
--- a/xfce4-session/xfsm-manager.c
+++ b/xfce4-session/xfsm-manager.c
@@ -603,14 +603,12 @@ xfsm_manager_load_failsafe (XfsmManager *manager,
{
FailsafeClient *fclient;
gchar *failsafe_name;
- GdkDisplay *display;
gchar propbuf[4096];
gchar **command;
gchar command_entry[256];
gchar screen_entry[256];
gint count;
gint i;
- gint n_screen;
failsafe_name = xfconf_channel_get_string (channel, "/general/FailsafeSessionName", NULL);
if (G_UNLIKELY (!failsafe_name))
@@ -634,8 +632,6 @@ xfsm_manager_load_failsafe (XfsmManager *manager,
return FALSE;
}
- display = gdk_display_get_default ();
-
g_snprintf (propbuf, sizeof (propbuf), "/sessions/%s/Count", failsafe_name);
count = xfconf_channel_get_int (channel, propbuf, 0);
@@ -651,16 +647,10 @@ xfsm_manager_load_failsafe (XfsmManager *manager,
"/sessions/%s/Client%d_PerScreen", failsafe_name, i);
if (xfconf_channel_get_bool (channel, screen_entry, FALSE))
{
- for (n_screen = 0; n_screen < XScreenCount (gdk_x11_display_get_xdisplay (display)); ++n_screen)
- {
- fclient = g_new0 (FailsafeClient, 1);
- if (n_screen == 0)
- fclient->command = command;
- else
- fclient->command = g_strdupv (command);
- fclient->screen = gdk_display_get_screen (display, n_screen);
- g_queue_push_tail (manager->failsafe_clients, fclient);
- }
+ fclient = g_new0 (FailsafeClient, 1);
+ fclient->command = command;
+ fclient->screen = gdk_screen_get_default ();
+ g_queue_push_tail (manager->failsafe_clients, fclient);
}
else
{
diff --git a/xfce4-session/xfsm-splash-screen.c b/xfce4-session/xfsm-splash-screen.c
index fac1aaf..60ba68c 100644
--- a/xfce4-session/xfsm-splash-screen.c
+++ b/xfce4-session/xfsm-splash-screen.c
@@ -70,7 +70,7 @@ xfsm_splash_screen_new (GdkDisplay *display,
if (G_UNLIKELY (screen == NULL) || (gdk_screen_get_display (screen) != display))
{
- screen = gdk_display_get_screen (display, 0);
+ screen = gdk_display_get_default_screen (display);
monitor = 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list