diff options
| author | Jan Djärv | 2010-01-05 15:16:30 +0100 |
|---|---|---|
| committer | Jan Djärv | 2010-01-05 15:16:30 +0100 |
| commit | 7c583cd8559846fc9537778e9c141cd85358302f (patch) | |
| tree | 593af9f94fd171fbe48d61d8da39933fb7bfbef4 | |
| parent | 798c9eb5600072c2558de7620ad69b06aee46de7 (diff) | |
| download | emacs-7c583cd8559846fc9537778e9c141cd85358302f.tar.gz emacs-7c583cd8559846fc9537778e9c141cd85358302f.zip | |
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.
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/gtkutil.c | 75 | ||||
| -rw-r--r-- | src/xterm.c | 54 |
3 files changed, 111 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index d6e7f2c9791..d355e79163e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2010-01-05 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xterm.c (x_new_font): Move code for setting rows/cols before | ||
| 4 | resizing ... | ||
| 5 | (x_set_window_size): ... to here. bug #2568. | ||
| 6 | |||
| 7 | * gtkutil.c (xg_clear_under_internal_border): New function. | ||
| 8 | (xg_frame_resized, xg_frame_set_char_size): Call | ||
| 9 | xg_clear_under_internal_border. | ||
| 10 | (xg_update_scrollbar_pos): Clear under old scroll bar position. | ||
| 11 | |||
| 1 | 2010-01-01 Chong Yidong <cyd@stupidchicken.com> | 12 | 2010-01-01 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 13 | ||
| 3 | * nsterm.m (ns_get_color): Fix buffer overflow (Bug#4763). | 14 | * nsterm.m (ns_get_color): Fix buffer overflow (Bug#4763). |
diff --git a/src/gtkutil.c b/src/gtkutil.c index cd9c930c7c2..1dab467a0ac 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -568,6 +568,42 @@ xg_set_geometry (f) | |||
| 568 | f->left_pos, f->top_pos); | 568 | f->left_pos, f->top_pos); |
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | /* Clear under internal border if any. As we use a mix of Gtk+ and X calls | ||
| 572 | and use a GtkFixed widget, this doesn't happen automatically. */ | ||
| 573 | |||
| 574 | static void | ||
| 575 | xg_clear_under_internal_border (f) | ||
| 576 | FRAME_PTR f; | ||
| 577 | { | ||
| 578 | if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0) | ||
| 579 | { | ||
| 580 | GtkWidget *wfixed = f->output_data.x->edit_widget; | ||
| 581 | gtk_widget_queue_draw (wfixed); | ||
| 582 | gdk_window_process_all_updates (); | ||
| 583 | x_clear_area (FRAME_X_DISPLAY (f), | ||
| 584 | FRAME_X_WINDOW (f), | ||
| 585 | 0, 0, | ||
| 586 | FRAME_PIXEL_WIDTH (f), | ||
| 587 | FRAME_INTERNAL_BORDER_WIDTH (f), 0); | ||
| 588 | x_clear_area (FRAME_X_DISPLAY (f), | ||
| 589 | FRAME_X_WINDOW (f), | ||
| 590 | 0, 0, | ||
| 591 | FRAME_INTERNAL_BORDER_WIDTH (f), | ||
| 592 | FRAME_PIXEL_HEIGHT (f), 0); | ||
| 593 | x_clear_area (FRAME_X_DISPLAY (f), | ||
| 594 | FRAME_X_WINDOW (f), | ||
| 595 | 0, FRAME_PIXEL_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f), | ||
| 596 | FRAME_PIXEL_WIDTH (f), | ||
| 597 | FRAME_INTERNAL_BORDER_WIDTH (f), 0); | ||
| 598 | x_clear_area (FRAME_X_DISPLAY (f), | ||
| 599 | FRAME_X_WINDOW (f), | ||
| 600 | FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f), | ||
| 601 | 0, | ||
| 602 | FRAME_INTERNAL_BORDER_WIDTH (f), | ||
| 603 | FRAME_PIXEL_HEIGHT (f), 0); | ||
| 604 | } | ||
| 605 | } | ||
| 606 | |||
| 571 | /* Function to handle resize of our frame. As we have a Gtk+ tool bar | 607 | /* Function to handle resize of our frame. As we have a Gtk+ tool bar |
| 572 | and a Gtk+ menu bar, we get resize events for the edit part of the | 608 | and a Gtk+ menu bar, we get resize events for the edit part of the |
| 573 | frame only. We let Gtk+ deal with the Gtk+ parts. | 609 | frame only. We let Gtk+ deal with the Gtk+ parts. |
| @@ -584,8 +620,8 @@ xg_frame_resized (f, pixelwidth, pixelheight) | |||
| 584 | if (pixelwidth == -1 && pixelheight == -1) | 620 | if (pixelwidth == -1 && pixelheight == -1) |
| 585 | { | 621 | { |
| 586 | if (FRAME_GTK_WIDGET (f) && GTK_WIDGET_MAPPED (FRAME_GTK_WIDGET (f))) | 622 | if (FRAME_GTK_WIDGET (f) && GTK_WIDGET_MAPPED (FRAME_GTK_WIDGET (f))) |
| 587 | gdk_window_get_geometry(FRAME_GTK_WIDGET (f)->window, 0, 0, | 623 | gdk_window_get_geometry (FRAME_GTK_WIDGET (f)->window, 0, 0, |
| 588 | &pixelwidth, &pixelheight, 0); | 624 | &pixelwidth, &pixelheight, 0); |
| 589 | else return; | 625 | else return; |
| 590 | } | 626 | } |
| 591 | 627 | ||
| @@ -601,6 +637,7 @@ xg_frame_resized (f, pixelwidth, pixelheight) | |||
| 601 | FRAME_PIXEL_WIDTH (f) = pixelwidth; | 637 | FRAME_PIXEL_WIDTH (f) = pixelwidth; |
| 602 | FRAME_PIXEL_HEIGHT (f) = pixelheight; | 638 | FRAME_PIXEL_HEIGHT (f) = pixelheight; |
| 603 | 639 | ||
| 640 | xg_clear_under_internal_border (f); | ||
| 604 | change_frame_size (f, rows, columns, 0, 1, 0); | 641 | change_frame_size (f, rows, columns, 0, 1, 0); |
| 605 | SET_FRAME_GARBAGED (f); | 642 | SET_FRAME_GARBAGED (f); |
| 606 | cancel_mouse_face (f); | 643 | cancel_mouse_face (f); |
| @@ -637,6 +674,10 @@ xg_frame_set_char_size (f, cols, rows) | |||
| 637 | after calculating that value. */ | 674 | after calculating that value. */ |
| 638 | pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); | 675 | pixelwidth = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, cols); |
| 639 | 676 | ||
| 677 | |||
| 678 | /* Do this before resize, as we don't know yet if we will be resized. */ | ||
| 679 | xg_clear_under_internal_border (f); | ||
| 680 | |||
| 640 | /* Must resize our top level widget. Font size may have changed, | 681 | /* Must resize our top level widget. Font size may have changed, |
| 641 | but not rows/cols. */ | 682 | but not rows/cols. */ |
| 642 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), | 683 | gtk_window_resize (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)), |
| @@ -3201,15 +3242,43 @@ xg_update_scrollbar_pos (f, scrollbar_id, top, left, width, height) | |||
| 3201 | { | 3242 | { |
| 3202 | GtkWidget *wfixed = f->output_data.x->edit_widget; | 3243 | GtkWidget *wfixed = f->output_data.x->edit_widget; |
| 3203 | GtkWidget *wparent = gtk_widget_get_parent (wscroll); | 3244 | GtkWidget *wparent = gtk_widget_get_parent (wscroll); |
| 3245 | GtkFixed *wf = GTK_FIXED (wfixed); | ||
| 3246 | |||
| 3247 | /* Clear out old position. */ | ||
| 3248 | GList *iter; | ||
| 3249 | int oldx = -1, oldy = -1, oldw, oldh; | ||
| 3250 | for (iter = wf->children; iter; iter = iter->next) | ||
| 3251 | if (((GtkFixedChild *)iter->data)->widget == wparent) | ||
| 3252 | { | ||
| 3253 | GtkFixedChild *ch = (GtkFixedChild *)iter->data; | ||
| 3254 | if (ch->x != left || ch->y != top) | ||
| 3255 | { | ||
| 3256 | oldx = ch->x; | ||
| 3257 | oldy = ch->y; | ||
| 3258 | gtk_widget_get_size_request (wscroll, &oldw, &oldh); | ||
| 3259 | } | ||
| 3260 | break; | ||
| 3261 | } | ||
| 3204 | 3262 | ||
| 3205 | /* Move and resize to new values. */ | 3263 | /* Move and resize to new values. */ |
| 3206 | gtk_fixed_move (GTK_FIXED (wfixed), wparent, left, top); | 3264 | gtk_fixed_move (GTK_FIXED (wfixed), wparent, left, top); |
| 3207 | gtk_widget_set_size_request (wscroll, width, height); | 3265 | gtk_widget_set_size_request (wscroll, width, height); |
| 3208 | gtk_widget_queue_draw (wparent); | 3266 | gtk_widget_queue_draw (wfixed); |
| 3209 | gdk_window_process_all_updates (); | 3267 | gdk_window_process_all_updates (); |
| 3268 | if (oldx != -1) | ||
| 3269 | { | ||
| 3270 | /* Clear under old scroll bar position. This must be done after | ||
| 3271 | the gtk_widget_queue_draw and gdk_window_process_all_updates | ||
| 3272 | above. */ | ||
| 3273 | x_clear_area (FRAME_X_DISPLAY (f), | ||
| 3274 | FRAME_X_WINDOW (f), | ||
| 3275 | oldx, oldy, oldw, oldh, 0); | ||
| 3276 | } | ||
| 3277 | |||
| 3210 | /* GTK does not redraw until the main loop is entered again, but | 3278 | /* GTK does not redraw until the main loop is entered again, but |
| 3211 | if there are no X events pending we will not enter it. So we sync | 3279 | if there are no X events pending we will not enter it. So we sync |
| 3212 | here to get some events. */ | 3280 | here to get some events. */ |
| 3281 | |||
| 3213 | x_sync (f); | 3282 | x_sync (f); |
| 3214 | SET_FRAME_GARBAGED (f); | 3283 | SET_FRAME_GARBAGED (f); |
| 3215 | cancel_mouse_face (f); | 3284 | cancel_mouse_face (f); |
diff --git a/src/xterm.c b/src/xterm.c index 7f9f6f3c05e..65f58e49196 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -8064,32 +8064,7 @@ x_new_font (f, font_object, fontset) | |||
| 8064 | doing it because it's done in Fx_show_tip, and it leads to | 8064 | doing it because it's done in Fx_show_tip, and it leads to |
| 8065 | problems because the tip frame has no widget. */ | 8065 | problems because the tip frame has no widget. */ |
| 8066 | if (NILP (tip_frame) || XFRAME (tip_frame) != f) | 8066 | if (NILP (tip_frame) || XFRAME (tip_frame) != f) |
| 8067 | { | 8067 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); |
| 8068 | int rows, cols; | ||
| 8069 | |||
| 8070 | /* When the frame is maximized/fullscreen or running under for | ||
| 8071 | example Xmonad, x_set_window_size will be a no-op. | ||
| 8072 | In that case, the right thing to do is extend rows/cols to | ||
| 8073 | the current frame size. We do that first if x_set_window_size | ||
| 8074 | turns out to not be a no-op (there is no way to know). | ||
| 8075 | The size will be adjusted again if the frame gets a | ||
| 8076 | ConfigureNotify event as a result of x_set_window_size. */ | ||
| 8077 | int pixelh = FRAME_PIXEL_HEIGHT (f); | ||
| 8078 | #ifdef USE_X_TOOLKIT | ||
| 8079 | /* The menu bar is not part of text lines. The tool bar | ||
| 8080 | is however. */ | ||
| 8081 | pixelh -= FRAME_MENUBAR_HEIGHT (f); | ||
| 8082 | #endif | ||
| 8083 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelh); | ||
| 8084 | /* Update f->scroll_bar_actual_width because it is used in | ||
| 8085 | FRAME_PIXEL_WIDTH_TO_TEXT_COLS. */ | ||
| 8086 | f->scroll_bar_actual_width | ||
| 8087 | = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f); | ||
| 8088 | cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, FRAME_PIXEL_WIDTH (f)); | ||
| 8089 | |||
| 8090 | change_frame_size (f, rows, cols, 0, 1, 0); | ||
| 8091 | x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f)); | ||
| 8092 | } | ||
| 8093 | } | 8068 | } |
| 8094 | 8069 | ||
| 8095 | #ifdef HAVE_X_I18N | 8070 | #ifdef HAVE_X_I18N |
| @@ -8977,6 +8952,33 @@ x_set_window_size (f, change_gravity, cols, rows) | |||
| 8977 | { | 8952 | { |
| 8978 | BLOCK_INPUT; | 8953 | BLOCK_INPUT; |
| 8979 | 8954 | ||
| 8955 | if (NILP (tip_frame) || XFRAME (tip_frame) != f) | ||
| 8956 | { | ||
| 8957 | int r, c; | ||
| 8958 | |||
| 8959 | /* When the frame is maximized/fullscreen or running under for | ||
| 8960 | example Xmonad, x_set_window_size_1 will be a no-op. | ||
| 8961 | In that case, the right thing to do is extend rows/cols to | ||
| 8962 | the current frame size. We do that first if x_set_window_size_1 | ||
| 8963 | turns out to not be a no-op (there is no way to know). | ||
| 8964 | The size will be adjusted again if the frame gets a | ||
| 8965 | ConfigureNotify event as a result of x_set_window_size. */ | ||
| 8966 | int pixelh = FRAME_PIXEL_HEIGHT (f); | ||
| 8967 | #ifdef USE_X_TOOLKIT | ||
| 8968 | /* The menu bar is not part of text lines. The tool bar | ||
| 8969 | is however. */ | ||
| 8970 | pixelh -= FRAME_MENUBAR_HEIGHT (f); | ||
| 8971 | #endif | ||
| 8972 | r = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, pixelh); | ||
| 8973 | /* Update f->scroll_bar_actual_width because it is used in | ||
| 8974 | FRAME_PIXEL_WIDTH_TO_TEXT_COLS. */ | ||
| 8975 | f->scroll_bar_actual_width | ||
| 8976 | = FRAME_SCROLL_BAR_COLS (f) * FRAME_COLUMN_WIDTH (f); | ||
| 8977 | c = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, FRAME_PIXEL_WIDTH (f)); | ||
| 8978 | fprintf (stderr, "1: old %d/%d, new %d/%d\n", rows, cols, r, c); | ||
| 8979 | change_frame_size (f, r, c, 0, 1, 0); | ||
| 8980 | } | ||
| 8981 | |||
| 8980 | #ifdef USE_GTK | 8982 | #ifdef USE_GTK |
| 8981 | if (FRAME_GTK_WIDGET (f)) | 8983 | if (FRAME_GTK_WIDGET (f)) |
| 8982 | xg_frame_set_char_size (f, cols, rows); | 8984 | xg_frame_set_char_size (f, cols, rows); |