summaryrefslogtreecommitdiff
path: root/src/gtkutil.c
diff options
context:
space:
mode:
authorMartin Rudalics <rudalics@gmx.at>2015-02-07 11:51:03 +0100
committerMartin Rudalics <rudalics@gmx.at>2015-02-07 11:51:03 +0100
commitd1655783194f7b84ccac7114a2c341f10bc438b0 (patch)
tree1ee78b1870dfbe7baa45d8e0c4cebae582e13423 /src/gtkutil.c
parentcf498e5b9a73329edea0bdbf1bd8dfe06fdd75e2 (diff)
downloademacs-d1655783194f7b84ccac7114a2c341f10bc438b0.tar.gz
Try to improve handling of fullwidth/-height frames.
* frame.el (frame-notice-user-settings): Update `frame-size-history'. (make-frame): Update `frame-size-history'. Call `frame-after-make-frame'. * faces.el (face-set-after-frame-default): Remove call to frame-can-run-window-configuration-change-hook. * frame.c (frame_size_history_add): New function. (frame_inhibit_resize): Consider frame_inhibit_implied_resize only after frame's after_make_frame slot is true. Inhibit resizing fullwidth-/height frames in one direction only. Update frame_size_history. (adjust_frame_size): Call frame_size_history_add. (make_frame): Initalize after_make_frame slot. (Fmake_terminal_frame): Adjust adjust_frame_size call. (Fcan_run_window_configuration_change_hook): Rename to Fframe_after_make_frame. Set after_make_frame slot. Return second argument. (x_set_frame_parameters): Postpone handling fullscreen parameter until after width and height parameters have been set. Apply width and height changes only if can_x_set_window_size is true. Update frame_size_history. (Qadjust_frame_size_1, Qadjust_frame_size_2) (Qadjust_frame_size_3, QEmacsFrameResize, Qframe_inhibit_resize) (Qx_set_fullscreen, Qx_check_fullscreen, Qx_set_window_size_1) (Qxg_frame_resized, Qxg_frame_set_char_size_1) (Qxg_frame_set_char_size_2, Qxg_frame_set_char_size_3) (Qxg_change_toolbar_position, Qx_net_wm_state) (Qx_handle_net_wm_state, Qtb_size_cb, Qupdate_frame_tool_bar) (Qfree_frame_tool_bar): New symbol for updating frame_size_history. (Qtip_frame, Qterminal_frame): New symbols. (Vframe_adjust_size_history): Rename to frame_size_history. * frame.h (struct frame): Rename can_run_window_configuration_change_hook slot to after_make_frame. (frame_size_history_add): Extern. * gtkutil.c (xg_frame_resized): Call frame_size_history_add. Don't set FRAME_PIXEL_WIDTH and FRAME_PIXEL_HEIGHT here. (xg_frame_set_char_size): Try to preserve the status of fullwidth/-height frames. Call frame_size_history_add. (tb_size_cb, update_frame_tool_bar, free_frame_tool_bar) (xg_change_toolbar_position): Call frame_size_history_add. * w32fns.c (x_change_tool_bar_height): Handle frame's fullscreen status. (Fx_create_frame): Process fullscreen parameter after frame has been resized. (x_create_tip_frame): Pass Qtip_frame to adjust_frame_size. (Fx_frame_geometry): Don't pollute pure storage. * w32term.c (w32_read_socket): For WM_WINDOWPOSCHANGED, WM_ACTIVATE and WM_ACTIVATEAPP set frame's visibility before calling w32fullscreen_hook. For WM_DISPLAYCHANGE call w32fullscreen_hook immediately. (x_fullscreen_adjust, x_check_fullscreen): Remove. (w32fullscreen_hook): Call change_frame_size just as with a "normal" frame resize operation. Call do_pending_window_change. (x_set_window_size): Try to handle fullwidth and fullheight more accurately. Don't rely on w32_enable_frame_resize_hack. (w32_enable_frame_resize_hack): Remove variable. * widget.c (EmacsFrameResize): Remove dead code. Call frame_size_history_add * window.c (run_window_configuration_change_hook): Check f->after_make_frame instead of f->can_run_window_configuration_change_hook. * xfns.c (x_change_tool_bar_height): Handle frame's fullscreen status. (Fx_create_frame): Process fullscreen parameter after frame has been resized. (Fx_frame_geometry): Don't pollute pure storage. * xterm.c (x_net_wm_state, x_handle_net_wm_state): Call frame_size_history_add. (do_ewmh_fullscreen): Handle x_frame_normalize_before_maximize. (x_check_fullscreen): Count in menubar when calling XResizeWindow. Wait for ConfigureNotify event. Call frame_size_history_add. (x_set_window_size_1): Remove PIXELWISE argument. Try to handle changing a fullheight frame's width or a fullwidth frame's height. Call frame_size_history_add. (x_set_window_size): Simplify xg_frame_set_char_size and x_set_window_size_1 calls. (x_frame_normalize_before_maximize): New variable.
Diffstat (limited to 'src/gtkutil.c')
-rw-r--r--src/gtkutil.c113
1 files changed, 92 insertions, 21 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 21f3cb15e66..063e88262d9 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -886,23 +886,25 @@ xg_frame_resized (struct frame *f, int pixelwidth, int pixelheight)
if (pixelwidth == -1 && pixelheight == -1)
{
if (FRAME_GTK_WIDGET (f) && gtk_widget_get_mapped (FRAME_GTK_WIDGET (f)))
- gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)),
- 0, 0,
- &pixelwidth, &pixelheight);
- else return;
+ gdk_window_get_geometry (gtk_widget_get_window (FRAME_GTK_WIDGET (f)),
+ 0, 0, &pixelwidth, &pixelheight);
+ else
+ return;
}
-
width = FRAME_PIXEL_TO_TEXT_WIDTH (f, pixelwidth);
height = FRAME_PIXEL_TO_TEXT_HEIGHT (f, pixelheight);
+ frame_size_history_add
+ (f, Qxg_frame_resized, width, height, Qnil);
+
if (width != FRAME_TEXT_WIDTH (f)
|| height != FRAME_TEXT_HEIGHT (f)
|| pixelwidth != FRAME_PIXEL_WIDTH (f)
|| pixelheight != FRAME_PIXEL_HEIGHT (f))
{
- FRAME_PIXEL_WIDTH (f) = pixelwidth;
- FRAME_PIXEL_HEIGHT (f) = pixelheight;
+/** FRAME_PIXEL_WIDTH (f) = pixelwidth; **/
+/** FRAME_PIXEL_HEIGHT (f) = pixelheight; **/
xg_clear_under_internal_border (f);
change_frame_size (f, width, height, 0, 1, 0, 1);
@@ -921,24 +923,71 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
{
int pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
int pixelheight = FRAME_TEXT_TO_PIXEL_HEIGHT (f, height);
+ Lisp_Object fullscreen = get_frame_param (f, Qfullscreen);
+ gint gwidth, gheight;
if (FRAME_PIXEL_HEIGHT (f) == 0)
return;
+ gtk_window_get_size (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ &gwidth, &gheight);
+
/* Do this before resize, as we don't know yet if we will be resized. */
xg_clear_under_internal_border (f);
- /* Must resize our top level widget. Font size may have changed,
- but not rows/cols. */
- gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
- pixelwidth + FRAME_TOOLBAR_WIDTH (f),
- pixelheight + FRAME_TOOLBAR_HEIGHT (f)
- + FRAME_MENUBAR_HEIGHT (f));
- x_wm_set_size_hint (f, 0, 0);
+ /* Resize the top level widget so rows and columns remain constant.
+
+ When the frame is fullheight and we only want to change the width
+ or it is fullwidth and we only want to change the height we should
+ be able to preserve the fullscreen property. However, due to the
+ fact that we have to send a resize request anyway, the window
+ manager will abolish it. At least the respective size should
+ remain unchanged but giving the frame back its normal size will
+ be broken ... */
+ if (EQ (fullscreen, Qfullwidth) && width == FRAME_TEXT_WIDTH (f))
+ {
+ frame_size_history_add
+ (f, Qxg_frame_set_char_size_1, width, height,
+ list2 (make_number (gheight),
+ make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ + FRAME_MENUBAR_HEIGHT (f))));
+
+ gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ gwidth,
+ pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ + FRAME_MENUBAR_HEIGHT (f));
+ }
+ else if (EQ (fullscreen, Qfullheight) && height == FRAME_TEXT_HEIGHT (f))
+ {
+ frame_size_history_add
+ (f, Qxg_frame_set_char_size_2, width, height,
+ list2 (make_number (gwidth),
+ make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f))));
+
+ gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ pixelwidth + FRAME_TOOLBAR_WIDTH (f),
+ gheight);
+ }
+
+ else
+ {
+ frame_size_history_add
+ (f, Qxg_frame_set_char_size_3, width, height,
+ list2 (make_number (pixelwidth + FRAME_TOOLBAR_WIDTH (f)),
+ make_number (pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ + FRAME_MENUBAR_HEIGHT (f))));
+
+ gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)),
+ pixelwidth + FRAME_TOOLBAR_WIDTH (f),
+ pixelheight + FRAME_TOOLBAR_HEIGHT (f)
+ + FRAME_MENUBAR_HEIGHT (f));
+ fullscreen = Qnil;
+ }
SET_FRAME_GARBAGED (f);
cancel_mouse_face (f);
+ x_wm_set_size_hint (f, 0, 0);
/* We can not call change_frame_size for a mapped frame,
we can not set pixel width/height either. The window manager may
override our resize request, XMonad does this all the time.
@@ -952,9 +1001,17 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
(void)gtk_events_pending ();
gdk_flush ();
x_wait_for_event (f, ConfigureNotify);
+
+ if (!NILP (fullscreen))
+ /* Try to restore fullscreen state. */
+ {
+ store_frame_param (f, Qfullscreen, fullscreen);
+ x_set_fullscreen (f, fullscreen, fullscreen);
+ }
}
else
- adjust_frame_size (f, -1, -1, 5, 0, Qxg_frame_set_char_size);
+ adjust_frame_size (f, width, height, 5, 0, Qxg_frame_set_char_size);
+
}
/* Handle height/width changes (i.e. add/remove/move menu/toolbar).
@@ -4214,8 +4271,12 @@ tb_size_cb (GtkWidget *widget,
allocated between widgets, it may get another. So we must update
size hints if tool bar size changes. Seen on Fedora 18 at least. */
struct frame *f = user_data;
+
if (xg_update_tool_bar_sizes (f))
- adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+ {
+ frame_size_history_add (f, Qtb_size_cb, 0, 0, Qnil);
+ adjust_frame_size (f, -1, -1, 5, 0, Qtool_bar_lines);
+ }
}
/* Create a tool bar for frame F. */
@@ -4489,10 +4550,11 @@ xg_update_tool_bar_sizes (struct frame *f)
FRAME_TOOLBAR_RIGHT_WIDTH (f) = nr;
FRAME_TOOLBAR_TOP_HEIGHT (f) = nt;
FRAME_TOOLBAR_BOTTOM_HEIGHT (f) = nb;
- return 1;
- }
- return 0;
+ return true;
+ }
+ else
+ return false;
}
static char *
@@ -4815,7 +4877,10 @@ update_frame_tool_bar (struct frame *f)
xg_pack_tool_bar (f, FRAME_TOOL_BAR_POSITION (f));
gtk_widget_show_all (x->toolbar_widget);
if (xg_update_tool_bar_sizes (f))
- adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+ {
+ frame_size_history_add (f, Qupdate_frame_tool_bar, 0, 0, Qnil);
+ adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+ }
}
unblock_input ();
@@ -4863,6 +4928,7 @@ free_frame_tool_bar (struct frame *f)
NULL);
}
+ frame_size_history_add (f, Qfree_frame_tool_bar, 0, 0, Qnil);
adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
unblock_input ();
@@ -4892,8 +4958,13 @@ xg_change_toolbar_position (struct frame *f, Lisp_Object pos)
xg_pack_tool_bar (f, pos);
g_object_unref (top_widget);
+
if (xg_update_tool_bar_sizes (f))
- adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+ {
+ frame_size_history_add (f, Qxg_change_toolbar_position, 0, 0, Qnil);
+ adjust_frame_size (f, -1, -1, 2, 0, Qtool_bar_lines);
+ }
+
unblock_input ();
}