all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: "N. Jackson" <nljlistbox2@gmail.com>
Cc: 25851@debbugs.gnu.org
Subject: bug#25851: 25.2; GTK warning when starting Emacs when desktop file has more than one frame
Date: Sun, 30 Apr 2017 10:32:39 +0200	[thread overview]
Message-ID: <5905A127.5010707@gmx.at> (raw)
In-Reply-To: <87pofvdn6h.fsf@moondust.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]

 >> But doesn't your Emacs 25 already contain the patch?
 >
 > No. Not if I understand correctly.
 >
 > _My_ Emacs 25.2.rc2 is modified so that the entire body of
 > xg_set_geometry() is deleted and replaced by a call to
 > gtk_window_move(). This fixes the bug and did not produce any
 > adverse effects in six weeks of use (on my system at least).
 >
 > My Emacs 25.2 is the stock release from the tarball. I don't know
 > if it contains any patch for this bug, but if it does that patch
 > does not appear to work.
 >
 >> The only difference I made lately was to set the default value
 >> of ‘x-gtk-use-window-move’ so all you have to do is to make the
 >> last line of your xterm.c read
 >>
 >> x_gtk_use_window_move = true;
 >
 > The symbol `x_gtk_use_window_move' is not defined in the emacs-25
 > branch, only in master.

Sorry.  I forgot to tell you to apply that change to your Emacs 25 back
then.  Please remove any changes I proposed earlier and try to apply the
attached x_gtk_use_window_move.diff to your Emacs 25.

Thanks, martin

[-- Attachment #2: x_gtk_use_window_move.diff --]
[-- Type: text/plain, Size: 4691 bytes --]

--- 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;
diff --git a/src/xterm.c b/src/xterm.c
index 7856793..4f9eff6 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10056,11 +10056,26 @@ x_set_offset (struct frame *f, register int xoff, register int yoff, int change_
 	f->size_hint_flags |= YNegative;
       f->win_gravity = NorthWestGravity;
     }
+
   x_calc_absolute_position (f);

   block_input ();
   x_wm_set_size_hint (f, 0, false);

+#ifdef USE_GTK
+  if (x_gtk_use_window_move)
+    {
+      /* When a position change was requested and the outer GTK widget
+	 has been realized already, leave it to gtk_window_move to DTRT
+	 and return.  Used for Bug#25851 and Bug#25943.  */
+      if (change_gravity != 0 && FRAME_GTK_OUTER_WIDGET (f))
+	gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+			 f->left_pos, f->top_pos);
+      unblock_input ();
+      return;
+    }
+#endif /* USE_GTK */
+
   modified_left = f->left_pos;
   modified_top = f->top_pos;

@@ -12905,4 +12920,11 @@ state.
 Set this variable only if your window manager cannot handle the
 transition between the various maximization states.  */);
   x_frame_normalize_before_maximize = false;
+
+  DEFVAR_BOOL ("x-gtk-use-window-move", x_gtk_use_window_move,
+    doc: /* Non-nil means rely on gtk_window_move to set frame positions.
+If this variable is t, the GTK build uses the function gtk_window_move
+to set or store frame positions and disables some time consuming frame
+position adjustments.  */);
+  x_gtk_use_window_move = true;
 }

  reply	other threads:[~2017-04-30  8:32 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23 16:08 bug#25851: 25.2; GTK warning when starting Emacs when desktop file has more than one frame N. Jackson
2017-02-23 16:24 ` Eli Zaretskii
2017-02-24  2:33   ` N. Jackson
2017-02-24  8:07     ` Eli Zaretskii
2017-02-24 13:41       ` N. Jackson
2017-02-24 13:53         ` N. Jackson
2017-02-24 14:10         ` Eli Zaretskii
2017-02-24 16:09           ` N. Jackson
2017-02-24 20:28             ` N. Jackson
2017-02-25  8:17               ` Eli Zaretskii
2017-02-26 22:41                 ` N. Jackson
2017-02-27  0:31                   ` N. Jackson
2017-02-27 16:18                     ` Eli Zaretskii
2017-02-27 18:26                       ` N. Jackson
2017-02-27 18:37                         ` Eli Zaretskii
2017-02-28  9:46                         ` martin rudalics
2017-03-01 20:05                           ` N. Jackson
2017-03-23  8:00                             ` martin rudalics
2017-03-23 14:11                               ` N. Jackson
2017-03-24  9:01                                 ` martin rudalics
2017-03-24 20:28                                   ` N. Jackson
2017-03-25  6:26                                     ` Eli Zaretskii
2017-03-28 13:15                                       ` N. Jackson
2017-03-29  7:36                                         ` martin rudalics
2017-03-25  9:25                                     ` martin rudalics
2017-04-27 19:28                                     ` N. Jackson
2017-04-11  6:49                                   ` martin rudalics
2017-04-27 19:55                                     ` N. Jackson
2017-04-29 10:30                                       ` martin rudalics
2017-04-29 19:32                                         ` N. Jackson
2017-04-30  8:32                                           ` martin rudalics [this message]
2017-04-30 16:13                                             ` N. Jackson
2017-04-30 19:36                                               ` martin rudalics
2017-02-28  9:46                       ` martin rudalics
2017-02-28 15:51                         ` Eli Zaretskii
2017-02-28 18:42                           ` martin rudalics
2017-02-28 18:50                             ` Eli Zaretskii
2017-03-01  8:29                               ` martin rudalics
2017-03-01 16:18                                 ` Eli Zaretskii
2017-03-01 19:36                                   ` martin rudalics
2017-03-01 19:47                                     ` Eli Zaretskii
2017-03-01 20:11                                       ` Eli Zaretskii
2017-03-02 11:00                                       ` martin rudalics
2017-03-02 15:09                                         ` Eli Zaretskii
2017-03-02 17:57                                           ` martin rudalics
2017-03-02 20:10                                             ` Eli Zaretskii
2017-03-03  8:13                                               ` martin rudalics
2017-03-03  8:25                                                 ` Eli Zaretskii
2017-03-01 20:16                                     ` N. Jackson
2017-03-03  8:13                                       ` martin rudalics
2017-03-03 13:05                                         ` N. Jackson
2017-03-03 14:24                                           ` martin rudalics
2017-03-06 18:25                                             ` N. Jackson
2017-03-06 18:44                                               ` martin rudalics
2017-02-25  8:21               ` martin rudalics
2017-02-26 22:47                 ` N. Jackson
2017-02-27  2:22                   ` N. Jackson
2017-02-27  8:04                     ` martin rudalics
2017-02-27 17:56                       ` N. Jackson
2017-02-28  9:46                         ` martin rudalics
2017-02-25  7:55             ` Eli Zaretskii
2017-02-26 22:09               ` N. Jackson
2017-03-23  7:59 ` martin rudalics
2017-03-23 13:47   ` Drew Adams
2017-03-23 14:34     ` N. Jackson
2017-03-24  9:01     ` martin rudalics
2017-03-24 20:37       ` N. Jackson
2017-03-25  9:25         ` martin rudalics
2017-03-23 15:24   ` Eli Zaretskii
2017-03-24  9:02     ` martin rudalics
2017-04-27 19:45 ` N. Jackson
2017-04-27 19:52   ` Noam Postavsky
2017-04-28 14:15     ` N. Jackson
2017-04-28 14:25   ` N. Jackson
2017-09-25 16:31 ` N. Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5905A127.5010707@gmx.at \
    --to=rudalics@gmx.at \
    --cc=25851@debbugs.gnu.org \
    --cc=nljlistbox2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.