Mercurial > emacs
changeset 106720:3db7e57ee4e9
Handle change of internal-border width when maximized.
* xterm.c (x_new_font): Move code for setting rows/cols before
resizing ...
(x_set_window_size): ... to here. bug #2568.
* gtkutil.c (xg_clear_under_internal_border): New function.
(xg_frame_resized, xg_frame_set_char_size): Call
xg_clear_under_internal_border.
(xg_update_scrollbar_pos): Clear under old scroll bar position.
author | Jan D. <jan.h.d@swipnet.se> |
---|---|
date | Tue, 05 Jan 2010 15:16:30 +0100 |
parents | b7f28f66e31e |
children | 9dcca543c2aa |
files | src/ChangeLog src/gtkutil.c src/xterm.c |
diffstat | 3 files changed, 111 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Sat Jan 02 23:33:36 2010 +0200 +++ b/src/ChangeLog Tue Jan 05 15:16:30 2010 +0100 @@ -1,3 +1,14 @@ +2010-01-05 Jan Djärv <jan.h.d@swipnet.se> + + * xterm.c (x_new_font): Move code for setting rows/cols before + resizing ... + (x_set_window_size): ... to here. bug #2568. + + * gtkutil.c (xg_clear_under_internal_border): New function. + (xg_frame_resized, xg_frame_set_char_size): Call + xg_clear_under_internal_border. + (xg_update_scrollbar_pos): Clear under old scroll bar position. + 2010-01-01 Chong Yidong <cyd@stupidchicken.com> * nsterm.m (ns_get_color): Fix buffer overflow (Bug#4763).
--- a/src/gtkutil.c Sat Jan 02 23:33:36 2010 +0200 +++ b/src/gtkutil.c Tue Jan 05 15:16:30 2010 +0100 @@ -568,6 +568,42 @@ f->left_pos, f->top_pos); } +/* Clear under internal border if any. As we use a mix of Gtk+ and X calls + and use a GtkFixed widget, this doesn't happen automatically. */ + +static void +xg_clear_under_internal_border (f) + FRAME_PTR f; +{ + if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0) + { + GtkWidget *wfixed = f->output_data.x->edit_widget; + gtk_widget_queue_draw (wfixed); + gdk_window_process_all_updates (); + x_clear_area (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + 0, 0, + FRAME_PIXEL_WIDTH (f), + FRAME_INTERNAL_BORDER_WIDTH (f), 0); + x_clear_area (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + 0, 0, + FRAME_INTERNAL_BORDER_WIDTH (f), + FRAME_PIXEL_HEIGHT (f), 0); + x_clear_area (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + 0, FRAME_PIXEL_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f), + FRAME_PIXEL_WIDTH (f), + FRAME_INTERNAL_BORDER_WIDTH (f), 0); + x_clear_area (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f), + 0, + FRAME_INTERNAL_BORDER_WIDTH (f), + FRAME_PIXEL_HEIGHT (f), 0); + } +} + /* Function to handle resize of our frame. As we have a Gtk+ tool bar and a Gtk+ menu bar, we get resize events for the edit part of the frame only. We let Gtk+ deal with the Gtk+ parts. @@ -584,8 +620,8 @@ if (pixelwidth == -1 && pixelheight == -1) { if (FRAME_GTK_WIDGET (f) && GTK_WIDGET_MAPPED (FRAME_GTK_WIDGET (f))) - gdk_window_get_geometry(FRAME_GTK_WIDGET (f)->window, 0, 0, - &pixelwidth, &pixelheight, 0); + gdk_window_get_geometry (FRAME_GTK_WIDGET (f)->window, 0, 0, + &pixelwidth, &pixelheight, 0); else return; } @@ -601,6 +637,7 @@ FRAME_PIXEL_WIDTH (f) = pixelwidth; FRAME_PIXEL_HEIGHT (f) = pixelheight; + xg_clear_under_internal_border (f); change_frame_size (f, rows, columns, 0, 1, 0); SET_FRAME_GARBAGED (f); cancel_mouse_face (f); @@ -637,6 +674,10 @@ after calculating that value. */ pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); + + /* 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)), @@ -3201,15 +3242,43 @@ { GtkWidget *wfixed = f->output_data.x->edit_widget; GtkWidget *wparent = gtk_widget_get_parent (wscroll); + GtkFixed *wf = GTK_FIXED (wfixed); + + /* Clear out old position. */ + GList *iter; + int oldx = -1, oldy = -1, oldw, oldh; + for (iter = wf->children; iter; iter = iter->next) + if (((GtkFixedChild *)iter->data)->widget == wparent) + { + GtkFixedChild *ch = (GtkFixedChild *)iter->data; + if (ch->x != left || ch->y != top) + { + oldx = ch->x; + oldy = ch->y; + gtk_widget_get_size_request (wscroll, &oldw, &oldh); + } + break; + } /* Move and resize to new values. */ gtk_fixed_move (GTK_FIXED (wfixed), wparent, left, top); gtk_widget_set_size_request (wscroll, width, height); - gtk_widget_queue_draw (wparent); + gtk_widget_queue_draw (wfixed); gdk_window_process_all_updates (); + if (oldx != -1) + { + /* Clear under old scroll bar position. This must be done after + the gtk_widget_queue_draw and gdk_window_process_all_updates + above. */ + x_clear_area (FRAME_X_DISPLAY (f), + FRAME_X_WINDOW (f), + oldx, oldy, oldw, oldh, 0); + } + /* GTK does not redraw until the main loop is entered again, but if there are no X events pending we will not enter it. So we sync here to get some events. */ + x_sync (f); SET_FRAME_GARBAGED (f); cancel_mouse_face (f);
--- a/src/xterm.c Sat Jan 02 23:33:36 2010 +0200 +++ b/src/xterm.c Tue Jan 05 15:16:30 2010 +0100 @@ -8064,32 +8064,7 @@ doing it because it's done in Fx_show_tip, and it leads to problems because the tip frame has no widget. */ if (NILP (tip_frame) || XFRAME (tip_frame) != f) - { - int rows, cols; - - /* When the frame is maximized/fullscreen or running under for - example Xmonad, x_set_window_size will be a no-op. - In that case, the right thing to do is extend rows/cols to - the current frame size. We do that first if x_set_window_size - turns out to not be a no-op (there is no way to know). - The size will be adjusted again if the frame gets a - ConfigureNotify event as a result of x_set_window_size. */ - int pixelh = FRAME_PIXEL_HEIGHT (f); -#ifdef USE_X_TOOLKIT - /* The menu bar is not part of text lines. The tool bar - is however. */ - pixelh -= FRAME_MENUBAR_HEIGHT (f); -#endif - rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelh); - /* Update f->scroll_bar_actual_width because it is used in - FRAME_PIXEL_WIDTH_TO_TEXT_COLS. */ - f->scroll_bar_actual_width - = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f); - cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, FRAME_PIXEL_WIDTH (f)); - - change_frame_size (f, rows, cols, 0, 1, 0); - x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); - } + x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); } #ifdef HAVE_X_I18N @@ -8977,6 +8952,33 @@ { BLOCK_INPUT; + if (NILP (tip_frame) || XFRAME (tip_frame) != f) + { + int r, c; + + /* When the frame is maximized/fullscreen or running under for + example Xmonad, x_set_window_size_1 will be a no-op. + In that case, the right thing to do is extend rows/cols to + the current frame size. We do that first if x_set_window_size_1 + turns out to not be a no-op (there is no way to know). + The size will be adjusted again if the frame gets a + ConfigureNotify event as a result of x_set_window_size. */ + int pixelh = FRAME_PIXEL_HEIGHT (f); +#ifdef USE_X_TOOLKIT + /* The menu bar is not part of text lines. The tool bar + is however. */ + pixelh -= FRAME_MENUBAR_HEIGHT (f); +#endif + r = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelh); + /* Update f->scroll_bar_actual_width because it is used in + FRAME_PIXEL_WIDTH_TO_TEXT_COLS. */ + f->scroll_bar_actual_width + = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f); + c = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, FRAME_PIXEL_WIDTH (f)); + fprintf (stderr, "1: old %d/%d, new %d/%d\n", rows, cols, r, c); + change_frame_size (f, r, c, 0, 1, 0); + } + #ifdef USE_GTK if (FRAME_GTK_WIDGET (f)) xg_frame_set_char_size (f, cols, rows);