summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorPablo Barciela <[email protected]>2017-12-04 01:01:52 +0100
committerraveit65 <[email protected]>2017-12-16 20:04:18 +0100
commit2fea2c846689d3810def93e6e0e6eeb01c2ef718 (patch)
tree3ec5bb043842bbc5e6e9e504a4b4adc2ef22aecf /eel
parentc6b81f64c4c4212e414c04e584380774d6ac83ca (diff)
downloadcaja-2fea2c846689d3810def93e6e0e6eeb01c2ef718.tar.bz2
caja-2fea2c846689d3810def93e6e0e6eeb01c2ef718.tar.xz
WidthOfScreen and HeightOfScreen implementation
This commit reverts: https://github.com/mate-desktop/caja/commit/4c130e22b98bbc1a85747adac3b582e45d34514e https://github.com/mate-desktop/caja/commit/ac12e6d16f4a51b3327d013781e72cfec17f3624 https://github.com/mate-desktop/caja/commit/17b3c0ca924ffcd4bd06fded98227eba626d4f0b https://github.com/mate-desktop/caja/commit/42c8d2c3373c25d6e321be6950997c0d7ce44279 And it applies an alternative to fix the deprecated functions: gdk_screen_get_width gdk_screen_get_height gdk_screen_width gdk_screen_height
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-background.c30
-rw-r--r--eel/eel-editable-label.c15
-rw-r--r--eel/eel-gtk-extensions.c23
3 files changed, 13 insertions, 55 deletions
diff --git a/eel/eel-background.c b/eel/eel-background.c
index 53e0a652..8de791ec 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -31,7 +31,7 @@
#include "eel-lib-self-check-functions.h"
#include <gtk/gtk.h>
#include <eel/eel-canvas.h>
-# include <cairo-xlib.h>
+#include <cairo-xlib.h>
#include <gdk/gdkx.h>
#include <gio/gio.h>
#include <math.h>
@@ -311,33 +311,9 @@ drawable_get_adjusted_size (EelBackground *self,
{
if (self->details->is_desktop)
{
-#if GTK_CHECK_VERSION (3, 22, 0)
- GdkRectangle geometry;
- GdkMonitor *monitor;
- GdkDisplay *display;
- int n = 0;
- int i = 0;
- int sc_width = 0;
- int sc_height = 0;
-
- display = gtk_widget_get_display (self->details->widget);
- n = gdk_display_get_n_monitors (display);
-
- for (i = 0; i < n; ++i)
- {
- monitor = gdk_display_get_monitor (display, i);
- gdk_monitor_get_geometry (monitor, &geometry);
- sc_width = sc_width + geometry.width;
- sc_height = sc_height + geometry.height;
- }
-
- *width = sc_width;
- *height = sc_height;
-#else
GdkScreen *screen = gtk_widget_get_screen (self->details->widget);
- *width = gdk_screen_get_width (screen);
- *height = gdk_screen_get_height (screen);
-#endif
+ *width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
+ *height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
}
else
{
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index fb1fb29b..8b98a273 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -36,6 +36,7 @@
#include <pango/pango.h>
#include <gtk/gtk.h>
#include <gtk/gtk-a11y.h>
+#include <gdk/gdkx.h>
#include <gdk/gdkkeysyms.h>
@@ -1051,7 +1052,6 @@ eel_editable_label_ensure_layout (EelEditableLabel *label,
else
{
gint wrap_width;
- gint sc_width;
pango_layout_set_width (label->layout, -1);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
@@ -1061,13 +1061,10 @@ eel_editable_label_ensure_layout (EelEditableLabel *label,
/* Try to guess a reasonable maximum width */
longest_paragraph = width;
- gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()),
- NULL, NULL, &sc_width, NULL);
-
wrap_width = get_label_wrap_width (label);
width = MIN (width, wrap_width);
width = MIN (width,
- PANGO_SCALE * (sc_width + 1) / 2);
+ PANGO_SCALE * (WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) + 1) / 2);
pango_layout_set_width (label->layout, width);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
@@ -3051,7 +3048,6 @@ popup_position_func (GtkMenu *menu,
GtkWidget *widget;
GtkRequisition req;
GtkAllocation allocation;
- gint sc_width, sc_height;
label = EEL_EDITABLE_LABEL (user_data);
widget = GTK_WIDGET (label);
@@ -3066,11 +3062,8 @@ popup_position_func (GtkMenu *menu,
*x += allocation.width / 2;
*y += allocation.height;
- gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()),
- NULL, NULL, &sc_width, &sc_height);
-
- *x = CLAMP (*x, 0, MAX (0, sc_width - req.width));
- *y = CLAMP (*y, 0, MAX (0, sc_height - req.height));
+ *x = CLAMP (*x, 0, MAX (0, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - req.width));
+ *y = CLAMP (*y, 0, MAX (0, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - req.height));
}
static void
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index e388636a..1fd156c0 100644
--- a/eel/eel-gtk-extensions.c
+++ b/eel/eel-gtk-extensions.c
@@ -86,11 +86,6 @@ eel_gtk_window_get_geometry_string (GtkWindow *window)
static void
sanity_check_window_position (int *left, int *top)
{
- gint sc_width, sc_height;
-
- gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()),
- NULL, NULL, &sc_width, &sc_height);
-
g_assert (left != NULL);
g_assert (top != NULL);
@@ -100,7 +95,7 @@ sanity_check_window_position (int *left, int *top)
* isn't off the bottom of the screen, or so close to the bottom
* that it might be obscured by the panel.
*/
- *top = CLAMP (*top, 0, sc_height - MINIMUM_ON_SCREEN_HEIGHT);
+ *top = CLAMP (*top, 0, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - MINIMUM_ON_SCREEN_HEIGHT);
/* FIXME bugzilla.eazel.com 669:
* If window has negative left coordinate, set_uposition sends it
@@ -113,17 +108,12 @@ sanity_check_window_position (int *left, int *top)
* the screen, or so close to the right edge that it might be
* obscured by the panel.
*/
- *left = CLAMP (*left, 0, sc_width - MINIMUM_ON_SCREEN_WIDTH);
+ *left = CLAMP (*left, 0, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) - MINIMUM_ON_SCREEN_WIDTH);
}
static void
sanity_check_window_dimensions (guint *width, guint *height)
{
- gint sc_width, sc_height;
-
- gdk_window_get_geometry (gdk_screen_get_root_window (gdk_screen_get_default()),
- NULL, NULL, &sc_width, &sc_height);
-
g_assert (width != NULL);
g_assert (height != NULL);
@@ -132,8 +122,8 @@ sanity_check_window_dimensions (guint *width, guint *height)
* be reached (might not be necessary with all window managers,
* but seems reasonable anyway).
*/
- *width = MIN (*width, sc_width);
- *height = MIN (*height, sc_height);
+ *width = MIN (*width, WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())));
+ *height = MIN (*height, HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())));
}
/**
@@ -178,9 +168,8 @@ eel_gtk_window_set_initial_geometry (GtkWindow *window,
real_top = top;
screen = gtk_window_get_screen (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));
/* This is sub-optimal. GDK doesn't allow us to set win_gravity
* to South/East types, which should be done if using negative