summaryrefslogtreecommitdiff
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2017-03-23 07:51:19 +0100
committerMartin Rudalics <rudalics@gmx.at>2017-03-23 07:51:19 +0100
commitfe3af8d4f2a4cd67958f76d1b708e8a78e68cd4f (patch)
treea91409b89ffda17d6813738195d0ca3f3487c5f0 /src/gtkutil.c
parent560d6f91246ee90ac6e630ae941097a4d4f8f730 (diff)
downloademacs-fe3af8d4f2a4cd67958f76d1b708e8a78e68cd4f.tar.gz
c:/Temp/gtk-window-move/ChangeLog.txt
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c83
1 files changed, 56 insertions, 27 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 3a00e362221..63f01436413 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -783,33 +783,55 @@ xg_set_geometry (struct frame *f)
{
if (f->size_hint_flags & (USPosition | PPosition))
{
- int left = f->left_pos;
- int xneg = f->size_hint_flags & XNegative;
- int top = f->top_pos;
- int yneg = f->size_hint_flags & YNegative;
- char geom_str[sizeof "=x--" + 4 * INT_STRLEN_BOUND (int)];
- guint id;
-
- if (xneg)
- left = -left;
- if (yneg)
- top = -top;
-
- sprintf (geom_str, "=%dx%d%c%d%c%d",
- FRAME_PIXEL_WIDTH (f),
- FRAME_PIXEL_HEIGHT (f),
- (xneg ? '-' : '+'), left,
- (yneg ? '-' : '+'), top);
-
- /* Silence warning about visible children. */
- id = g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
- | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
-
- if (!gtk_window_parse_geometry (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
- geom_str))
- fprintf (stderr, "Failed to parse: '%s'\n", geom_str);
-
- g_log_remove_handler ("Gtk", id);
+ if (x_gtk_use_window_move)
+ {
+ /* Handle negative positions without consulting
+ gtk_window_parse_geometry (Bug#25851). The position will
+ be off by scrollbar width + window manager decorations. */
+ if (f->size_hint_flags & XNegative)
+ f->left_pos = (x_display_pixel_width (FRAME_DISPLAY_INFO (f))
+ - FRAME_PIXEL_WIDTH (f) + f->left_pos);
+
+ if (f->size_hint_flags & YNegative)
+ f->top_pos = (x_display_pixel_height (FRAME_DISPLAY_INFO (f))
+ - FRAME_PIXEL_HEIGHT (f) + f->top_pos);
+
+ gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ f->left_pos, f->top_pos);
+
+ /* Reset size hint flags. */
+ f->size_hint_flags &= ~ (XNegative | YNegative);
+ }
+ else
+ {
+ int left = f->left_pos;
+ int xneg = f->size_hint_flags & XNegative;
+ int top = f->top_pos;
+ int yneg = f->size_hint_flags & YNegative;
+ char geom_str[sizeof "=x--" + 4 * INT_STRLEN_BOUND (int)];
+ guint id;
+
+ if (xneg)
+ left = -left;
+ if (yneg)
+ top = -top;
+
+ sprintf (geom_str, "=%dx%d%c%d%c%d",
+ FRAME_PIXEL_WIDTH (f),
+ FRAME_PIXEL_HEIGHT (f),
+ (xneg ? '-' : '+'), left,
+ (yneg ? '-' : '+'), top);
+
+ /* Silence warning about visible children. */
+ id = g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
+ | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
+
+ if (!gtk_window_parse_geometry (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ geom_str))
+ fprintf (stderr, "Failed to parse: '%s'\n", geom_str);
+
+ g_log_remove_handler ("Gtk", id);
+ }
}
}
@@ -1406,6 +1428,13 @@ x_wm_set_size_hint (struct frame *f, long int flags, bool user_position)
else if (win_gravity == StaticGravity)
size_hints.win_gravity = GDK_GRAVITY_STATIC;
+ if (x_gtk_use_window_move)
+ {
+ if (flags & PPosition) hint_flags |= GDK_HINT_POS;
+ if (flags & USPosition) hint_flags |= GDK_HINT_USER_POS;
+ if (flags & USSize) hint_flags |= GDK_HINT_USER_SIZE;
+ }
+
if (user_position)
{
hint_flags &= ~GDK_HINT_POS;