Commit 5c646d5a authored by Jan Djärv's avatar Jan Djärv

Fix resize due to font change on a maximized/xmonad-controlled frame.

* xterm.h (x_wait_for_event): Declare it.

* xterm.c (pending_event_wait): New variable.
(handle_one_xevent): Set pending_event_wait.eventtype to 0 if we
see pending_event_wait.eventtype.
(handle_one_xevent): Don't change gravity when parent changes.
(x_new_font): Call change_frame_size with new rows/columns before we try
to resize the frame.
(x_wait_for_event): New function.
(x_set_window_size_1): Don't change gravity unless change_gravity is set.
Call XResizeWindow with FRAME_OUTER_WINDOW.  If we are visible,
don't change frame size, instead wait for the ConfigureNotify.
(x_set_window_size): Call x_set_window_size_1 for USE_X_TOOLKIT also.
(x_wm_set_size_hint): Remove ifdefs for USE_X_TOOLKIT.
(x_initialize): Initialize pending_event_wait.

* xmenu.c (set_frame_menubar): Add internal border width to menu bar
size.

* widget.c (EmacsFrameSetValues): Add comment.
(EmacsFrameSetCharSize): Just call x_set_window_size.

* gtkutil.c (xg_frame_set_char_size): Flush events and call
x_wait_for_event.
(flush_and_sync): Removed again.
(xg_get_font_name): Suggest monospace if no previous font is known.
parent 8d106ea0
2009-10-21 Jan Djärv <jan.h.d@swipnet.se>
* xterm.h (x_wait_for_event): Declare it.
* xterm.c (pending_event_wait): New variable.
(handle_one_xevent): Set pending_event_wait.eventtype to 0 if we
see pending_event_wait.eventtype.
(handle_one_xevent): Don't change gravity when parent changes.
(x_new_font): Call change_frame_size with new rows/columns before we try
to resize the frame.
(x_wait_for_event): New function.
(x_set_window_size_1): Don't change gravity unless change_gravity is set.
Call XResizeWindow with FRAME_OUTER_WINDOW. If we are visible,
don't change frame size, instead wait for the ConfigureNotify.
(x_set_window_size): Call x_set_window_size_1 for USE_X_TOOLKIT also.
(x_wm_set_size_hint): Remove ifdefs for USE_X_TOOLKIT.
(x_initialize): Initialize pending_event_wait.
* xmenu.c (set_frame_menubar): Add internal border width to menu bar
size.
* widget.c (EmacsFrameSetValues): Add comment.
(EmacsFrameSetCharSize): Just call x_set_window_size.
* gtkutil.c (xg_frame_set_char_size): Flush events and call
x_wait_for_event.
(flush_and_sync): Removed again.
(xg_get_font_name): Suggest monospace if no previous font is known.
2009-10-20 Stefan Monnier <monnier@iro.umontreal.ca>
* character.c (char_resolve_modifier_mask): Don't resolve meta to the
......
......@@ -665,20 +665,6 @@ xg_frame_resized (f, pixelwidth, pixelheight)
}
}
static void
flush_and_sync (f)
FRAME_PTR f;
{
gdk_window_process_all_updates ();
x_sync (f);
while (gtk_events_pending ())
{
gtk_main_iteration ();
gdk_window_process_all_updates ();
x_sync (f);
}
}
/* Resize the outer window of frame F after chainging the height.
COLUMNS/ROWS is the size the edit area shall have after the resize. */
......@@ -715,6 +701,9 @@ xg_frame_set_char_size (f, cols, rows)
pixelwidth, pixelheight);
x_wm_set_size_hint (f, 0, 0);
SET_FRAME_GARBAGED (f);
cancel_mouse_face (f);
/* 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.
......@@ -723,14 +712,17 @@ xg_frame_set_char_size (f, cols, rows)
For unmapped windows, we can set rows/cols. When
the frame is mapped again we will (hopefully) get the correct size. */
if (f->async_visible)
flush_and_sync (f);
{
/* Must call this to flush out events */
(void)gtk_events_pending ();
gdk_flush ();
x_wait_for_event (f, ConfigureNotify);
}
else
{
change_frame_size (f, rows, cols, 0, 1, 0);
FRAME_PIXEL_WIDTH (f) = pixelwidth;
FRAME_PIXEL_HEIGHT (f) = pixelheight;
change_frame_size (f, rows, cols, 0, 1, 0);
SET_FRAME_GARBAGED (f);
cancel_mouse_face (f);
}
}
......@@ -1640,9 +1632,10 @@ xg_get_font_name (f, default_name)
#endif /* HAVE_GTK_AND_PTHREAD */
w = gtk_font_selection_dialog_new ("Pick a font");
if (default_name)
gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (w),
default_name);
if (!default_name)
default_name = "Monospace 10";
gtk_font_selection_dialog_set_font_name (GTK_FONT_SELECTION_DIALOG (w),
default_name);
xg_set_screen (w, f);
gtk_widget_set_name (w, "emacs-fontdialog");
......
......@@ -775,6 +775,7 @@ EmacsFrameSetValues (cur_widget, req_widget, new_widget, dum1, dum2)
Dimension pixel_width;
Dimension pixel_height;
/* AFAIK, this function is never called. -- Jan D, Oct 2009. */
has_to_recompute_gcs = (cur->emacs_frame.font != new->emacs_frame.font
|| (cur->emacs_frame.foreground_pixel
!= new->emacs_frame.foreground_pixel)
......@@ -872,112 +873,9 @@ EmacsFrameSetCharSize (widget, columns, rows)
int rows;
{
EmacsFrame ew = (EmacsFrame) widget;
Dimension pixel_width, pixel_height;
struct frame *f = ew->emacs_frame.frame;
if (columns < 3) columns = 3; /* no way buddy */
check_frame_size (f, &rows, &columns);
f->scroll_bar_actual_width
= FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f);
compute_fringe_widths (f, 0);
char_to_pixel_size (ew, columns, rows, &pixel_width, &pixel_height);
#if 0 /* This doesn't seem to be right. The frame gets too wide. --gerd. */
/* Something is really strange here wrt to the border width:
Apparently, XtNwidth and XtNheight include the border, so we have
to add it here. But the XtNborderWidth set for the widgets has
no similarity to what f->border_width is set to. */
XtVaGetValues (widget, XtNborderWidth, &border_width, NULL);
pixel_height += 2 * border_width;
pixel_width += 2 * border_width;
#endif
/* Manually change the height and width of all our widgets,
adjusting each widget by the same increments. */
if (ew->core.width != pixel_width
|| ew->core.height != pixel_height)
{
int hdelta = pixel_height - ew->core.height;
int wdelta = pixel_width - ew->core.width;
int column_widget_height = f->output_data.x->column_widget->core.height;
int column_widget_width = f->output_data.x->column_widget->core.width;
int outer_widget_height = f->output_data.x->widget->core.height;
int outer_widget_width = f->output_data.x->widget->core.width;
int old_left = f->output_data.x->widget->core.x;
int old_top = f->output_data.x->widget->core.y;
/* Input is blocked here, and Xt waits for some event to
occur. */
lw_refigure_widget (f->output_data.x->column_widget, False);
update_hints_inhibit = 1;
/* Xt waits for a ConfigureNotify event from the window manager
in EmacsFrameSetCharSize when the shell widget is resized.
For some window managers like fvwm2 2.2.5 and KDE 2.1 this
event doesn't arrive for an unknown reason and Emacs hangs in
Xt when the default font is changed. Tell Xt not to wait,
depending on the value of the frame parameter
`wait-for-wm'. */
x_catch_errors (FRAME_X_DISPLAY (f));
XtVaSetValues (f->output_data.x->widget,
XtNwaitForWm, (XtArgVal) f->output_data.x->wait_for_wm,
NULL);
x_uncatch_errors ();
/* Workaround: When a SIGIO or SIGALRM occurs while Xt is
waiting for a ConfigureNotify event (see above), this leads
to Xt waiting indefinitely instead of using its default
timeout (5 seconds). */
turn_on_atimers (0);
#ifdef SIGIO
sigblock (sigmask (SIGIO));
#endif
/* Do parents first, otherwise LessTif's geometry management
enters an infinite loop (as of 2000-01-15). This is fixed in
later versions of LessTif (as of 2001-03-13); I'll leave it
as is because I think it can't do any harm. */
/* In April 2002, simon.marshall@misys.com reports the problem
seems not to occur any longer. */
x_catch_errors (FRAME_X_DISPLAY (f));
XtVaSetValues (f->output_data.x->widget,
XtNheight, (XtArgVal) (outer_widget_height + hdelta),
XtNwidth, (XtArgVal) (outer_widget_width + wdelta),
NULL);
XtVaSetValues (f->output_data.x->column_widget,
XtNheight, (XtArgVal) (column_widget_height + hdelta),
XtNwidth, (XtArgVal) column_widget_width + wdelta,
NULL);
XtVaSetValues ((Widget) ew,
XtNheight, (XtArgVal) pixel_height,
XtNwidth, (XtArgVal) pixel_width,
NULL);
x_uncatch_errors ();
#ifdef SIGIO
sigunblock (sigmask (SIGIO));
#endif
turn_on_atimers (1);
lw_refigure_widget (f->output_data.x->column_widget, True);
update_hints_inhibit = 0;
update_wm_hints (ew);
/* These seem to get clobbered. I don't know why. - rms. */
f->output_data.x->widget->core.x = old_left;
f->output_data.x->widget->core.y = old_top;
}
/* We've set {FRAME,PIXEL}_{WIDTH,HEIGHT} to the values we hope to
receive in the ConfigureNotify event; if we get what we asked
for, then the event won't cause the screen to become garbaged, so
we have to make sure to do it here. */
SET_FRAME_GARBAGED (f);
x_set_window_size (f, 0, columns, rows);
}
......
......@@ -1555,8 +1555,10 @@ set_frame_menubar (f, first_time, deep_p)
+ f->output_data.x->menubar_widget->core.border_width)
: 0);
#if 0 /* Experimentally, we now get the right results
for -geometry -0-0 without this. 24 Aug 96, rms. */
#if 1 /* Experimentally, we now get the right results
for -geometry -0-0 without this. 24 Aug 96, rms.
Maybe so, but the menu bar size is missing the pixels so the
WM size hints are off by theses pixel. Jan D, oct 2009. */
#ifdef USE_LUCID
if (FRAME_EXTERNAL_MENU_BAR (f))
{
......@@ -1566,7 +1568,7 @@ set_frame_menubar (f, first_time, deep_p)
menubar_size += ibw;
}
#endif /* USE_LUCID */
#endif /* 0 */
#endif /* 1 */
f->output_data.x->menubar_height = menubar_size;
}
......
This diff is collapsed.
......@@ -973,6 +973,7 @@ extern int x_display_pixel_height P_ ((struct x_display_info *));
extern int x_display_pixel_width P_ ((struct x_display_info *));
extern void x_set_sticky P_ ((struct frame *, Lisp_Object, Lisp_Object));
extern void x_wait_for_event P_ ((struct frame *, int));
/* Defined in xselect.c */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment