summaryrefslogtreecommitdiff
path: root/src/xterm.c
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2025-12-22 11:01:53 +0100
committerMartin Rudalics <rudalics@gmx.at>2025-12-22 11:01:53 +0100
commitf3d9371a890699fe4047f693adfcd4d8dbe2fb7d (patch)
treed37fd603addf836483df8ebcf78c53cd0407d991 /src/xterm.c
parent5cf8af22900d359c18a75d9efed44f7c1d8fc06c (diff)
Add functions to set frame size and position in one compound step
* lisp/frame.el (set-frame-size-and-position): New function. * src/frame.c (adjust_frame_size): Handle requests to set size and position. (Fset_frame_size_and_position_pixelwise): New function. * src/gtkutil.c (xg_frame_set_size_and_position): New function. (xg_wm_set_size_hint): Handle any non-NorthWestGravity values for child frames only. Some GTK implementations don't like them. * src/gtkutil.h (xg_frame_set_size_and_position.): Add external declaration. * src/termhooks.h (set_window_size_and_position_hook): New hook. * src/w32term.c (w32_set_window_size_and_position): New function. (w32_create_terminal): Make it the Microsoft Windows API set_window_size_and_position_hook. * src/xterm.c (x_set_window_size_and_position_1) (x_set_window_size_and_position): New functions. (x_create_terminal): Make x_set_window_size_and_position the set_window_size_and_position_hook for the X protocol. * src/xterm.h (x_set_window_size_and_position): Add external declaration. * etc/NEWS: Announce new functions.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/xterm.c b/src/xterm.c
index 9a6131ebb7d..088eaee83c9 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -28563,6 +28563,59 @@ x_set_window_size (struct frame *f, bool change_gravity,
do_pending_window_change (false);
}
+static void
+x_set_window_size_and_position_1 (struct frame *f, int width, int height)
+{
+ int x = f->left_pos;
+ int y = f->top_pos;
+
+ x_wm_set_size_hint (f, 0, false);
+
+ XMoveResizeWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+ x, y, width, height + FRAME_MENUBAR_HEIGHT (f));
+
+ SET_FRAME_GARBAGED (f);
+
+ if (FRAME_VISIBLE_P (f))
+ x_wait_for_event (f, ConfigureNotify);
+ else
+ /* Call adjust_frame_size right away as with GTK. It might be
+ tempting to clear out f->new_width and f->new_height here. */
+ adjust_frame_size (f, FRAME_PIXEL_TO_TEXT_WIDTH (f, width),
+ FRAME_PIXEL_TO_TEXT_HEIGHT (f, height),
+ 5, 0, Qx_set_window_size_1);
+}
+
+void
+x_set_window_size_and_position (struct frame *f, int width, int height)
+{
+ block_input ();
+
+#ifdef USE_GTK
+ if (FRAME_GTK_WIDGET (f))
+ xg_frame_set_size_and_position (f, width, height);
+ else
+ x_set_window_size_and_position_1 (f, width, height);
+#else /* not USE_GTK */
+ x_set_window_size_and_position_1 (f, width, height);
+#endif /* USE_GTK */
+
+ x_clear_under_internal_border (f);
+
+ /* If cursor was outside the new size, mark it as off. */
+ mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f)));
+
+ /* Clear out any recollection of where the mouse highlighting was,
+ since it might be in a place that's outside the new frame size.
+ Actually checking whether it is outside is a pain in the neck,
+ so don't try--just let the highlighting be done afresh with new size. */
+ cancel_mouse_face (f);
+
+ unblock_input ();
+
+ do_pending_window_change (false);
+}
+
/* Move the mouse to position pixel PIX_X, PIX_Y relative to frame F. */
void
@@ -32148,6 +32201,7 @@ x_create_terminal (struct x_display_info *dpyinfo)
terminal->fullscreen_hook = XTfullscreen_hook;
terminal->iconify_frame_hook = x_iconify_frame;
terminal->set_window_size_hook = x_set_window_size;
+ terminal->set_window_size_and_position_hook = x_set_window_size_and_position;
terminal->set_frame_offset_hook = x_set_offset;
terminal->set_frame_alpha_hook = x_set_frame_alpha;
terminal->set_new_font_hook = x_new_font;