From: martin rudalics via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Reuben Thomas <rrt@sc3d.org>
Cc: luangruo@yahoo.com, Eli Zaretskii <eliz@gnu.org>, 72986@debbugs.gnu.org
Subject: bug#72986: Disabling menu-bar-mode changes size of new frames
Date: Sat, 30 Nov 2024 20:00:55 +0100 [thread overview]
Message-ID: <923e3659-a284-43f7-be38-8b5821ac9f8e@gmx.at> (raw)
In-Reply-To: <CAOnWdojRWemYpRDQoWbzo-x6YbULc-oHjJx2AGR8_t4JHaaLnw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 877 bytes --]
> Assuming that this problem affects all or most users of recent GNOME, it
> would be fantastic to have this patch installed. It's a very unsatisfactory
> fix (because we don't understand what the problem really is, or even where,
> I think?), but the current situation is quite annoying (every time I open a
> new Emacs frame, I first have to resize it before I can use it).
> Thanks again to Martin; having myself had to do quite a lot of proxy
> debugging of weird effects on systems I don't use, I appreciate the
> patience and hard thought that goes into trying to diagnose and fix this
> sort of bug.
I now added a variable called 'x-gtk-insist-on-requested-size'. If
non-nil, it should do what its doc-string says. The rest of the
attached patch is mostly what was in a diff I earlier posted as
gtkutil-reject-2024-10-02.diff. Please try it.
Thanks, martin
[-- Attachment #2: gtkutil-reject-11.diff --]
[-- Type: text/x-patch, Size: 4301 bytes --]
diff --git a/src/gtkutil.c b/src/gtkutil.c
index d57627f152f..1496b761550 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -1129,11 +1129,59 @@ xg_set_geometry (struct frame *f)
}
}
+#ifndef HAVE_PGTK
+static struct frame *last_resize_frame = NULL;
+static int last_resize_height = -1;
+static int last_resize_width = -1;
+static bool last_resize_insist = false;
+#endif
+
/** Function to handle resize of native frame F to WIDTH and HEIGHT
pixels after we got a ConfigureNotify event. */
void
xg_frame_resized (struct frame *f, int width, int height)
{
+#ifndef HAVE_PGTK
+ bool reject = false;
+
+ if (last_resize_insist && f == last_resize_frame)
+ {
+ int expected_width = ((last_resize_width * xg_get_scale (f))
+ - FRAME_TOOLBAR_WIDTH (f));
+ int expected_height = ((last_resize_height * xg_get_scale (f))
+ - FRAME_MENUBAR_HEIGHT (f)
+ - FRAME_TOOLBAR_HEIGHT (f));
+
+ /* Fuzzyness: Reject the new size if the deviation is more than
+ two pixels in either direction. */
+ if (width > expected_width + 2
+ || width < expected_width - 2
+ || height > expected_height + 2
+ || height < expected_height - 2)
+ /* We did not get what we wanted, retry. */
+ {
+ if (CONSP (frame_size_history))
+ frame_size_history_extra
+ (f, build_string ("xg_frame_resized, rejected"),
+ FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f), width, height,
+ last_resize_width, last_resize_height);
+
+ /* Resend the previous request. */
+ gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ last_resize_width, last_resize_height);
+ reject = true;
+ }
+
+ /* Reset the insistence values. */
+ last_resize_frame = NULL;
+ last_resize_height = -1;
+ last_resize_width = -1;
+ last_resize_insist = false;
+
+ if (reject)
+ return;
+ }
+#endif
/* Ignore case where size of native rectangle didn't change. */
if (width != FRAME_PIXEL_WIDTH (f)
|| height != FRAME_PIXEL_HEIGHT (f)
@@ -1297,19 +1345,23 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
else
{
#ifndef HAVE_PGTK
+ if (x_gtk_insist_on_requested_size)
+ {
+ last_resize_frame = f;
+ last_resize_width = outer_width;
+ last_resize_height = outer_height;
+ last_resize_insist = true;
+ }
+
gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
outer_width, outer_height);
#else
if (FRAME_GTK_OUTER_WIDGET (f))
- {
- gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
- outer_width, outer_height);
- }
+ gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ outer_width, outer_height);
else
- {
- gtk_widget_set_size_request (FRAME_GTK_WIDGET (f),
- outer_width, outer_height);
- }
+ gtk_widget_set_size_request (FRAME_GTK_WIDGET (f),
+ outer_width, outer_height);
#endif
fullscreen = Qnil;
}
diff --git a/src/xterm.c b/src/xterm.c
index 0c20d38b0f7..00dc976e2ff 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -32762,6 +32762,23 @@ syms_of_xterm (void)
always uses gtk_window_move and ignores the value of this variable. */);
x_gtk_use_window_move = true;
+#if defined USE_GTK && !defined HAVE_PGTK
+ DEFVAR_BOOL ("x-gtk-insist-on-requested-size", x_gtk_insist_on_requested_size,
+ doc: /* Non-nil means try harder to obtain requested size for new frames.
+If this variable is non-nil, a GTK build on X will reject once a frame
+size it is offered that does not match the one previously requested by
+Emacs. Rather, Emacs will reissue the previous request to size the
+frame. If this variable is nil, Emacs will accept any frame size it is
+offered.
+
+Setting this to a non-nil value can be necessary when running on a GNOME
+desktop with the mutter window manager under GTK3. These may offer
+Emacs a much smaller frame size for the initial as well as for any
+additional frames. For the initial frame it will be necessary to set
+this in the `early-init.el' file. */);
+ x_gtk_insist_on_requested_size = false;
+#endif
+
DEFVAR_LISP ("x-scroll-event-delta-factor", Vx_scroll_event_delta_factor,
doc: /* A scale to apply to pixel deltas reported in scroll events.
This option is only effective when Emacs is built with XInput 2
next prev parent reply other threads:[~2024-11-30 19:00 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-02 18:48 bug#72986: Disabling menu-bar-mode changes size of new frames Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-03 12:07 ` Eli Zaretskii
2024-09-03 12:09 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-03 15:52 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-03 15:59 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-03 17:03 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-03 17:29 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-03 17:42 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-04 8:01 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-04 11:23 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-04 12:12 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-04 13:05 ` Robert Pluim
2024-09-04 17:11 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-04 22:45 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-05 7:49 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-05 19:31 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 7:54 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 8:11 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 9:50 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 12:20 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 14:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 15:14 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-07 8:37 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-07 12:07 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 8:42 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 11:38 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 14:21 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 15:20 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 16:54 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-08 17:32 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-09 8:58 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-09 9:49 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-09 12:33 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-09 13:59 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-09 16:52 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-09 17:52 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-10 9:31 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-10 17:00 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-10 17:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-12 16:24 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-14 14:43 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-15 12:40 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-16 8:46 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-25 19:12 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-01 8:55 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-01 18:11 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-02 8:53 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-02 12:06 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-03 13:54 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-03 19:43 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-04 15:01 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-04 15:23 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-04 17:21 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-05 20:02 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-06 15:01 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-26 12:39 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-26 17:40 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-31 11:09 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-31 14:14 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-05 23:06 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-06 8:48 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-06 22:03 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-07 9:49 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-07 10:36 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-14 23:25 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 17:20 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 20:06 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 8:59 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 14:45 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 16:40 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-17 13:09 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-17 16:37 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-17 17:01 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 9:59 ` Eli Zaretskii
2024-11-30 10:16 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 11:50 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-30 19:00 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-30 12:32 ` Eli Zaretskii
2024-09-03 17:44 ` Eli Zaretskii
2024-09-03 18:34 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-04 8:05 ` martin rudalics via Bug reports for GNU Emacs, the Swiss army knife of text editors
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=923e3659-a284-43f7-be38-8b5821ac9f8e@gmx.at \
--to=bug-gnu-emacs@gnu.org \
--cc=72986@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=luangruo@yahoo.com \
--cc=rrt@sc3d.org \
--cc=rudalics@gmx.at \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).