summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eel/eel-background.c17
-rw-r--r--eel/eel-editable-label.c2
-rw-r--r--eel/eel-gtk-extensions.c44
-rw-r--r--libcaja-private/caja-autorun.c20
-rw-r--r--libcaja-private/caja-file-operations.c6
-rw-r--r--libcaja-private/caja-icon-container.c41
-rw-r--r--libcaja-private/caja-icon-dnd.c15
-rw-r--r--src/caja-application.c48
-rw-r--r--src/caja-main.c2
-rw-r--r--src/caja-window.c6
10 files changed, 111 insertions, 90 deletions
diff --git a/eel/eel-background.c b/eel/eel-background.c
index ae585d6a..5b00f849 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -311,9 +311,20 @@ drawable_get_adjusted_size (EelBackground *self,
if (self->details->is_desktop)
{
GdkScreen *screen = gtk_widget_get_screen (self->details->widget);
- gint scale = gtk_widget_get_scale_factor (self->details->widget);
- *width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
- *height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ GdkDisplay *display = gdk_screen_get_display (screen);
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ gint scale = gtk_widget_get_scale_factor (self->details->widget);
+ *width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ *height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ }
+ else {
+ GdkRectangle workarea = {0};
+ gdk_monitor_get_workarea(gdk_display_get_monitor_at_window(gdk_display_get_default(),
+ gtk_widget_get_window (self->details->widget)), &workarea);
+ *width = workarea.width;
+ *height = workarea.height;
+ }
}
else
{
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index d18f5df9..92ce7015 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -1042,7 +1042,7 @@ eel_editable_label_ensure_layout (EelEditableLabel *label,
scale = gtk_widget_get_scale_factor (widget);
width = MIN (width, wrap_width);
width = MIN (width,
- PANGO_SCALE * (WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale + 1) / 2);
+ PANGO_SCALE * (gdk_screen_width () + 1) / 2);
pango_layout_set_width (label->layout, width);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index 2218b02b..21c3c358 100644
--- a/eel/eel-gtk-extensions.c
+++ b/eel/eel-gtk-extensions.c
@@ -80,22 +80,23 @@ eel_gtk_window_get_geometry_string (GtkWindow *window)
static void
sanity_check_window_position (int *left, int *top)
{
- GdkScreen *screen;
- gint scale;
-
g_assert (left != NULL);
g_assert (top != NULL);
-
- screen = gdk_screen_get_default ();
- scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+ GdkDisplay *display;
+ GdkWindow *root_window;
+ GdkRectangle workarea = {0};
/* Make sure the top of the window is on screen, for
* draggability (might not be necessary with all window managers,
* but seems reasonable anyway). Make sure the top of the window
* 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, HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale - MINIMUM_ON_SCREEN_HEIGHT);
+ root_window = gdk_screen_get_root_window (gdk_screen_get_default());
+ display = gdk_display_get_default ();
+ gdk_monitor_get_workarea(gdk_display_get_monitor_at_window (display, root_window), &workarea);
+ *top = CLAMP (*top, 0, workarea.height - MINIMUM_ON_SCREEN_HEIGHT);
/* FIXME bugzilla.eazel.com 669:
* If window has negative left coordinate, set_uposition sends it
@@ -108,33 +109,23 @@ 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, WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale - MINIMUM_ON_SCREEN_WIDTH);
+ *left = CLAMP (*left, 0, workarea.width - MINIMUM_ON_SCREEN_WIDTH);
}
static void
sanity_check_window_dimensions (guint *width, guint *height)
{
- GdkScreen *screen;
- int screen_width;
- int screen_height;
- int scale;
-
g_assert (width != NULL);
g_assert (height != NULL);
- screen = gdk_screen_get_default ();
- scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
- screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
- screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
-
/* Pin the size of the window to the screen, so we don't end up in
* a state where the window is so big essential parts of it can't
* be reached (might not be necessary with all window managers,
* but seems reasonable anyway).
*/
- *width = MIN (*width, (guint) screen_width);
- *height = MIN (*height, (guint) screen_height);
-}
+ *width = MIN ((int)*width, gdk_screen_width());
+ *height = MIN ((int)*height, gdk_screen_height());
+ }
/**
* eel_gtk_window_set_initial_geometry:
@@ -160,7 +151,9 @@ eel_gtk_window_set_initial_geometry (GtkWindow *window,
guint width,
guint height)
{
+ GdkScreen *screen;
int real_left, real_top;
+ int screen_width, screen_height;
g_return_if_fail (GTK_IS_WINDOW (window));
@@ -172,17 +165,12 @@ eel_gtk_window_set_initial_geometry (GtkWindow *window,
if ((geometry_flags & EEL_GDK_X_VALUE) && (geometry_flags & EEL_GDK_Y_VALUE))
{
- GdkScreen *screen;
- int screen_width, screen_height;
- int scale;
-
real_left = left;
real_top = top;
screen = gtk_window_get_screen (window);
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (window));
- screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
- screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ screen_width = gdk_screen_get_width (screen);
+ screen_height = gdk_screen_get_height (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
diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c
index 2f79b16b..b78ea1c7 100644
--- a/libcaja-private/caja-autorun.c
+++ b/libcaja-private/caja-autorun.c
@@ -761,16 +761,22 @@ is_shift_pressed (void)
Bool status;
ret = FALSE;
-
display = gdk_display_get_default ();
- gdk_x11_display_error_trap_push (display);
- status = XkbGetState (GDK_DISPLAY_XDISPLAY (display),
- XkbUseCoreKbd, &state);
- gdk_x11_display_error_trap_pop_ignored (display);
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ gdk_x11_display_error_trap_push (display);
+ status = XkbGetState (GDK_DISPLAY_XDISPLAY (display),
+ XkbUseCoreKbd, &state);
+ gdk_x11_display_error_trap_pop_ignored (display);
- if (status == Success)
+ if (status == Success)
+ {
+ ret = state.mods & ShiftMask;
+ }
+ }
+ else
{
- ret = state.mods & ShiftMask;
+ ret=FALSE;
}
return ret;
diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c
index 60193d47..8676800e 100644
--- a/libcaja-private/caja-file-operations.c
+++ b/libcaja-private/caja-file-operations.c
@@ -962,7 +962,11 @@ init_common (gsize job_size,
GdkScreen *screen;
screen = gtk_widget_get_screen (GTK_WIDGET (parent_window));
- common->screen_num = gdk_x11_screen_get_screen_number (screen);
+ /*common->screen_num = gdk_x11_screen_get_screen_number (screen);*
+ *https://discourse.ubuntu.com/t/porting-mate-apps-to-wayland/12670
+ *Screen number is always 0 with >GTK 3.22 so we can just use zero here
+ */
+ common->screen_num = 0;
}
return common;
diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c
index bb912d4b..7b19516d 100644
--- a/libcaja-private/caja-icon-container.c
+++ b/libcaja-private/caja-icon-container.c
@@ -324,7 +324,9 @@ icon_set_position_full (CajaIcon *icon,
int item_width, item_height;
int height_above, width_left;
int min_x, max_x, min_y, max_y;
- int scale;
+ GdkWindow *window;
+ GdkMonitor *monitor;
+ GdkRectangle workarea = {0};
/* FIXME: This should be:
@@ -338,14 +340,17 @@ icon_set_position_full (CajaIcon *icon,
really bad.
For now, we have a cheesy workaround:
+ note that this version does not require scaling
*/
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (container));
+ window = gtk_widget_get_window (GTK_WIDGET(container));
+ monitor = gdk_display_get_monitor_at_window (gdk_display_get_default(), window);
+ gdk_monitor_get_workarea(monitor, &workarea);
container_x = 0;
container_y = 0;
- container_width = WidthOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - container_x
+ container_width = workarea.width - container_x
- container->details->left_margin
- container->details->right_margin;
- container_height = HeightOfScreen (gdk_x11_screen_get_xscreen (gdk_screen_get_default ())) / scale - container_y
+ container_height = workarea.height - container_y
- container->details->top_margin
- container->details->bottom_margin;
pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit;
@@ -5253,17 +5258,19 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
gint x, y;
gint cont_x, cont_y;
gint cont_width, cont_height;
- gint scale;
GdkWindow *cont_window;
GdkScreen *screen;
GtkRequisition requisition;
GdkMonitor *monitor_num;
GdkRectangle monitor;
+ GdkRectangle workarea = {0};
cont_window = gtk_widget_get_window (GTK_WIDGET (container));
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (container));
screen = gdk_window_get_screen (cont_window);
+ monitor_num = gdk_display_get_monitor_at_window (gdk_display_get_default(), cont_window);
+ gdk_monitor_get_workarea(monitor_num, &workarea);
+
monitor_num = gdk_display_get_monitor_at_window (gdk_screen_get_display (screen),
cont_window);
gdk_monitor_get_geometry (monitor_num, &monitor);
@@ -5277,9 +5284,9 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
gtk_widget_get_preferred_size (search_dialog, &requisition, NULL);
- if (cont_x + cont_width - requisition.width > WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale)
+ if (cont_x + cont_width - requisition.width > workarea.width)
{
- x = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale - requisition.width;
+ x = workarea.width - requisition.width;
}
else if (cont_x + cont_width - requisition.width < 0)
{
@@ -5290,9 +5297,9 @@ caja_icon_container_search_position_func (CajaIconContainer *container,
x = cont_x + cont_width - requisition.width;
}
- if (cont_y + cont_height > HeightOfScreen (gdk_x11_screen_get_xscreen (screen)))
+ if (cont_y + cont_height > workarea.height)
{
- y = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) - requisition.height;
+ y = workarea.height - requisition.height;
}
else if (cont_y + cont_height < 0) /* isn't really possible ... */
{
@@ -6034,13 +6041,13 @@ key_press_event (GtkWidget *widget,
{
GdkEvent *new_event;
GdkWindow *window;
+ GdkDisplay *display;
+ GdkRectangle workarea = {0};
char *old_text;
const char *new_text;
gboolean retval;
- GdkScreen *screen;
gboolean text_modified;
gulong popup_menu_id;
- gint scale;
caja_icon_container_ensure_interactive_directory (container);
@@ -6055,12 +6062,12 @@ key_press_event (GtkWidget *widget,
"popup_menu", G_CALLBACK (gtk_true), NULL);
/* Move the entry off screen */
- screen = gtk_widget_get_screen (GTK_WIDGET (container));
- scale = gtk_widget_get_scale_factor (GTK_WIDGET (container));
- gtk_window_move (GTK_WINDOW (container->details->search_window),
- WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale + 1,
- HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale + 1);
gtk_widget_show (container->details->search_window);
+ display = gdk_display_get_default ();
+ gdk_monitor_get_workarea(gdk_display_get_monitor_at_window (display, window), &workarea);
+ gtk_window_move (GTK_WINDOW (container->details->search_window),
+ workarea.width + 1,
+ workarea.height + 1);
/* Send the event to the window. If the preedit_changed signal is emitted
* during this event, we will set priv->imcontext_changed */
diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c
index b9dfc36f..913e085f 100644
--- a/libcaja-private/caja-icon-dnd.c
+++ b/libcaja-private/caja-icon-dnd.c
@@ -946,7 +946,6 @@ handle_local_move (CajaIconContainer *container,
GList *moved_icons, *p;
CajaFile *file;
char screen_string[32];
- GdkScreen *screen;
time_t now;
CajaDragSelectionItem *item = NULL;
CajaIcon *icon = NULL;
@@ -971,13 +970,15 @@ handle_local_move (CajaIconContainer *container,
{
/* probably dragged from another screen. Add it to
* this screen
+ * Update: since GTK 3.22 there is only ONE screen
+ * even with multiple monitors
*/
file = caja_file_get_by_uri (item->uri);
-
- screen = gtk_widget_get_screen (GTK_WIDGET (container));
+
g_snprintf (screen_string, sizeof (screen_string), "%d",
- gdk_x11_screen_get_screen_number (screen));
+ /*gdk_x11_screen_get_screen_number (screen)); This is ALWAYS 0 since GTK 3.22*/
+ 0);
caja_file_set_metadata (file,
CAJA_METADATA_KEY_SCREEN,
NULL, screen_string);
@@ -1906,8 +1907,10 @@ drag_data_received_callback (GtkWidget *widget,
caja_file_changes_queue_schedule_position_set (
location,
p,
- gdk_x11_screen_get_screen_number (
- gtk_widget_get_screen (widget)));
+ 0);
+ /*gdk_x11_screen_get_screen_number
+ *Always returns 0 since GTK 3.22
+ */
g_object_unref (location);
caja_file_changes_consume_changes (TRUE);
success = TRUE;
diff --git a/src/caja-application.c b/src/caja-application.c
index 5f7a8ac4..1467e421 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -634,38 +634,44 @@ selection_get_cb (GtkWidget *widget,
static GtkWidget *
get_desktop_manager_selection (GdkDisplay *display)
{
- char selection_name[32];
- GdkAtom selection_atom;
- Window selection_owner;
- GtkWidget *selection_widget;
-
- g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S0");
- selection_atom = gdk_atom_intern (selection_name, FALSE);
-
- selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
+ /*FIXME: for Wayland we need a new desktop canvas anyway
+ *so when that is ready we will need to add a wayland code
+ *path here to support it
+ */
+ if (GDK_IS_X11_DISPLAY (display)){
+ char selection_name[32];
+ GdkAtom selection_atom;
+ Window selection_owner;
+ GtkWidget *selection_widget;
+
+ g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S0");
+ selection_atom = gdk_atom_intern (selection_name, FALSE);
+
+ selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
gdk_x11_atom_to_xatom_for_display (display,
selection_atom));
- if (selection_owner != None)
- {
+ if (selection_owner != None)
+ {
return NULL;
- }
+ }
- selection_widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display));
- /* We need this for gdk_x11_get_server_time() */
- gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK);
+ selection_widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display));
+ /* We need this for gdk_x11_get_server_time() */
+ gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK);
- if (gtk_selection_owner_set_for_display (display,
+ if (gtk_selection_owner_set_for_display (display,
selection_widget,
selection_atom,
gdk_x11_get_server_time (gtk_widget_get_window (selection_widget))))
- {
+ {
- g_signal_connect (selection_widget, "selection_get",
+ g_signal_connect (selection_widget, "selection_get",
G_CALLBACK (selection_get_cb), NULL);
- return selection_widget;
- }
+ return selection_widget;
+ }
- gtk_widget_destroy (selection_widget);
+ gtk_widget_destroy (selection_widget);
+ }
return NULL;
}
diff --git a/src/caja-main.c b/src/caja-main.c
index 75ccbdf5..11871257 100644
--- a/src/caja-main.c
+++ b/src/caja-main.c
@@ -250,8 +250,6 @@ main (int argc, char *argv[])
g_set_prgname ("caja");
- gdk_set_allowed_backends ("x11");
-
if (g_file_test (DATADIR "/applications/caja.desktop", G_FILE_TEST_EXISTS)) {
egg_set_desktop_file (DATADIR "/applications/caja.desktop");
}
diff --git a/src/caja-window.c b/src/caja-window.c
index 2417e07c..a67a5ee4 100644
--- a/src/caja-window.c
+++ b/src/caja-window.c
@@ -591,8 +591,7 @@ caja_window_zoom_to_default (CajaWindow *window)
static guint
get_max_forced_height (GdkScreen *screen)
{
- gint scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
- return (HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale * 90) / 100;
+ return (gdk_screen_get_height (screen) * 90) / 100;
}
/* Code should never force the window wider than this size.
@@ -601,8 +600,7 @@ get_max_forced_height (GdkScreen *screen)
static guint
get_max_forced_width (GdkScreen *screen)
{
- gint scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
- return (WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale * 90) / 100;
+ return (gdk_screen_get_width (screen) * 90) / 100;
}
/* This must be called when construction of CajaWindow is finished,