From 9736a57f3a39d293daf30401a5ae8463a42b76e4 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Tue, 5 Dec 2017 00:27:00 +0100 Subject: WidthOfScreen and HeightOfScreen implementation This commit reverts: https://github.com/mate-desktop/mate-applets/commit/d809e57c7b09f545f1cf847f514fa738d44ac2b3 https://github.com/mate-desktop/mate-applets/commit/2f5515815c1f6c9b66f85d6ec228aad7aea0b441 And it applies an alternative to fix the deprecated functions: gdk_screen_get_width gdk_screen_get_height gdk_screen_width gdk_screen_height --- charpick/charpick.c | 7 +++---- cpufreq/src/cpufreq-applet.c | 10 +++------- stickynotes/stickynotes_applet.c | 8 ++------ 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/charpick/charpick.c b/charpick/charpick.c index e6f4fa74..b7863238 100644 --- a/charpick/charpick.c +++ b/charpick/charpick.c @@ -2,6 +2,7 @@ * accented (and other) characters to be pasted into other apps. */ +#include #include #include #include @@ -355,10 +356,8 @@ get_menu_pos (GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data) tempx += width; break; } - - gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()), - NULL, NULL, &screen_width, &screen_height); - + screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())); + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())); *x = CLAMP (tempx, 0, MAX (0, screen_width - reqmenu.width)); *y = CLAMP (tempy, 0, MAX (0, screen_height - reqmenu.height)); } diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c index 1b7e4b71..33812df2 100644 --- a/cpufreq/src/cpufreq-applet.c +++ b/cpufreq/src/cpufreq-applet.c @@ -24,6 +24,7 @@ #endif #include +#include #include #include #include @@ -415,8 +416,6 @@ cpufreq_applet_popup_position_menu (GtkMenu *menu, GtkAllocation allocation; gint menu_xpos; gint menu_ypos; - gint sc_width; - gint sc_height; widget = GTK_WIDGET (gdata); @@ -426,23 +425,20 @@ cpufreq_applet_popup_position_menu (GtkMenu *menu, gtk_widget_get_allocation (widget, &allocation); - gdk_window_get_geometry (gdk_screen_get_root_window (gtk_widget_get_screen (widget)), NULL, NULL, - &sc_width, &sc_height); - menu_xpos += allocation.x; menu_ypos += allocation.y; switch (mate_panel_applet_get_orient (MATE_PANEL_APPLET (widget))) { case MATE_PANEL_APPLET_ORIENT_DOWN: case MATE_PANEL_APPLET_ORIENT_UP: - if (menu_ypos > sc_height / 2) + if (menu_ypos > HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (widget))) / 2) menu_ypos -= requisition.height; else menu_ypos += allocation.height; break; case MATE_PANEL_APPLET_ORIENT_RIGHT: case MATE_PANEL_APPLET_ORIENT_LEFT: - if (menu_xpos > sc_width / 2) + if (menu_xpos > WidthOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (widget))) / 2) menu_xpos -= requisition.width; else menu_xpos += allocation.width; diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c index 2f1b4b76..c7c88ac2 100644 --- a/stickynotes/stickynotes_applet.c +++ b/stickynotes/stickynotes_applet.c @@ -24,6 +24,7 @@ #include "stickynotes.h" #include +#include StickyNotes *stickynotes = NULL; @@ -154,8 +155,6 @@ stickynotes_destroy (GtkWidget *widget, void stickynotes_applet_init (MatePanelApplet *mate_panel_applet) { - gint sc_height; - stickynotes = g_new(StickyNotes, 1); stickynotes->notes = NULL; @@ -191,10 +190,7 @@ stickynotes_applet_init (MatePanelApplet *mate_panel_applet) G_CALLBACK (preferences_apply_cb), NULL); /* Max height for large notes*/ - gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()), NULL, NULL, - NULL, &sc_height); - - stickynotes->max_height = 0.8 * sc_height; + stickynotes->max_height = 0.8 * HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())); /* Load sticky notes */ stickynotes_load (gtk_widget_get_screen (GTK_WIDGET (mate_panel_applet))); -- cgit v1.2.1