aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32term.c
diff options
context:
space:
mode:
authorMartin Rudalics2025-12-22 11:01:53 +0100
committerMartin Rudalics2025-12-22 11:01:53 +0100
commitf3d9371a890699fe4047f693adfcd4d8dbe2fb7d (patch)
treed37fd603addf836483df8ebcf78c53cd0407d991 /src/w32term.c
parent5cf8af22900d359c18a75d9efed44f7c1d8fc06c (diff)
downloademacs-f3d9371a890699fe4047f693adfcd4d8dbe2fb7d.tar.gz
emacs-f3d9371a890699fe4047f693adfcd4d8dbe2fb7d.zip
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/w32term.c')
-rw-r--r--src/w32term.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 9387cc3e7b7..80b072d6b5d 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -7237,6 +7237,85 @@ w32_set_window_size (struct frame *f, bool change_gravity,
7237 7237
7238 do_pending_window_change (false); 7238 do_pending_window_change (false);
7239} 7239}
7240
7241/* Change the size of frame F's Windows window to WIDTH and HEIGHT
7242 pixels and its position to those stored in f->left_pos and
7243 f->top_pos. */
7244static void
7245w32_set_window_size_and_position (struct frame *f, int width, int height)
7246{
7247 RECT rect;
7248 MENUBARINFO info;
7249 int menu_bar_height;
7250
7251 block_input ();
7252
7253 /* Get the height of the menu bar here. It's used below to detect
7254 whether the menu bar is wrapped. It's also used to specify the
7255 third argument for AdjustWindowRect. See bug#22105. */
7256 info.cbSize = sizeof (info);
7257 info.rcBar.top = info.rcBar.bottom = 0;
7258 GetMenuBarInfo (FRAME_W32_WINDOW (f), 0xFFFFFFFD, 0, &info);
7259 menu_bar_height = info.rcBar.bottom - info.rcBar.top;
7260
7261 if (w32_add_wrapped_menu_bar_lines)
7262 {
7263 /* When the menu bar wraps sending a SetWindowPos shrinks the
7264 height of the frame then the wrapped menu bar lines are not
7265 accounted for (Bug#15174 and Bug#18720). Here we add these
7266 extra lines to the frame height. */
7267 int default_menu_bar_height;
7268
7269 /* Why is (apparently) SM_CYMENUSIZE needed here instead of
7270 SM_CYMENU ?? */
7271 default_menu_bar_height = GetSystemMetrics (SM_CYMENUSIZE);
7272
7273 if ((default_menu_bar_height > 0)
7274 && (menu_bar_height > default_menu_bar_height)
7275 && ((menu_bar_height % default_menu_bar_height) == 0))
7276 height = height + menu_bar_height - default_menu_bar_height;
7277 }
7278
7279 f->win_gravity = NorthWestGravity;
7280 w32_wm_set_size_hint (f, (long) 0, false);
7281
7282 rect.left = f->left_pos;
7283 rect.top = f->top_pos;
7284 rect.right = rect.left + width;
7285 rect.bottom = rect.top + height;
7286
7287 AdjustWindowRect (&rect, f->output_data.w32->dwStyle, menu_bar_height > 0);
7288
7289 if (!FRAME_PARENT_FRAME (f))
7290 my_set_window_pos (FRAME_W32_WINDOW (f), NULL,
7291 f->left_pos, f->top_pos,
7292 rect.right - rect.left,
7293 rect.bottom - rect.top,
7294 SWP_NOZORDER | SWP_NOACTIVATE);
7295 else
7296 my_set_window_pos (FRAME_W32_WINDOW (f), HWND_TOP,
7297 f->left_pos, f->top_pos,
7298 rect.right - rect.left,
7299 rect.bottom - rect.top,
7300 SWP_NOACTIVATE);
7301
7302 change_frame_size (f, width, height, false, true, false);
7303 SET_FRAME_GARBAGED (f);
7304
7305 /* If cursor was outside the new size, mark it as off. */
7306 mark_window_cursors_off (XWINDOW (f->root_window));
7307
7308 /* Clear out any recollection of where the mouse highlighting was,
7309 since it might be in a place that's outside the new frame size.
7310 Actually checking whether it is outside is a pain in the neck,
7311 so don't try--just let the highlighting be done afresh with new
7312 size. */
7313 cancel_mouse_face (f);
7314
7315 unblock_input ();
7316
7317 do_pending_window_change (false);
7318}
7240 7319
7241/* Mouse warping. */ 7320/* Mouse warping. */
7242 7321
@@ -7891,6 +7970,7 @@ w32_create_terminal (struct w32_display_info *dpyinfo)
7891 terminal->fullscreen_hook = w32fullscreen_hook; 7970 terminal->fullscreen_hook = w32fullscreen_hook;
7892 terminal->iconify_frame_hook = w32_iconify_frame; 7971 terminal->iconify_frame_hook = w32_iconify_frame;
7893 terminal->set_window_size_hook = w32_set_window_size; 7972 terminal->set_window_size_hook = w32_set_window_size;
7973 terminal->set_window_size_and_position_hook = w32_set_window_size_and_position;
7894 terminal->set_frame_offset_hook = w32_set_offset; 7974 terminal->set_frame_offset_hook = w32_set_offset;
7895 terminal->set_frame_alpha_hook = w32_set_frame_alpha; 7975 terminal->set_frame_alpha_hook = w32_set_frame_alpha;
7896 terminal->set_new_font_hook = w32_new_font; 7976 terminal->set_new_font_hook = w32_new_font;