commit a05bafffdcb88df74408a8402cafc9829407c1e5 (HEAD, refs/remotes/origin/master) Author: Tobias Bading Date: Wed Nov 27 16:51:26 2019 +0100 Fix incorrect GTK menus on HiDPI monitors with scaling factor > 1 This should fix Bug#31223, Bug#28106, Bug#23672 as well as Ubuntu bug https://bugs.launchpad.net/ubuntu/+source/emacs25/+bug/1695228 Also fixes the formerly unscaled Y value returned by frame-monitor-workarea (and display-monitor-attributes-list). For details on why some GTK menus were empty please see thread https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg01061.html * src/gtkutil.c (menubar_map_cb, xg_update_frame_menubar): Scale up req.height so that the menu bar's height is in device pixels as expected. (xg_event_is_for_menubar): Scale down rec.x and rec.y so that gtk_widget_intersect() works as intended. * src/xfns.c (Fx_display_monitor_attributes_list): Scale work.x and work.y up to be in device pixels. Copyright-paperwork-exempt: yes diff --git a/src/gtkutil.c b/src/gtkutil.c index cf5c31aa20..7e6db57c9d 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c @@ -3471,6 +3471,7 @@ menubar_map_cb (GtkWidget *w, gpointer user_data) GtkRequisition req; struct frame *f = user_data; gtk_widget_get_preferred_size (w, NULL, &req); + req.height *= xg_get_scale (f); if (FRAME_MENUBAR_HEIGHT (f) != req.height) { FRAME_MENUBAR_HEIGHT (f) = req.height; @@ -3502,7 +3503,7 @@ xg_update_frame_menubar (struct frame *f) g_signal_connect (x->menubar_widget, "map", G_CALLBACK (menubar_map_cb), f); gtk_widget_show_all (x->menubar_widget); gtk_widget_get_preferred_size (x->menubar_widget, NULL, &req); - + req.height *= xg_get_scale (f); if (FRAME_MENUBAR_HEIGHT (f) != req.height) { FRAME_MENUBAR_HEIGHT (f) = req.height; @@ -3568,8 +3569,9 @@ xg_event_is_for_menubar (struct frame *f, const XEvent *event) list = gtk_container_get_children (GTK_CONTAINER (x->menubar_widget)); if (! list) return 0; - rec.x = event->xbutton.x; - rec.y = event->xbutton.y; + int scale = xg_get_scale (f); + rec.x = event->xbutton.x / scale; + rec.y = event->xbutton.y / scale; rec.width = 1; rec.height = 1; diff --git a/src/xfns.c b/src/xfns.c index b1b40702c2..47aa19607f 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5093,6 +5093,8 @@ Internal use only, use `display-monitor-attributes-list' instead. */) #endif rec.width *= scale; rec.height *= scale; + work.x *= scale; + work.y *= scale; work.width *= scale; work.height *= scale; commit 16ce6dbef279bda70b4d60b4d2d0aff008bfa5f7 Author: YAMAMOTO Mitsuharu Date: Tue Dec 3 16:07:29 2019 +0900 Fix typo in populating otf_capability method for HarfBuzz * src/ftcrfont.c (syms_of_ftcrfont_for_pdumper) [HAVE_HARFBUZZ]: * src/ftfont.c (syms_of_ftfont_for_pdumper) [HAVE_HARFBUZZ]: * src/w32uniscribe.c (syms_of_w32uniscribe_for_pdumper) [HAVE_HARFBUZZ]: * src/xftfont.c (syms_of_xftfont_for_pdumper) [HAVE_HARFBUZZ]: Fix typos. diff --git a/src/ftcrfont.c b/src/ftcrfont.c index f0c7cbb8c8..9701296c15 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c @@ -620,7 +620,7 @@ syms_of_ftcrfont_for_pdumper (void) ftcrhbfont_driver.type = Qftcrhb; ftcrhbfont_driver.list = ftcrhbfont_list; ftcrhbfont_driver.match = ftcrhbfont_match; - ftcrhbfont_driver.otf_capability = hbfont_otf_capability, + ftcrhbfont_driver.otf_capability = hbfont_otf_capability; ftcrhbfont_driver.shape = hbfont_shape; ftcrhbfont_driver.combining_capability = hbfont_combining_capability; ftcrhbfont_driver.begin_hb_font = ftcrhbfont_begin_hb_font; diff --git a/src/ftfont.c b/src/ftfont.c index d649c991dd..b8199dc4ba 100644 --- a/src/ftfont.c +++ b/src/ftfont.c @@ -3120,7 +3120,7 @@ syms_of_ftfont_for_pdumper (void) #ifdef HAVE_HARFBUZZ fthbfont_driver = ftfont_driver; fthbfont_driver.type = Qfreetypehb; - fthbfont_driver.otf_capability = hbfont_otf_capability, + fthbfont_driver.otf_capability = hbfont_otf_capability; fthbfont_driver.shape = hbfont_shape; fthbfont_driver.combining_capability = hbfont_combining_capability; fthbfont_driver.begin_hb_font = fthbfont_begin_hb_font; diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c index 8fbbe7e4a9..3ef4e31b4f 100644 --- a/src/w32uniscribe.c +++ b/src/w32uniscribe.c @@ -1549,7 +1549,7 @@ syms_of_w32uniscribe_for_pdumper (void) harfbuzz_font_driver.list = w32hb_list; harfbuzz_font_driver.match = w32hb_match; harfbuzz_font_driver.encode_char = w32hb_encode_char; - harfbuzz_font_driver.otf_capability = hbfont_otf_capability, + harfbuzz_font_driver.otf_capability = hbfont_otf_capability; harfbuzz_font_driver.shape = hbfont_shape; harfbuzz_font_driver.get_variation_glyphs = w32hb_get_variation_glyphs; harfbuzz_font_driver.combining_capability = hbfont_combining_capability; diff --git a/src/xftfont.c b/src/xftfont.c index fa06d96736..7d84e0e0d6 100644 --- a/src/xftfont.c +++ b/src/xftfont.c @@ -702,7 +702,7 @@ syms_of_xftfont_for_pdumper (void) xfthbfont_driver.type = Qxfthb; xfthbfont_driver.list = xfthbfont_list; xfthbfont_driver.match = xfthbfont_match; - xfthbfont_driver.otf_capability = hbfont_otf_capability, + xfthbfont_driver.otf_capability = hbfont_otf_capability; xfthbfont_driver.shape = hbfont_shape; xfthbfont_driver.combining_capability = hbfont_combining_capability; xfthbfont_driver.begin_hb_font = xfthbfont_begin_hb_font; commit 9a911b4af50fdfef308aab8e2492392f0986580b Author: Juri Linkov Date: Tue Dec 3 01:40:12 2019 +0200 New functions window-state-buffers and tab-bar-get-buffer-tab (bug#38354) * lisp/window.el (window-state-buffers): New function. * lisp/tab-bar.el (tab-bar-get-buffer-tab): New function. * lisp/emacs-lisp/seq.el (seq-some): Add autoload cookie. * lisp/desktop.el (desktop-buffers-not-to-save-function): New variable. (desktop-save-buffer-p): Use it. diff --git a/lisp/desktop.el b/lisp/desktop.el index 498f769bd3..6f45278218 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -946,7 +946,9 @@ which means to truncate VAR's value to at most MAX-SIZE elements ")\n")))) ;; ---------------------------------------------------------------------------- -(defun desktop-save-buffer-p (filename bufname mode &rest _dummy) +(defvar desktop-buffers-not-to-save-function nil) + +(defun desktop-save-buffer-p (filename bufname mode &rest rest) "Return t if buffer should have its state saved in the desktop file. FILENAME is the visited file name, BUFNAME is the buffer name, and MODE is the major mode. @@ -970,6 +972,9 @@ MODE is the major mode. (and (null filename) (null dired-skip) ; bug#5755 (with-current-buffer bufname desktop-save-buffer))) + (or (null desktop-buffers-not-to-save-function) + (funcall desktop-buffers-not-to-save-function + filename bufname mode rest)) t))) ;; ---------------------------------------------------------------------------- diff --git a/lisp/emacs-lisp/seq.el b/lisp/emacs-lisp/seq.el index 2fd735617b..7e5e6f3b16 100644 --- a/lisp/emacs-lisp/seq.el +++ b/lisp/emacs-lisp/seq.el @@ -348,6 +348,7 @@ If SEQUENCE is empty, return INITIAL-VALUE and FUNCTION is not called." (throw 'seq--break nil))) t)) +;;;###autoload (cl-defgeneric seq-some (pred sequence) "Return non-nil if PRED is satisfied for at least one element of SEQUENCE. If so, return the first non-nil value returned by PRED." diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el index 5eb332884c..a36be13e37 100644 --- a/lisp/tab-bar.el +++ b/lisp/tab-bar.el @@ -1244,7 +1244,8 @@ in the selected frame." (kill-buffer (current-buffer)) ;; Delete the current window configuration of tab list ;; without storing it in the undo list of closed tabs - (let (tab-bar-closed-tabs) + (let ((tab-bar-mode t) ; avoid message about deleted tab + tab-bar-closed-tabs) (tab-bar-close-tab nil (1+ (tab-bar--tab-index to-tab)))))) (defun tab-bar-list-mouse-select (event) @@ -1284,6 +1285,47 @@ indirectly called by the latter." (tab-bar-rename-tab name)))) (tab-bar-new-tab)))) +(defun tab-bar-get-buffer-tab (buffer-or-name &optional all-frames) + "Return a tab whose window contains BUFFER-OR-NAME, or nil if none. +BUFFER-OR-NAME may be a buffer or a buffer name and defaults to +the current buffer. + +The optional argument ALL-FRAMES specifies the frames to consider: + +- t means consider all tabs on all existing frames. + +- `visible' means consider all tabs on all visible frames. + +- A frame means consider all tabs on that frame only. + +Any other value of ALL-FRAMES means consider all tabs on the +selected frame and no others." + (let ((buffer (if buffer-or-name + (get-buffer buffer-or-name) + (current-buffer)))) + (when (bufferp buffer) + (let ((frames (cond + ((eq all-frames t) (frame-list)) + ((eq all-frames 'visible) (visible-frame-list)) + ((framep all-frames) (list all-frames)) + (t (list (selected-frame)))))) + (seq-some (lambda (frame) + (with-selected-frame frame + (seq-some (lambda (tab) + (when (if (eq (car tab) 'current-tab) + (get-buffer-window buffer frame) + (let* ((state (cdr (assq 'ws tab))) + (buffers (when state + (window-state-buffers state)))) + (or + ;; non-writable window-state + (memq buffer buffers) + ;; writable window-state + (member (buffer-name buffer) buffers)))) + (append tab `((frame . ,frame))))) + (funcall tab-bar-tabs-function)))) + frames))))) + (defun switch-to-buffer-other-tab (buffer-or-name &optional norecord) "Switch to buffer BUFFER-OR-NAME in another tab. diff --git a/lisp/window.el b/lisp/window.el index c750ea71ea..a0280eba9b 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -6231,6 +6231,15 @@ windows can get as small as `window-safe-min-height' and (delete-window window)))) (window--check frame)))) +(defun window-state-buffers (state) + "Return all buffers saved to the given window state STATE." + (let ((buffer (cadr (assq 'buffer state))) + (buffers (mapcan (lambda (item) + (when (memq (car item) '(leaf vc hc)) + (window-state-buffers item))) + (if (consp (car state)) (list (cdr state)) (cdr state))))) + (if buffer (cons buffer buffers) buffers))) + (defun window-swap-states (&optional window-1 window-2 size) "Swap the states of live windows WINDOW-1 and WINDOW-2. WINDOW-1 must specify a live window and defaults to the selected commit 91762e49e10949a1f54a1bab78555e196e75d9ea Author: Juanma Barranquero Date: Mon Dec 2 19:19:13 2019 +0100 Don't save/restore font-backend in framesets (bug#38442) * lisp/frameset.el (frameset-persistent-filter-alist): Add :never filter for `font-backend'. diff --git a/lisp/frameset.el b/lisp/frameset.el index 9a7a75f5ef..dc59afd0c9 100644 --- a/lisp/frameset.el +++ b/lisp/frameset.el @@ -456,6 +456,9 @@ DO NOT MODIFY. See `frameset-filter-alist' for a full description.") (client . :never) (delete-before . :never) (font . frameset-filter-font-param) + ;; Don't save font-backend because we cannot guarantee the new + ;; session will support the saved backend anyway. (Bug#38442) + (font-backend . :never) (foreground-color . frameset-filter-sanitize-color) (frameset--text-pixel-height . :save) (frameset--text-pixel-width . :save)