From 10b38211e032738593dfe71176289c275956b476 Mon Sep 17 00:00:00 2001 From: Pablo Barciela Date: Thu, 7 Dec 2017 01:37:08 +0100 Subject: WidthOfScreen and HeightOfScreen implementation This commit reverts: https://github.com/mate-desktop/mate-panel/commit/7b2bc7d9f98c6ba8c2c31bdf9605faadb42a7e0e And it applies an alternative to fix the deprecated functions: gdk_screen_get_width gdk_screen_get_height --- applets/clock/clock.c | 5 ++--- applets/fish/fish.c | 5 +++-- applets/notification_area/system-tray/fixedtip.c | 5 +++-- libmate-panel-applet/mate-panel-applet.c | 13 ++++--------- mate-panel/applet.c | 13 ++++--------- mate-panel/panel-addto.c | 6 ++---- mate-panel/panel-force-quit.c | 4 ++-- mate-panel/panel-struts.c | 5 +++-- mate-panel/panel-toplevel.c | 10 +++------- 9 files changed, 26 insertions(+), 40 deletions(-) diff --git a/applets/clock/clock.c b/applets/clock/clock.c index 622e3adf..0076c780 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -925,9 +925,8 @@ position_calendar_popup (ClockData *cd) monitors */ monitor.x = 0; monitor.y = 0; - - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - &monitor.width, &monitor.height); + monitor.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + monitor.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); } /* Based on panel orientation, position the popup. diff --git a/applets/fish/fish.c b/applets/fish/fish.c index 56def60c..dd18c508 100644 --- a/applets/fish/fish.c +++ b/applets/fish/fish.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -856,8 +857,8 @@ static void display_fortune_dialog(FishApplet* fish) screen = gtk_widget_get_screen (GTK_WIDGET (fish)); - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - &screen_width, &screen_height); + screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); gtk_window_set_default_size (GTK_WINDOW (fish->fortune_dialog), MIN (600, screen_width * 0.9), diff --git a/applets/notification_area/system-tray/fixedtip.c b/applets/notification_area/system-tray/fixedtip.c index eca42a3f..d233424e 100644 --- a/applets/notification_area/system-tray/fixedtip.c +++ b/applets/notification_area/system-tray/fixedtip.c @@ -20,6 +20,7 @@ * 02110-1301, USA. */ +#include #include "fixedtip.h" /* Signals */ @@ -158,8 +159,8 @@ na_fixed_tip_position (NaFixedTip *fixedtip) parent_width = gdk_window_get_width(parent_window); parent_height = gdk_window_get_height(parent_window); - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - &screen_width, &screen_height); + screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); /* pad between panel and message window */ #define PAD 5 diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index b60ca71c..6b6d58fb 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -796,8 +796,6 @@ mate_panel_applet_position_menu (GtkMenu *menu, int menu_y = 0; int pointer_x; int pointer_y; - int screen_width; - int screen_height; g_return_if_fail (PANEL_IS_APPLET (widget)); @@ -821,9 +819,6 @@ mate_panel_applet_position_menu (GtkMenu *menu, menu_x += allocation.x; menu_y += allocation.y; - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - &screen_width, &screen_height); - if (applet->priv->orient == MATE_PANEL_APPLET_ORIENT_UP || applet->priv->orient == MATE_PANEL_APPLET_ORIENT_DOWN) { if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) { @@ -839,9 +834,9 @@ mate_panel_applet_position_menu (GtkMenu *menu, allocation.width - requisition.width); } } - menu_x = MIN (menu_x, screen_width - requisition.width); + menu_x = MIN (menu_x, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) - requisition.width); - if (menu_y > screen_height / 2) + if (menu_y > HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / 2) menu_y -= requisition.height; else menu_y += allocation.height; @@ -849,9 +844,9 @@ mate_panel_applet_position_menu (GtkMenu *menu, if (pointer_y < allocation.height && requisition.height < pointer_y) menu_y += MIN (pointer_y, allocation.height - requisition.height); - menu_y = MIN (menu_y, screen_height - requisition.height); + menu_y = MIN (menu_y, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) - requisition.height); - if (menu_x > screen_width / 2) + if (menu_x > WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / 2) menu_x -= requisition.width; else menu_x += allocation.width; diff --git a/mate-panel/applet.c b/mate-panel/applet.c index 86399908..13f31d7e 100644 --- a/mate-panel/applet.c +++ b/mate-panel/applet.c @@ -641,8 +641,6 @@ mate_panel_applet_position_menu (GtkMenu *menu, int menu_y = 0; int pointer_x; int pointer_y; - int screen_width; - int screen_height; parent = gtk_widget_get_parent (applet); @@ -667,9 +665,6 @@ mate_panel_applet_position_menu (GtkMenu *menu, menu_y += allocation.y; } - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - &screen_width, &screen_height); - if (PANEL_WIDGET (parent)->orient == GTK_ORIENTATION_HORIZONTAL) { if (gtk_widget_get_direction (GTK_WIDGET (menu)) != GTK_TEXT_DIR_RTL) { if (pointer_x < allocation.width && @@ -684,9 +679,9 @@ mate_panel_applet_position_menu (GtkMenu *menu, allocation.width - requisition.width); } } - menu_x = MIN (menu_x, screen_width - requisition.width); + menu_x = MIN (menu_x, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) - requisition.width); - if (menu_y > screen_height / 2) + if (menu_y > HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / 2) menu_y -= requisition.height; else menu_y += allocation.height; @@ -694,9 +689,9 @@ mate_panel_applet_position_menu (GtkMenu *menu, if (pointer_y < allocation.height && requisition.height < pointer_y) menu_y += MIN (pointer_y, allocation.height - requisition.height); - menu_y = MIN (menu_y, screen_height - requisition.height); + menu_y = MIN (menu_y, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) - requisition.height); - if (menu_x > screen_width / 2) + if (menu_x > WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / 2) menu_x -= requisition.width; else menu_x += allocation.width; diff --git a/mate-panel/panel-addto.c b/mate-panel/panel-addto.c index 2e2ff712..e6cae0eb 100644 --- a/mate-panel/panel-addto.c +++ b/mate-panel/panel-addto.c @@ -27,6 +27,7 @@ #include #include +#include #include @@ -1373,10 +1374,7 @@ panel_addto_present (GtkMenuItem *item, panel_addto_dialog_quark); screen = gtk_window_get_screen (GTK_WINDOW (toplevel)); - - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - NULL, &screen_height); - + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); height = MIN (MAX_ADDTOPANEL_HEIGHT, 3 * (screen_height / 4)); if (!dialog) { diff --git a/mate-panel/panel-force-quit.c b/mate-panel/panel-force-quit.c index 71ec4f8c..ffb82274 100644 --- a/mate-panel/panel-force-quit.c +++ b/mate-panel/panel-force-quit.c @@ -86,8 +86,8 @@ display_popup_window (GdkScreen *screen) gtk_widget_realize (retval); - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - &screen_width, &screen_height); + screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); gtk_widget_get_allocation (retval, &allocation); diff --git a/mate-panel/panel-struts.c b/mate-panel/panel-struts.c index 76e5c655..644dafb0 100644 --- a/mate-panel/panel-struts.c +++ b/mate-panel/panel-struts.c @@ -22,6 +22,7 @@ */ #include +#include #include "panel-struts.h" @@ -268,8 +269,8 @@ panel_struts_set_window_hint (PanelToplevel *toplevel) strut_size = strut->allocated_strut_size; - gdk_window_get_geometry (gdk_screen_get_root_window (strut->screen), NULL, NULL, - &screen_width, &screen_height); + screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (strut->screen)); + screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (strut->screen)); panel_struts_get_monitor_geometry (strut->screen, strut->monitor, diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c index c95bc641..7aa61e42 100644 --- a/mate-panel/panel-toplevel.c +++ b/mate-panel/panel-toplevel.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -277,19 +278,14 @@ gboolean panel_toplevel_is_last_unattached(PanelToplevel* toplevel) static GdkScreen* panel_toplevel_get_screen_geometry(PanelToplevel* toplevel, int* width, int* height) { GdkScreen* screen; - gint screen_width; - gint screen_height; g_return_val_if_fail(PANEL_IS_TOPLEVEL (toplevel), NULL); g_return_val_if_fail(width != NULL && height != NULL, NULL); screen = gtk_window_get_screen(GTK_WINDOW(toplevel)); - gdk_window_get_geometry (gdk_screen_get_root_window (screen), NULL, NULL, - &screen_width, &screen_height); - - *width = screen_width; - *height = screen_height; + *width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + *height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); return screen; } -- cgit v1.2.1