aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Rudalics2017-04-12 18:22:44 +0200
committerMartin Rudalics2017-04-12 18:22:44 +0200
commitc25005eda1c5ad8dabb3ce815658bd3c637ae686 (patch)
treed4c7e6bd2d2a9fe8cdc3345a0f84d6d0aa6d4987
parent8720f601e715e5f1d41f7cf863a525a1cc1bc12c (diff)
downloademacs-c25005eda1c5ad8dabb3ce815658bd3c637ae686.tar.gz
emacs-c25005eda1c5ad8dabb3ce815658bd3c637ae686.zip
New internal-border face and args for select-window and x-focus-frame
Add `internal-border' face and handle it whenever clearing the internal border. If NORECORD equals the symbol 'mark-for-redisplay', `select-window' will not record the window but still mark it for redisplay. The new argument NOACTIVATE for `x-focus-frame' tries to not activate FRAME when set. * lisp/faces.el (internal-border): New face. * lisp/mwheel.el (mwheel-scroll): Select window to scroll with `mark-for-redisplay'. * lisp/scroll-bar.el (scroll-bar-drag) (scroll-bar-horizontal-drag, scroll-bar-scroll-down) (scroll-bar-scroll-up, scroll-bar-toolkit-scroll) (scroll-bar-toolkit-horizontal-scroll): Select window to scroll with `mark-for-redisplay'. * lisp/window.el (handle-select-window): When `focus-follows-mouse' is not 'auto-raise' try to not activate FRAME. * src/dispextern.h (face_id): Add INTERNAL_BORDER_FACE_ID. * src/frame.c (Fx_focus_frame): New argument NOACTIVATE. * src/frame.h (x_focus_frame): Update extern declaration. * src/gtkutil.c (xg_clear_under_internal_border): Remove function. (xg_frame_resized, xg_frame_set_char_size): Call x_clear_under_internal_border. (xg_tool_bar_callback): Adapt x_focus_frame call. * src/gtkutil.h (xg_clear_under_internal_border): Remove declaration. * src/nsfns.m (x_focus_frame): Add argument NOACTIVATE. * src/w32fns.c (x_clear_under_internal_border): Fill border with internal-border background if specified. * src/w32term.h (x_clear_under_internal_border): Add extern declaration. * src/w32term.c (x_after_update_window_line): Fill border with internal-border background if specified. (w32_set_vertical_scroll_bar, w32_set_horizontal_scroll_bar) (x_scroll_bar_clear, w32_read_socket): Call x_clear_under_internal_border. (x_focus_frame): New argument NOACTIVATE. * src/window.c (select_window): Mark WINDOW for redisplay when NORECORD equals 'mark-for-redisplay'. (Fselect_window): Update doc-string. (syms_of_window): Define Qmark_for_redisplay. * src/xdisp.c (clear_garbaged_frames, echo_area_display) (redisplay_internal): Call x_clear_under_internal_border. * src/xfaces.c (lookup_basic_face): Handle `window-divider' and `internal-border' faces. (realize_basic_faces): Realize `internal-border' face. (syms_of_xfaces): Define Qinternal_border. * src/xfns.c (x_set_internal_border_width): Remove call for xg_clear_under_internal_border. (x_focus_frame): New argument NOACTIVATE. When non-nil try to not activate frame. * src/xterm.c (x_fill_rectangle): No more static. (x_clear_under_internal_border, x_after_update_window_line): Fill border with internal-border background if specified. (xt_horizontal_action_hook): Rewrite. (handle_one_xevent): Call x_clear_under_internal_border. * src/xterm.h (x_fill_rectangle): Add extern declaration.
-rw-r--r--lisp/faces.el7
-rw-r--r--lisp/mwheel.el3
-rw-r--r--lisp/scroll-bar.el12
-rw-r--r--lisp/window.el2
-rw-r--r--src/dispextern.h1
-rw-r--r--src/frame.c10
-rw-r--r--src/frame.h2
-rw-r--r--src/gtkutil.c30
-rw-r--r--src/gtkutil.h1
-rw-r--r--src/nsfns.m2
-rw-r--r--src/w32fns.c30
-rw-r--r--src/w32term.c35
-rw-r--r--src/w32term.h2
-rw-r--r--src/window.c6
-rw-r--r--src/xdisp.c18
-rw-r--r--src/xfaces.c10
-rw-r--r--src/xfns.c12
-rw-r--r--src/xterm.c104
-rw-r--r--src/xterm.h1
19 files changed, 196 insertions, 92 deletions
diff --git a/lisp/faces.el b/lisp/faces.el
index e62561a63a5..a6ffd1ecd33 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2629,6 +2629,13 @@ the same as `window-divider' face."
2629 :group 'window-divider 2629 :group 'window-divider
2630 :group 'basic-faces) 2630 :group 'basic-faces)
2631 2631
2632(defface internal-border
2633 '((t nil))
2634 "Basic face for the internal border."
2635 :version "26.1"
2636 :group 'frames
2637 :group 'basic-faces)
2638
2632(defface minibuffer-prompt 2639(defface minibuffer-prompt
2633 '((((background dark)) :foreground "cyan") 2640 '((((background dark)) :foreground "cyan")
2634 ;; Don't use blue because many users of the MS-DOS port customize 2641 ;; Don't use blue because many users of the MS-DOS port customize
diff --git a/lisp/mwheel.el b/lisp/mwheel.el
index 73fd2b7e115..1428e5f4d01 100644
--- a/lisp/mwheel.el
+++ b/lisp/mwheel.el
@@ -220,6 +220,9 @@ non-Windows systems."
220 (mods 220 (mods
221 (delq 'click (delq 'double (delq 'triple (event-modifiers event))))) 221 (delq 'click (delq 'double (delq 'triple (event-modifiers event)))))
222 (amt (assoc mods mouse-wheel-scroll-amount))) 222 (amt (assoc mods mouse-wheel-scroll-amount)))
223 (unless (eq scroll-window selected-window)
224 ;; Mark window to be scrolled for redisplay.
225 (select-window scroll-window 'mark-for-redisplay))
223 ;; Extract the actual amount or find the element that has no modifiers. 226 ;; Extract the actual amount or find the element that has no modifiers.
224 (if amt (setq amt (cdr amt)) 227 (if amt (setq amt (cdr amt))
225 (let ((list-elt mouse-wheel-scroll-amount)) 228 (let ((list-elt mouse-wheel-scroll-amount))
diff --git a/lisp/scroll-bar.el b/lisp/scroll-bar.el
index 5290a7b3bee..58352740447 100644
--- a/lisp/scroll-bar.el
+++ b/lisp/scroll-bar.el
@@ -281,7 +281,7 @@ If you click outside the slider, the window scrolls to bring the slider there."
281 (with-current-buffer (window-buffer window) 281 (with-current-buffer (window-buffer window)
282 (setq before-scroll point-before-scroll)) 282 (setq before-scroll point-before-scroll))
283 (save-selected-window 283 (save-selected-window
284 (select-window window) 284 (select-window window 'mark-for-redisplay)
285 (setq before-scroll 285 (setq before-scroll
286 (or before-scroll (point)))) 286 (or before-scroll (point))))
287 (scroll-bar-drag-1 event) 287 (scroll-bar-drag-1 event)
@@ -326,7 +326,7 @@ If you click outside the slider, the window scrolls to bring the slider there."
326 (with-current-buffer (window-buffer window) 326 (with-current-buffer (window-buffer window)
327 (setq before-scroll point-before-scroll)) 327 (setq before-scroll point-before-scroll))
328 (save-selected-window 328 (save-selected-window
329 (select-window window) 329 (select-window window 'mark-for-redisplay)
330 (setq before-scroll 330 (setq before-scroll
331 (or before-scroll (point)))) 331 (or before-scroll (point))))
332 (scroll-bar-horizontal-drag-1 event) 332 (scroll-bar-horizontal-drag-1 event)
@@ -356,7 +356,7 @@ EVENT should be a scroll bar click."
356 (unwind-protect 356 (unwind-protect
357 (save-selected-window 357 (save-selected-window
358 (let ((portion-whole (nth 2 end-position))) 358 (let ((portion-whole (nth 2 end-position)))
359 (select-window window) 359 (select-window window 'mark-for-redisplay)
360 (setq before-scroll 360 (setq before-scroll
361 (or before-scroll (point))) 361 (or before-scroll (point)))
362 (scroll-down 362 (scroll-down
@@ -377,7 +377,7 @@ EVENT should be a scroll bar click."
377 (unwind-protect 377 (unwind-protect
378 (save-selected-window 378 (save-selected-window
379 (let ((portion-whole (nth 2 end-position))) 379 (let ((portion-whole (nth 2 end-position)))
380 (select-window window) 380 (select-window window 'mark-for-redisplay)
381 (setq before-scroll 381 (setq before-scroll
382 (or before-scroll (point))) 382 (or before-scroll (point)))
383 (scroll-up 383 (scroll-up
@@ -402,7 +402,7 @@ EVENT should be a scroll bar click."
402 (with-current-buffer (window-buffer window) 402 (with-current-buffer (window-buffer window)
403 (setq before-scroll point-before-scroll)) 403 (setq before-scroll point-before-scroll))
404 (save-selected-window 404 (save-selected-window
405 (select-window window) 405 (select-window window 'mark-for-redisplay)
406 (setq before-scroll (or before-scroll (point))) 406 (setq before-scroll (or before-scroll (point)))
407 (cond 407 (cond
408 ((eq part 'above-handle) 408 ((eq part 'above-handle)
@@ -449,7 +449,7 @@ EVENT should be a scroll bar click."
449 (with-current-buffer (window-buffer window) 449 (with-current-buffer (window-buffer window)
450 (setq before-scroll point-before-scroll)) 450 (setq before-scroll point-before-scroll))
451 (save-selected-window 451 (save-selected-window
452 (select-window window) 452 (select-window window 'mark-for-redisplay)
453 (setq before-scroll (or before-scroll (point))) 453 (setq before-scroll (or before-scroll (point)))
454 (cond 454 (cond
455 ((eq part 'before-handle) 455 ((eq part 'before-handle)
diff --git a/lisp/window.el b/lisp/window.el
index bea8383fcde..f4a834c0d8c 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8855,7 +8855,7 @@ is active. This function is run by `mouse-autoselect-window-timer'."
8855 (raise-frame frame)) 8855 (raise-frame frame))
8856 (t 8856 (t
8857 ;; Just focus frame. 8857 ;; Just focus frame.
8858 (x-focus-frame frame)))))) 8858 (x-focus-frame frame t))))))
8859 8859
8860(defun truncated-partial-width-window-p (&optional window) 8860(defun truncated-partial-width-window-p (&optional window)
8861 "Return non-nil if lines in WINDOW are specifically truncated due to its width. 8861 "Return non-nil if lines in WINDOW are specifically truncated due to its width.
diff --git a/src/dispextern.h b/src/dispextern.h
index 679820d5063..d1e4715c329 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -1784,6 +1784,7 @@ enum face_id
1784 WINDOW_DIVIDER_FACE_ID, 1784 WINDOW_DIVIDER_FACE_ID,
1785 WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID, 1785 WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID,
1786 WINDOW_DIVIDER_LAST_PIXEL_FACE_ID, 1786 WINDOW_DIVIDER_LAST_PIXEL_FACE_ID,
1787 INTERNAL_BORDER_FACE_ID,
1787 BASIC_FACE_ID_SENTINEL 1788 BASIC_FACE_ID_SENTINEL
1788}; 1789};
1789 1790
diff --git a/src/frame.c b/src/frame.c
index e5d80fa8257..fc7982d0d55 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2450,14 +2450,16 @@ See `redirect-frame-focus'. */)
2450 return FRAME_FOCUS_FRAME (decode_live_frame (frame)); 2450 return FRAME_FOCUS_FRAME (decode_live_frame (frame));
2451} 2451}
2452 2452
2453DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0, 2453DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 2, 0,
2454 doc: /* Set the input focus to FRAME. 2454 doc: /* Set the input focus to FRAME.
2455FRAME nil means use the selected frame. 2455FRAME nil means use the selected frame. Optional argument NOACTIVATE
2456means do not activate FRAME.
2457
2456If there is no window system support, this function does nothing. */) 2458If there is no window system support, this function does nothing. */)
2457 (Lisp_Object frame) 2459 (Lisp_Object frame, Lisp_Object noactivate)
2458{ 2460{
2459#ifdef HAVE_WINDOW_SYSTEM 2461#ifdef HAVE_WINDOW_SYSTEM
2460 x_focus_frame (decode_window_system_frame (frame)); 2462 x_focus_frame (decode_window_system_frame (frame), !NILP (noactivate));
2461#endif 2463#endif
2462 return Qnil; 2464 return Qnil;
2463} 2465}
diff --git a/src/frame.h b/src/frame.h
index 84f9a05d774..36af6e67804 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1531,7 +1531,7 @@ extern void x_sync (struct frame *);
1531#endif /* HAVE_X_WINDOWS */ 1531#endif /* HAVE_X_WINDOWS */
1532 1532
1533extern void x_query_colors (struct frame *f, XColor *, int); 1533extern void x_query_colors (struct frame *f, XColor *, int);
1534extern void x_focus_frame (struct frame *); 1534extern void x_focus_frame (struct frame *, bool);
1535 1535
1536#ifndef HAVE_NS 1536#ifndef HAVE_NS
1537 1537
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 227a062bff3..ad3590dfa66 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -835,30 +835,6 @@ xg_set_geometry (struct frame *f)
835 } 835 }
836} 836}
837 837
838/* Clear under internal border if any. As we use a mix of Gtk+ and X calls
839 and use a GtkFixed widget, this doesn't happen automatically. */
840
841void
842xg_clear_under_internal_border (struct frame *f)
843{
844 if (FRAME_INTERNAL_BORDER_WIDTH (f) > 0)
845 {
846 x_clear_area (f, 0, 0,
847 FRAME_PIXEL_WIDTH (f), FRAME_INTERNAL_BORDER_WIDTH (f));
848
849 x_clear_area (f, 0, 0,
850 FRAME_INTERNAL_BORDER_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
851
852 x_clear_area (f, 0,
853 FRAME_PIXEL_HEIGHT (f) - FRAME_INTERNAL_BORDER_WIDTH (f),
854 FRAME_PIXEL_WIDTH (f), FRAME_INTERNAL_BORDER_WIDTH (f));
855
856 x_clear_area (f,
857 FRAME_PIXEL_WIDTH (f) - FRAME_INTERNAL_BORDER_WIDTH (f),
858 0, FRAME_INTERNAL_BORDER_WIDTH (f), FRAME_PIXEL_HEIGHT (f));
859 }
860}
861
862static int 838static int
863xg_get_gdk_scale (void) 839xg_get_gdk_scale (void)
864{ 840{
@@ -905,7 +881,7 @@ xg_frame_resized (struct frame *f, int pixelwidth, int pixelheight)
905 || pixelwidth != FRAME_PIXEL_WIDTH (f) 881 || pixelwidth != FRAME_PIXEL_WIDTH (f)
906 || pixelheight != FRAME_PIXEL_HEIGHT (f)) 882 || pixelheight != FRAME_PIXEL_HEIGHT (f))
907 { 883 {
908 xg_clear_under_internal_border (f); 884 x_clear_under_internal_border (f);
909 change_frame_size (f, width, height, 0, 1, 0, 1); 885 change_frame_size (f, width, height, 0, 1, 0, 1);
910 SET_FRAME_GARBAGED (f); 886 SET_FRAME_GARBAGED (f);
911 cancel_mouse_face (f); 887 cancel_mouse_face (f);
@@ -933,7 +909,7 @@ xg_frame_set_char_size (struct frame *f, int width, int height)
933 &gwidth, &gheight); 909 &gwidth, &gheight);
934 910
935 /* Do this before resize, as we don't know yet if we will be resized. */ 911 /* Do this before resize, as we don't know yet if we will be resized. */
936 xg_clear_under_internal_border (f); 912 x_clear_under_internal_border (f);
937 913
938 if (FRAME_VISIBLE_P (f)) 914 if (FRAME_VISIBLE_P (f))
939 { 915 {
@@ -4361,7 +4337,7 @@ xg_tool_bar_callback (GtkWidget *w, gpointer client_data)
4361 4337
4362 /* Return focus to the frame after we have clicked on a detached 4338 /* Return focus to the frame after we have clicked on a detached
4363 tool bar button. */ 4339 tool bar button. */
4364 x_focus_frame (f); 4340 x_focus_frame (f, false);
4365} 4341}
4366 4342
4367static GtkWidget * 4343static GtkWidget *
diff --git a/src/gtkutil.h b/src/gtkutil.h
index 244549fc54b..0abcb06bc71 100644
--- a/src/gtkutil.h
+++ b/src/gtkutil.h
@@ -150,7 +150,6 @@ extern void update_frame_tool_bar (struct frame *f);
150extern void free_frame_tool_bar (struct frame *f); 150extern void free_frame_tool_bar (struct frame *f);
151extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos); 151extern void xg_change_toolbar_position (struct frame *f, Lisp_Object pos);
152 152
153extern void xg_clear_under_internal_border (struct frame *f);
154extern void xg_frame_resized (struct frame *f, 153extern void xg_frame_resized (struct frame *f,
155 int pixelwidth, 154 int pixelwidth,
156 int pixelheight); 155 int pixelheight);
diff --git a/src/nsfns.m b/src/nsfns.m
index e8f035f0e57..8a923dd3933 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1391,7 +1391,7 @@ This function is an internal primitive--use `make-frame' instead. */)
1391} 1391}
1392 1392
1393void 1393void
1394x_focus_frame (struct frame *f) 1394x_focus_frame (struct frame *f, bool noactivate)
1395{ 1395{
1396 struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); 1396 struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
1397 1397
diff --git a/src/w32fns.c b/src/w32fns.c
index f7d3b722abf..62798f269ef 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -1634,7 +1634,13 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
1634#endif 1634#endif
1635} 1635}
1636 1636
1637static void 1637/**
1638 * x_clear_under_internal_border:
1639 *
1640 * Clear area of frame F's internal border. If the internal border face
1641 * of F has been specified (is not null), fill the area with that face.
1642 */
1643void
1638x_clear_under_internal_border (struct frame *f) 1644x_clear_under_internal_border (struct frame *f)
1639{ 1645{
1640 int border = FRAME_INTERNAL_BORDER_WIDTH (f); 1646 int border = FRAME_INTERNAL_BORDER_WIDTH (f);
@@ -1645,12 +1651,26 @@ x_clear_under_internal_border (struct frame *f)
1645 HDC hdc = get_frame_dc (f); 1651 HDC hdc = get_frame_dc (f);
1646 int width = FRAME_PIXEL_WIDTH (f); 1652 int width = FRAME_PIXEL_WIDTH (f);
1647 int height = FRAME_PIXEL_HEIGHT (f); 1653 int height = FRAME_PIXEL_HEIGHT (f);
1654 struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
1648 1655
1649 block_input (); 1656 block_input ();
1650 w32_clear_area (f, hdc, 0, FRAME_TOP_MARGIN_HEIGHT (f), width, border); 1657 if (face)
1651 w32_clear_area (f, hdc, 0, 0, border, height); 1658 {
1652 w32_clear_area (f, hdc, width - border, 0, border, height); 1659 /* Fill border with internal border face. */
1653 w32_clear_area (f, hdc, 0, height - border, width, border); 1660 unsigned long color = face->background;
1661
1662 w32_fill_area (f, hdc, color, 0, FRAME_TOP_MARGIN_HEIGHT (f), width, border);
1663 w32_fill_area (f, hdc, color, 0, 0, border, height);
1664 w32_fill_area (f, hdc, color, width - border, 0, border, height);
1665 w32_fill_area (f, hdc, color, 0, height - border, width, border);
1666 }
1667 else
1668 {
1669 w32_clear_area (f, hdc, 0, FRAME_TOP_MARGIN_HEIGHT (f), width, border);
1670 w32_clear_area (f, hdc, 0, 0, border, height);
1671 w32_clear_area (f, hdc, width - border, 0, border, height);
1672 w32_clear_area (f, hdc, 0, height - border, width, border);
1673 }
1654 release_frame_dc (f, hdc); 1674 release_frame_dc (f, hdc);
1655 unblock_input (); 1675 unblock_input ();
1656 } 1676 }
diff --git a/src/w32term.c b/src/w32term.c
index b50f0d39a48..1c3d243b62c 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -782,9 +782,23 @@ x_after_update_window_line (struct window *w, struct glyph_row *desired_row)
782 block_input (); 782 block_input ();
783 { 783 {
784 HDC hdc = get_frame_dc (f); 784 HDC hdc = get_frame_dc (f);
785 w32_clear_area (f, hdc, 0, y, width, height); 785 struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
786 w32_clear_area (f, hdc, FRAME_PIXEL_WIDTH (f) - width, 786
787 y, width, height); 787 if (face)
788 {
789 /* Fill border with internal border face. */
790 unsigned long color = face->background;
791
792 w32_fill_area (f, hdc, color, 0, y, width, height);
793 w32_fill_area (f, hdc, color, FRAME_PIXEL_WIDTH (f) - width,
794 y, width, height);
795 }
796 else
797 {
798 w32_clear_area (f, hdc, 0, y, width, height);
799 w32_clear_area (f, hdc, FRAME_PIXEL_WIDTH (f) - width,
800 y, width, height);
801 }
788 release_frame_dc (f, hdc); 802 release_frame_dc (f, hdc);
789 } 803 }
790 unblock_input (); 804 unblock_input ();
@@ -3908,6 +3922,7 @@ w32_set_vertical_scroll_bar (struct window *w,
3908 for them on the frame, we have to clear "under" them. */ 3922 for them on the frame, we have to clear "under" them. */
3909 w32_clear_area (f, hdc, left, top, width, height); 3923 w32_clear_area (f, hdc, left, top, width, height);
3910 release_frame_dc (f, hdc); 3924 release_frame_dc (f, hdc);
3925 x_clear_under_internal_border (f);
3911 } 3926 }
3912 /* Make sure scroll bar is "visible" before moving, to ensure the 3927 /* Make sure scroll bar is "visible" before moving, to ensure the
3913 area of the parent window now exposed will be refreshed. */ 3928 area of the parent window now exposed will be refreshed. */
@@ -4009,6 +4024,7 @@ w32_set_horizontal_scroll_bar (struct window *w,
4009 for them on the frame, we have to clear "under" them. */ 4024 for them on the frame, we have to clear "under" them. */
4010 w32_clear_area (f, hdc, clear_left, top, clear_width, height); 4025 w32_clear_area (f, hdc, clear_left, top, clear_width, height);
4011 release_frame_dc (f, hdc); 4026 release_frame_dc (f, hdc);
4027 x_clear_under_internal_border (f);
4012 } 4028 }
4013 /* Make sure scroll bar is "visible" before moving, to ensure the 4029 /* Make sure scroll bar is "visible" before moving, to ensure the
4014 area of the parent window now exposed will be refreshed. */ 4030 area of the parent window now exposed will be refreshed. */
@@ -4553,6 +4569,7 @@ x_scroll_bar_clear (struct frame *f)
4553 GetClientRect (window, &rect); 4569 GetClientRect (window, &rect);
4554 select_palette (f, hdc); 4570 select_palette (f, hdc);
4555 w32_clear_rect (f, hdc, &rect); 4571 w32_clear_rect (f, hdc, &rect);
4572 x_clear_under_internal_border (f);
4556 deselect_palette (f, hdc); 4573 deselect_palette (f, hdc);
4557 4574
4558 ReleaseDC (window, hdc); 4575 ReleaseDC (window, hdc);
@@ -4682,6 +4699,7 @@ w32_read_socket (struct terminal *terminal,
4682 msg.rect.top, 4699 msg.rect.top,
4683 msg.rect.right - msg.rect.left, 4700 msg.rect.right - msg.rect.left,
4684 msg.rect.bottom - msg.rect.top); 4701 msg.rect.bottom - msg.rect.top);
4702 x_clear_under_internal_border (f);
4685 } 4703 }
4686 } 4704 }
4687 break; 4705 break;
@@ -5118,6 +5136,9 @@ w32_read_socket (struct terminal *terminal,
5118 } 5136 }
5119#endif 5137#endif
5120 5138
5139 if (f = x_window_to_frame (dpyinfo, msg.msg.hwnd))
5140 x_clear_under_internal_border (f);
5141
5121 check_visibility = 1; 5142 check_visibility = 1;
5122 break; 5143 break;
5123 5144
@@ -6392,10 +6413,14 @@ frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
6392} 6413}
6393 6414
6394 6415
6395/* focus shifting, raising and lowering. */ 6416/* Focus shifting, raising and lowering. */
6417
6418/* The NOACTIVATE argument has no effect on Windows. According to the
6419 Windows API: An application cannot activate an inactive window
6420 without also bringing it to the top of the Z order. */
6396 6421
6397void 6422void
6398x_focus_frame (struct frame *f) 6423x_focus_frame (struct frame *f, bool noactivate)
6399{ 6424{
6400#if 0 6425#if 0
6401 struct w32_display_info *dpyinfo = &one_w32_display_info; 6426 struct w32_display_info *dpyinfo = &one_w32_display_info;
diff --git a/src/w32term.h b/src/w32term.h
index 6896ef4f2c6..371cf9005bc 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -707,7 +707,7 @@ extern BOOL parse_button (int, int, int *, int *);
707 707
708extern void w32_sys_ring_bell (struct frame *f); 708extern void w32_sys_ring_bell (struct frame *f);
709extern void x_delete_display (struct w32_display_info *dpyinfo); 709extern void x_delete_display (struct w32_display_info *dpyinfo);
710 710extern void x_clear_under_internal_border (struct frame *f);
711extern void x_query_color (struct frame *, XColor *); 711extern void x_query_color (struct frame *, XColor *);
712 712
713#define FILE_NOTIFICATIONS_SIZE 16384 713#define FILE_NOTIFICATIONS_SIZE 16384
diff --git a/src/window.c b/src/window.c
index 58c0c33cbb0..2d6f0e48faa 100644
--- a/src/window.c
+++ b/src/window.c
@@ -492,7 +492,7 @@ select_window (Lisp_Object window, Lisp_Object norecord,
492 record_buffer before returning here. */ 492 record_buffer before returning here. */
493 goto record_and_return; 493 goto record_and_return;
494 494
495 if (NILP (norecord)) 495 if (NILP (norecord) || EQ (norecord, Qmark_for_redisplay))
496 { /* Mark the window for redisplay since the selected-window has 496 { /* Mark the window for redisplay since the selected-window has
497 a different mode-line. */ 497 a different mode-line. */
498 wset_redisplay (XWINDOW (selected_window)); 498 wset_redisplay (XWINDOW (selected_window));
@@ -571,7 +571,8 @@ Return WINDOW.
571 571
572Optional second arg NORECORD non-nil means do not put this buffer at the 572Optional second arg NORECORD non-nil means do not put this buffer at the
573front of the buffer list and do not make this window the most recently 573front of the buffer list and do not make this window the most recently
574selected one. 574selected one. Also, do not mark WINDOW for redisplay unless NORECORD
575equals the special symbol `mark-for-redisplay'.
575 576
576Run `buffer-list-update-hook' unless NORECORD is non-nil. Note that 577Run `buffer-list-update-hook' unless NORECORD is non-nil. Note that
577applications and internal routines often select a window temporarily for 578applications and internal routines often select a window temporarily for
@@ -7350,6 +7351,7 @@ syms_of_window (void)
7350 DEFSYM (Qclone_of, "clone-of"); 7351 DEFSYM (Qclone_of, "clone-of");
7351 DEFSYM (Qfloor, "floor"); 7352 DEFSYM (Qfloor, "floor");
7352 DEFSYM (Qceiling, "ceiling"); 7353 DEFSYM (Qceiling, "ceiling");
7354 DEFSYM (Qmark_for_redisplay, "mark-for-redisplay");
7353 7355
7354 staticpro (&Vwindow_list); 7356 staticpro (&Vwindow_list);
7355 7357
diff --git a/src/xdisp.c b/src/xdisp.c
index 42a59d63b13..58b5ca2f018 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11379,6 +11379,11 @@ clear_garbaged_frames (void)
11379 redraw_frame (f); 11379 redraw_frame (f);
11380 else 11380 else
11381 clear_current_matrices (f); 11381 clear_current_matrices (f);
11382
11383#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS)
11384 x_clear_under_internal_border (f);
11385#endif /* HAVE_WINDOW_SYSTEM && !HAVE_NS */
11386
11382 fset_redisplay (f); 11387 fset_redisplay (f);
11383 f->garbaged = false; 11388 f->garbaged = false;
11384 f->resized_p = false; 11389 f->resized_p = false;
@@ -11441,7 +11446,14 @@ echo_area_display (bool update_frame_p)
11441 been called, so that mode lines above the echo area are 11446 been called, so that mode lines above the echo area are
11442 garbaged. This looks odd, so we prevent it here. */ 11447 garbaged. This looks odd, so we prevent it here. */
11443 if (!display_completed) 11448 if (!display_completed)
11444 n = redisplay_mode_lines (FRAME_ROOT_WINDOW (f), false); 11449 {
11450 n = redisplay_mode_lines (FRAME_ROOT_WINDOW (f), false);
11451
11452#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS)
11453 x_clear_under_internal_border (f);
11454#endif /* HAVE_WINDOW_SYSTEM && !HAVE_NS */
11455
11456 }
11445 11457
11446 if (window_height_changed_p 11458 if (window_height_changed_p
11447 /* Don't do this if Emacs is shutting down. Redisplay 11459 /* Don't do this if Emacs is shutting down. Redisplay
@@ -14151,6 +14163,10 @@ redisplay_internal (void)
14151 if (FRAME_GARBAGED_P (f)) 14163 if (FRAME_GARBAGED_P (f))
14152 goto retry; 14164 goto retry;
14153 14165
14166#if defined (HAVE_WINDOW_SYSTEM) && !defined (HAVE_NS)
14167 x_clear_under_internal_border (f);
14168#endif /* HAVE_WINDOW_SYSTEM && !HAVE_NS */
14169
14154 /* Prevent various kinds of signals during display 14170 /* Prevent various kinds of signals during display
14155 update. stdio is not robust about handling 14171 update. stdio is not robust about handling
14156 signals, which can cause an apparent I/O error. */ 14172 signals, which can cause an apparent I/O error. */
diff --git a/src/xfaces.c b/src/xfaces.c
index 7fcaef4e41a..4714b7b3cb8 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -4474,6 +4474,10 @@ lookup_basic_face (struct frame *f, int face_id)
4474 case CURSOR_FACE_ID: name = Qcursor; break; 4474 case CURSOR_FACE_ID: name = Qcursor; break;
4475 case MOUSE_FACE_ID: name = Qmouse; break; 4475 case MOUSE_FACE_ID: name = Qmouse; break;
4476 case MENU_FACE_ID: name = Qmenu; break; 4476 case MENU_FACE_ID: name = Qmenu; break;
4477 case WINDOW_DIVIDER_FACE_ID: name = Qwindow_divider; break;
4478 case WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID: name = Qwindow_divider_first_pixel; break;
4479 case WINDOW_DIVIDER_LAST_PIXEL_FACE_ID: name = Qwindow_divider_last_pixel; break;
4480 case INTERNAL_BORDER_FACE_ID: name = Qinternal_border; break;
4477 4481
4478 default: 4482 default:
4479 emacs_abort (); /* the caller is supposed to pass us a basic face id */ 4483 emacs_abort (); /* the caller is supposed to pass us a basic face id */
@@ -5168,6 +5172,7 @@ realize_basic_faces (struct frame *f)
5168 WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID); 5172 WINDOW_DIVIDER_FIRST_PIXEL_FACE_ID);
5169 realize_named_face (f, Qwindow_divider_last_pixel, 5173 realize_named_face (f, Qwindow_divider_last_pixel,
5170 WINDOW_DIVIDER_LAST_PIXEL_FACE_ID); 5174 WINDOW_DIVIDER_LAST_PIXEL_FACE_ID);
5175 realize_named_face (f, Qinternal_border, INTERNAL_BORDER_FACE_ID);
5171 5176
5172 /* Reflect changes in the `menu' face in menu bars. */ 5177 /* Reflect changes in the `menu' face in menu bars. */
5173 if (FRAME_FACE_CACHE (f)->menu_face_changed_p) 5178 if (FRAME_FACE_CACHE (f)->menu_face_changed_p)
@@ -6420,11 +6425,12 @@ syms_of_xfaces (void)
6420 DEFSYM (Qmouse, "mouse"); 6425 DEFSYM (Qmouse, "mouse");
6421 DEFSYM (Qmode_line_inactive, "mode-line-inactive"); 6426 DEFSYM (Qmode_line_inactive, "mode-line-inactive");
6422 DEFSYM (Qvertical_border, "vertical-border"); 6427 DEFSYM (Qvertical_border, "vertical-border");
6423
6424 /* TTY color-related functions (defined in tty-colors.el). */
6425 DEFSYM (Qwindow_divider, "window-divider"); 6428 DEFSYM (Qwindow_divider, "window-divider");
6426 DEFSYM (Qwindow_divider_first_pixel, "window-divider-first-pixel"); 6429 DEFSYM (Qwindow_divider_first_pixel, "window-divider-first-pixel");
6427 DEFSYM (Qwindow_divider_last_pixel, "window-divider-last-pixel"); 6430 DEFSYM (Qwindow_divider_last_pixel, "window-divider-last-pixel");
6431 DEFSYM (Qinternal_border, "internal-border");
6432
6433 /* TTY color-related functions (defined in tty-colors.el). */
6428 DEFSYM (Qtty_color_desc, "tty-color-desc"); 6434 DEFSYM (Qtty_color_desc, "tty-color-desc");
6429 DEFSYM (Qtty_color_standard_values, "tty-color-standard-values"); 6435 DEFSYM (Qtty_color_standard_values, "tty-color-standard-values");
6430 DEFSYM (Qtty_color_by_index, "tty-color-by-index"); 6436 DEFSYM (Qtty_color_by_index, "tty-color-by-index");
diff --git a/src/xfns.c b/src/xfns.c
index 3d667446e67..3257805cabb 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1703,15 +1703,10 @@ x_set_internal_border_width (struct frame *f, Lisp_Object arg, Lisp_Object oldva
1703 widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget); 1703 widget_store_internal_border (FRAME_X_OUTPUT (f)->edit_widget);
1704#endif 1704#endif
1705 1705
1706 if (FRAME_X_WINDOW (f) != 0) 1706 if (FRAME_X_WINDOW (f))
1707 { 1707 {
1708 adjust_frame_size (f, -1, -1, 3, false, Qinternal_border_width); 1708 adjust_frame_size (f, -1, -1, 3, false, Qinternal_border_width);
1709
1710#ifdef USE_GTK
1711 xg_clear_under_internal_border (f);
1712#else
1713 x_clear_under_internal_border (f); 1709 x_clear_under_internal_border (f);
1714#endif
1715 } 1710 }
1716 } 1711 }
1717 1712
@@ -4076,7 +4071,7 @@ x_get_focus_frame (struct frame *frame)
4076 following a user-command. */ 4071 following a user-command. */
4077 4072
4078void 4073void
4079x_focus_frame (struct frame *f) 4074x_focus_frame (struct frame *f, bool noactivate)
4080{ 4075{
4081 Display *dpy = FRAME_X_DISPLAY (f); 4076 Display *dpy = FRAME_X_DISPLAY (f);
4082 4077
@@ -4094,7 +4089,8 @@ x_focus_frame (struct frame *f)
4094 { 4089 {
4095 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4090 XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4096 RevertToParent, CurrentTime); 4091 RevertToParent, CurrentTime);
4097 x_ewmh_activate_frame (f); 4092 if (!noactivate)
4093 x_ewmh_activate_frame (f);
4098 } 4094 }
4099 4095
4100 x_uncatch_errors (); 4096 x_uncatch_errors ();
diff --git a/src/xterm.c b/src/xterm.c
index 4444a5c187a..8dc1067a688 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -714,7 +714,7 @@ x_reset_clip_rectangles (struct frame *f, GC gc)
714#endif 714#endif
715} 715}
716 716
717static void 717void
718x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height) 718x_fill_rectangle (struct frame *f, GC gc, int x, int y, int width, int height)
719{ 719{
720#ifdef USE_CAIRO 720#ifdef USE_CAIRO
@@ -1295,8 +1295,12 @@ XTbuffer_flipping_unblocked_hook (struct frame *f)
1295 show_back_buffer (f); 1295 show_back_buffer (f);
1296} 1296}
1297 1297
1298/* Clear under internal border if any (GTK has its own version). */ 1298/**
1299#ifndef USE_GTK 1299 * x_clear_under_internal_border:
1300 *
1301 * Clear area of frame F's internal border. If the internal border face
1302 * of F has been specified (is not null), fill the area with that face.
1303 */
1300void 1304void
1301x_clear_under_internal_border (struct frame *f) 1305x_clear_under_internal_border (struct frame *f)
1302{ 1306{
@@ -1305,17 +1309,39 @@ x_clear_under_internal_border (struct frame *f)
1305 int border = FRAME_INTERNAL_BORDER_WIDTH (f); 1309 int border = FRAME_INTERNAL_BORDER_WIDTH (f);
1306 int width = FRAME_PIXEL_WIDTH (f); 1310 int width = FRAME_PIXEL_WIDTH (f);
1307 int height = FRAME_PIXEL_HEIGHT (f); 1311 int height = FRAME_PIXEL_HEIGHT (f);
1312#ifdef USE_GTK
1313 int margin = 0;
1314#else
1308 int margin = FRAME_TOP_MARGIN_HEIGHT (f); 1315 int margin = FRAME_TOP_MARGIN_HEIGHT (f);
1316#endif
1317 struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
1309 1318
1310 block_input (); 1319 block_input ();
1311 x_clear_area (f, 0, 0, border, height); 1320
1312 x_clear_area (f, 0, margin, width, border); 1321 if (face)
1313 x_clear_area (f, width - border, 0, border, height); 1322 {
1314 x_clear_area (f, 0, height - border, width, border); 1323 unsigned long color = face->background;
1324 Display *display = FRAME_X_DISPLAY (f);
1325 GC gc = f->output_data.x->normal_gc;
1326
1327 XSetForeground (display, gc, color);
1328 x_fill_rectangle (f, gc, 0, margin, width, border);
1329 x_fill_rectangle (f, gc, 0, 0, border, height);
1330 x_fill_rectangle (f, gc, width - border, 0, border, height);
1331 x_fill_rectangle (f, gc, 0, height - border, width, border);
1332 XSetForeground (display, gc, FRAME_FOREGROUND_PIXEL (f));
1333 }
1334 else
1335 {
1336 x_clear_area (f, 0, 0, border, height);
1337 x_clear_area (f, 0, margin, width, border);
1338 x_clear_area (f, width - border, 0, border, height);
1339 x_clear_area (f, 0, height - border, width, border);
1340 }
1341
1315 unblock_input (); 1342 unblock_input ();
1316 } 1343 }
1317} 1344}
1318#endif
1319 1345
1320/* Draw truncation mark bitmaps, continuation mark bitmaps, overlay 1346/* Draw truncation mark bitmaps, continuation mark bitmaps, overlay
1321 arrow bitmaps, or clear the fringes if no bitmaps are required 1347 arrow bitmaps, or clear the fringes if no bitmaps are required
@@ -1351,10 +1377,25 @@ x_after_update_window_line (struct window *w, struct glyph_row *desired_row)
1351 height > 0)) 1377 height > 0))
1352 { 1378 {
1353 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 1379 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
1380 struct face *face = FACE_FROM_ID_OR_NULL (f, INTERNAL_BORDER_FACE_ID);
1354 1381
1355 block_input (); 1382 block_input ();
1356 x_clear_area (f, 0, y, width, height); 1383 if (face)
1357 x_clear_area (f, FRAME_PIXEL_WIDTH (f) - width, y, width, height); 1384 {
1385 unsigned long color = face->background;
1386 Display *display = FRAME_X_DISPLAY (f);
1387
1388 XSetForeground (display, f->output_data.x->normal_gc, color);
1389 x_fill_rectangle (f, f->output_data.x->normal_gc,
1390 0, y, width, height);
1391 x_fill_rectangle (f, f->output_data.x->normal_gc,
1392 FRAME_PIXEL_WIDTH (f) - width, y, width, height);
1393 }
1394 else
1395 {
1396 x_clear_area (f, 0, y, width, height);
1397 x_clear_area (f, FRAME_PIXEL_WIDTH (f) - width, y, width, height);
1398 }
1358 unblock_input (); 1399 unblock_input ();
1359 } 1400 }
1360 } 1401 }
@@ -3849,11 +3890,11 @@ x_clear_area (struct frame *f, int x, int y, int width, int height)
3849 cairo_fill (cr); 3890 cairo_fill (cr);
3850 x_end_cr_clip (f); 3891 x_end_cr_clip (f);
3851#else 3892#else
3852 if (FRAME_X_DOUBLE_BUFFERED_P (f)) 3893 if (FRAME_X_DOUBLE_BUFFERED_P (f))
3853 XFillRectangle (FRAME_X_DISPLAY (f), 3894 XFillRectangle (FRAME_X_DISPLAY (f),
3854 FRAME_X_DRAWABLE (f), 3895 FRAME_X_DRAWABLE (f),
3855 f->output_data.x->reverse_gc, 3896 f->output_data.x->reverse_gc,
3856 x, y, width, height); 3897 x, y, width, height);
3857 else 3898 else
3858 x_clear_area1 (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 3899 x_clear_area1 (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
3859 x, y, width, height, False); 3900 x, y, width, height, False);
@@ -5307,20 +5348,22 @@ xt_horizontal_action_hook (Widget widget, XtPointer client_data, String action_n
5307 x_send_scroll_bar_event (window_being_scrolled, 5348 x_send_scroll_bar_event (window_being_scrolled,
5308 scroll_bar_end_scroll, 0, 0, true); 5349 scroll_bar_end_scroll, 0, 0, true);
5309 w = XWINDOW (window_being_scrolled); 5350 w = XWINDOW (window_being_scrolled);
5310 bar = XSCROLL_BAR (w->horizontal_scroll_bar); 5351 if (!NILP (w->horizontal_scroll_bar))
5311
5312 if (bar->dragging != -1)
5313 { 5352 {
5314 bar->dragging = -1; 5353 bar = XSCROLL_BAR (w->horizontal_scroll_bar);
5315 /* The thumb size is incorrect while dragging: fix it. */ 5354 if (bar->dragging != -1)
5316 set_horizontal_scroll_bar (w); 5355 {
5317 } 5356 bar->dragging = -1;
5318 window_being_scrolled = Qnil; 5357 /* The thumb size is incorrect while dragging: fix it. */
5358 set_horizontal_scroll_bar (w);
5359 }
5360 window_being_scrolled = Qnil;
5319#if defined (USE_LUCID) 5361#if defined (USE_LUCID)
5320 bar->last_seen_part = scroll_bar_nowhere; 5362 bar->last_seen_part = scroll_bar_nowhere;
5321#endif 5363#endif
5322 /* Xt timeouts no longer needed. */ 5364 /* Xt timeouts no longer needed. */
5323 toolkit_scroll_bar_interaction = false; 5365 toolkit_scroll_bar_interaction = false;
5366 }
5324 } 5367 }
5325} 5368}
5326#endif /* not USE_GTK */ 5369#endif /* not USE_GTK */
@@ -7920,6 +7963,7 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7920 event->xexpose.x, event->xexpose.y, 7963 event->xexpose.x, event->xexpose.y,
7921 event->xexpose.width, event->xexpose.height, 7964 event->xexpose.width, event->xexpose.height,
7922 0); 7965 0);
7966 x_clear_under_internal_border (f);
7923#endif 7967#endif
7924 } 7968 }
7925 7969
@@ -7935,6 +7979,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7935#endif 7979#endif
7936 expose_frame (f, event->xexpose.x, event->xexpose.y, 7980 expose_frame (f, event->xexpose.x, event->xexpose.y,
7937 event->xexpose.width, event->xexpose.height); 7981 event->xexpose.width, event->xexpose.height);
7982#ifdef USE_GTK
7983 x_clear_under_internal_border (f);
7984#endif
7938 } 7985 }
7939 7986
7940 if (!FRAME_GARBAGED_P (f)) 7987 if (!FRAME_GARBAGED_P (f))
@@ -7983,7 +8030,10 @@ handle_one_xevent (struct x_display_info *dpyinfo,
7983 event->xgraphicsexpose.y, 8030 event->xgraphicsexpose.y,
7984 event->xgraphicsexpose.width, 8031 event->xgraphicsexpose.width,
7985 event->xgraphicsexpose.height); 8032 event->xgraphicsexpose.height);
7986 show_back_buffer (f); 8033#ifdef USE_GTK
8034 x_clear_under_internal_border (f);
8035#endif
8036 show_back_buffer (f);
7987 } 8037 }
7988#ifdef USE_X_TOOLKIT 8038#ifdef USE_X_TOOLKIT
7989 else 8039 else
diff --git a/src/xterm.h b/src/xterm.h
index a75257006fd..3122a2b208c 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -1102,6 +1102,7 @@ extern bool x_alloc_lighter_color_for_widget (Widget, Display *, Colormap,
1102extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *); 1102extern bool x_alloc_nearest_color (struct frame *, Colormap, XColor *);
1103extern void x_query_color (struct frame *f, XColor *); 1103extern void x_query_color (struct frame *f, XColor *);
1104extern void x_clear_area (struct frame *f, int, int, int, int); 1104extern void x_clear_area (struct frame *f, int, int, int, int);
1105extern void x_fill_rectangle (struct frame *f, GC, int, int, int, int);
1105#if !defined USE_X_TOOLKIT && !defined USE_GTK 1106#if !defined USE_X_TOOLKIT && !defined USE_GTK
1106extern void x_mouse_leave (struct x_display_info *); 1107extern void x_mouse_leave (struct x_display_info *);
1107#endif 1108#endif