Package: emacs;
To reply to this bug, email your comments to 62135 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
bug-gnu-emacs <at> gnu.org
:bug#62135
; Package emacs
.
(Sun, 12 Mar 2023 01:32:02 GMT) Full text and rfc822 format available.Madhu <enometh <at> meer.net>
:bug-gnu-emacs <at> gnu.org
.
(Sun, 12 Mar 2023 01:32:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Madhu <enometh <at> meer.net> To: bug-gnu-emacs <at> gnu.org Subject: xterm.c: (x_set_offset) Date: Sun, 12 Mar 2023 06:58:43 +0530 (IST)
While investingating some persistent placements at 0x0 by some wm, I was looking at x-set-offset, (which gets called via x_make_frame_visible). In the code below there is a comment that documents the role of the change_gravity argument. When called from x_make_frame_visible the parameter is set to 0, so as not to do anything. However lines 22713-22720 perform an unconditional move window, which happens in this code path even before the XWindow the mapped. 1) Shouldn't these lines be protected by a "if (change_gravity != 0) { ... }" conditional? My surmise is that most wms ignore the call to XMoveWindow because it is unmapped but at least wayfire (on Xwayland) persistently seems to position it at 0, 0 as the code calls it. Also the 0x0 placement only happens on non-gtk builds, because I think there is another bug in lines 22689-22702. x_gtk_use_window_move is always true and gtk builds exit x_set_offset before reaching that line. I hope martin can pick this up from here and take a look? ---Regards, Madhu ``` 22663 /* CHANGE_GRAVITY is 1 when calling from Fset_frame_position, 22664 to really change the position, and 0 when calling from 22665 x_make_frame_visible (in that case, XOFF and YOFF are the current 22666 position values). It is -1 when calling from gui_set_frame_parameters, 22667 which means, do adjust for borders but don't change the gravity. */ 22668 static void 22669 x_set_offset (struct frame *f, int xoff, int yoff, int change_gravity) 22670 { 22671 int modified_top, modified_left; 22672 #ifdef USE_GTK 22673 int scale = xg_get_scale (f); 22674 #endif 22675 if (change_gravity > 0) 22676 { [...] 22689 #ifdef USE_GTK 22690 if (x_gtk_use_window_move) 22691 { 22692 /* When a position change was requested and the outer GTK widget 22693 has been realized already, leave it to gtk_window_move to 22694 DTRT and return. Used for Bug#25851 and Bug#25943. Convert 22695 from X pixels to GTK scaled pixels. */ 22696 if (change_gravity != 0 && FRAME_GTK_OUTER_WIDGET (f)) 22697 gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 22698 f->left_pos / scale, f->top_pos / scale); 22699 unblock_input (); 22700 return; 22701 } 22702 #endif /* USE_GTK */ 22703 modified_left = f->left_pos; 22704 modified_top = f->top_pos; 22705 if (change_gravity != 0 && FRAME_DISPLAY_INFO (f)->wm_type == X_WMTYPE_A) 22706 { 22707 /* Some WMs (twm, wmaker at least) has an offset that is smaller 22708 than the WM decorations. So we use the calculated offset instead 22709 of the WM decoration sizes here (x/y_pixels_outer_diff). */ 22710 modified_left += FRAME_X_OUTPUT (f)->move_offset_left; 22711 modified_top += FRAME_X_OUTPUT (f)->move_offset_top; 22712 } 22713 #ifdef USE_GTK 22714 /* Make sure we adjust for possible scaling. */ 22715 gtk_window_move (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), 22716 modified_left / scale, modified_top / scale); 22717 #else 22718 XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), 22719 modified_left, modified_top); 22720 #endif ``` In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars) of 2023-02-14 Configured using: 'configure --with-x-toolkit=athena --with-native-compilation -C'
bug-gnu-emacs <at> gnu.org
:bug#62135
; Package emacs
.
(Sun, 12 Mar 2023 09:19:02 GMT) Full text and rfc822 format available.Message #8 received at 62135 <at> debbugs.gnu.org (full text, mbox):
From: Po Lu <luangruo <at> yahoo.com> To: Madhu <enometh <at> meer.net> Cc: 62135 <at> debbugs.gnu.org Subject: Re: bug#62135: xterm.c: (x_set_offset) Date: Sun, 12 Mar 2023 17:18:35 +0800
Madhu <enometh <at> meer.net> writes: > While investingating some persistent placements at 0x0 by some wm, I was > looking at x-set-offset, (which gets called via x_make_frame_visible). > > In the code below there is a comment that documents the role of the > change_gravity argument. When called from x_make_frame_visible the > parameter is set to 0, so as not to do anything. However lines > 22713-22720 perform an unconditional move window, which happens in > this code path even before the XWindow the mapped. > > 1) Shouldn't these lines be protected by a "if (change_gravity != 0) { > ... }" conditional? > > My surmise is that most wms ignore the call to XMoveWindow because it is > unmapped but at least wayfire (on Xwayland) persistently seems to > position it at 0, 0 as the code calls it. `change_gravity' means the function should update f->top_pos and f->left_pos, then reset the window gravity, as well as move the window to f->top_pos and f->left_pos. `change_gravity' < 0 means to leave f->top_pos and f->left_pos intact. However, at that point, the window's configuration is not guaranteed to have its origin at f->top_pos and f->left_pos, so the window must still be moved over. Thus, the code is correct. The comment above the function is somewhat misleading but still correct. To test out one theory of mine, please say what this does: diff --git a/src/xterm.c b/src/xterm.c index 70bcb67d80d..de5733c8b7c 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -26956,7 +26956,7 @@ x_set_offset (struct frame *f, int xoff, int yoff, int change_gravity) x_calc_absolute_position (f); block_input (); - x_wm_set_size_hint (f, 0, false); + x_wm_set_size_hint (f, 0, true); #ifdef USE_GTK if (x_gtk_use_window_move) > Also the 0x0 placement only happens on non-gtk builds, because I think > there is another bug in lines 22689-22702. x_gtk_use_window_move is > always true and gtk builds exit x_set_offset before reaching that > line. If that is the case, I think we have a bug in the x_gtk_use_window_move code, and another bug (or at least misbehavior) in Wayfire.
bug-gnu-emacs <at> gnu.org
:bug#62135
; Package emacs
.
(Sat, 25 Mar 2023 14:22:01 GMT) Full text and rfc822 format available.Message #11 received at 62135 <at> debbugs.gnu.org (full text, mbox):
From: Madhu <enometh <at> meer.net> To: luangruo <at> yahoo.com Cc: 62135 <at> debbugs.gnu.org Subject: Re: bug#62135: xterm.c: (x_set_offset) Date: Sat, 25 Mar 2023 19:50:34 +0530 (IST)
* Po Lu <luangruo <at> yahoo.com> <87y1o2ba50.fsf <at> yahoo.com> Wrote on Sun, 12 Mar 2023 17:18:35 +0800 > `change_gravity' means the function should update f->top_pos and > f->left_pos, then reset the window gravity, as well as move the window > to f->top_pos and f->left_pos. > > `change_gravity' < 0 means to leave f->top_pos and f->left_pos intact. > > However, at that point, the window's configuration is not guaranteed to > have its origin at f->top_pos and f->left_pos, so the window must still > be moved over. Thus, the code is correct. The comment above the > function is somewhat misleading but still correct. > > To test out one theory of mine, please say what this does: > - x_wm_set_size_hint (f, 0, false); > + x_wm_set_size_hint (f, 0, true); Thanks for your note (and apologies for the delay). I think all this does is push all windows to +0+0 all the time. > #ifdef USE_GTK > if (x_gtk_use_window_move) > >> Also the 0x0 placement only happens on non-gtk builds, because I think >> there is another bug in lines 22689-22702. x_gtk_use_window_move is >> always true and gtk builds exit x_set_offset before reaching that >> line. > > If that is the case, I think we have a bug in the x_gtk_use_window_move > code, and another bug (or at least misbehavior) in Wayfire. From what I see in wayfire's src/view/xwayland.c: (on_configure.callback) ``` if (!is_mapped()) { /* If the view is not mapped yet, let it be configured as it * wishes. We will position it properly in ::map() */ wlr_xwayland_surface_configure(xw, ev->x, ev->y, ev->width, ev->height); if ((ev->mask & XCB_CONFIG_WINDOW_X) && (ev->mask & XCB_CONFIG_WINDOW_Y)) { ``` During make_frame_visible, This gets ev->x == 0 and ev->y == 0 (presumably from the XMoveWindow in x_set_offset) and always pins the geometry of the view at +0+0 because it has got it from the client. It declines to pass the decision to the placement manager to place the window after the window is mapped, even though no geometry was supplied (say through --geometry 80x25+0+0) The x_gtk_use_window_move codepath actually does not call gtk_window_move (because of the change_gravity conditional I mention above) , and so the configure event does not specify values for x, y. and consequently wayfire does not pin x y. however gtk still maps the window at the correct (presumably based on its wm hints) when gtk_widget_show_all is called in x_make_frame_visible, so fortuitously there isn't a problem with gtk. I cant call foul on what wayfire's is doing. would you think otherwise?
bug-gnu-emacs <at> gnu.org
:bug#62135
; Package emacs
.
(Mon, 01 Apr 2024 12:43:01 GMT) Full text and rfc822 format available.Message #14 received at 62135 <at> debbugs.gnu.org (full text, mbox):
From: Madhu <enometh <at> meer.net> To: luangruo <at> yahoo.com Cc: 62135 <at> debbugs.gnu.org Subject: Re: bug#62135: xterm.c: (x_set_offset) Date: Mon, 01 Apr 2024 18:11:46 +0530 (IST)
[I hope the context is available upthread on the debbugs] I took another look at the problem with wayfire: The call to XMoveWindow in x_set_offset is what's scuttling it. XMoveWindow gets called with 0,0, wayfire thinks the window is self-positioned, and refuses to further touch the co-ordinates. I think that call to XMoveWindow should be protected by a conditional: ``` if (change_gravity != 0) XMoveWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), modified_left, modified_top); ``` so we avoid calling XMoveWindow even before the frame is mapped for the first time. Right?
bug-gnu-emacs <at> gnu.org
:bug#62135
; Package emacs
.
(Tue, 02 Apr 2024 03:40:01 GMT) Full text and rfc822 format available.Message #17 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Madhu <enometh <at> meer.net> To: bug-gnu-emacs <at> gnu.org Subject: Re: bug#62135: xterm.c: (x_set_offset) Date: Tue, 02 Apr 2024 09:08:09 +0530
* Po Lu via <87y1o2ba50.fsf <at> yahoo.com> : Wrote on Sun, 12 Mar 2023 17:18:35 +0800: > Madhu <enometh <at> meer.net> writes: > >> While investingating some persistent placements at 0x0 by some wm, I was >> looking at x-set-offset, (which gets called via x_make_frame_visible). >> >> In the code below there is a comment that documents the role of the >> change_gravity argument. When called from x_make_frame_visible the >> parameter is set to 0, so as not to do anything. However lines >> 22713-22720 perform an unconditional move window, which happens in >> this code path even before the XWindow the mapped. >> >> 1) Shouldn't these lines be protected by a "if (change_gravity != 0) { >> ... }" conditional? >> >> My surmise is that most wms ignore the call to XMoveWindow because it is >> unmapped but at least wayfire (on Xwayland) persistently seems to >> position it at 0, 0 as the code calls it. > > `change_gravity' means the function should update f->top_pos and > f->left_pos, then reset the window gravity, as well as move the window > to f->top_pos and f->left_pos. certainly, when called from set-frame-position. > `change_gravity' < 0 means to leave f->top_pos and f->left_pos intact. > > However, at that point, the window's configuration is not guaranteed to > have its origin at f->top_pos and f->left_pos, so the window must still > be moved over. certainly, when change_gravity < 0. But I don't think this statement is true when mapping an unmapped window when change_gravity == 0. does the code in x_set_offset alter top and left positions if change_gravity == 0? unless the function changes the positions a call to XMoveWindow should not be necessary. if an existing frame has been made invisible, the x and y size hints would have been set along with USPosition and the I presume the wm (minus bugs) would use them if needed when mapping the unmapped window. likewise if a new frame is being mapped with top, left, and user-position set (I haven't double-checked this again) the wm hints would be set, and an explicit move would be unnecessary when mapping the new window. In both these cases change_gravity is set to 0, and there should be no need to move the window at this step. > Thus, the code is correct. The comment above the > function is somewhat misleading but still correct.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.