commit 0adb2d507cdf386f2cc8b4fb6c5bfc953fec42e8 (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Sun Mar 6 07:13:07 2022 +0000 Implement frame cascading on Haiku * haikufns.c (haiku_create_frame): Cascade frame position with the focused frame if position is not user or programmer specified. diff --git a/src/haikufns.c b/src/haikufns.c index 545edb27ae..24e4613e3e 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -565,7 +565,7 @@ unwind_popup (void) static Lisp_Object haiku_create_frame (Lisp_Object parms) { - struct frame *f; + struct frame *f, *cascade_target; Lisp_Object frame, tem; Lisp_Object name; bool minibuffer_only = false; @@ -575,6 +575,13 @@ haiku_create_frame (Lisp_Object parms) struct haiku_display_info *dpyinfo = NULL; struct kboard *kb; + if (x_display_list->focused_frame) + cascade_target = x_display_list->focused_frame; + else if (x_display_list->focus_event_frame) + cascade_target = x_display_list->focus_event_frame; + else + cascade_target = NULL; + parms = Fcopy_alist (parms); Vx_resource_name = Vinvocation_name; @@ -888,6 +895,9 @@ haiku_create_frame (Lisp_Object parms) block_input (); if (window_prompting & (USPosition | PPosition)) haiku_set_offset (f, f->left_pos, f->top_pos, 1); + else if (cascade_target) + haiku_set_offset (f, cascade_target->left_pos + 15, + cascade_target->top_pos + 15, 1); else BWindow_center_on_screen (FRAME_HAIKU_WINDOW (f)); unblock_input (); commit 200627c255c4bf3f050f7f75fb3e4e100fe97bfa Merge: e09bbfc37d 0090318c61 Author: Stefan Kangas Date: Sun Mar 6 06:32:23 2022 +0100 Merge from origin/emacs-28 0090318c61 * lib-src/seccomp-filter.c (main): Use faccessat2 only if ... 3bb01a499b Fix regression in derived-mode-init-mode-variables commit e09bbfc37d81d58af3412ae1b56dc2e620218653 Author: Po Lu Date: Sun Mar 6 10:43:25 2022 +0800 Implement "window cascading" on NS * src/nsfns.m (Fx_create_frame): Cascade new frame position if size hint flags are not USPosition or PPosition. diff --git a/src/nsfns.m b/src/nsfns.m index 1900616b9d..6256bd220d 100644 --- a/src/nsfns.m +++ b/src/nsfns.m @@ -1112,6 +1112,7 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. Lisp_Object parent, parent_frame; struct kboard *kb; static int desc_ctr = 1; + NSWindow *main_window = [NSApp mainWindow]; /* gui_display_get_arg modifies parms. */ parms = Fcopy_alist (parms); @@ -1483,8 +1484,27 @@ Turn the input menu (an NSMenu) into a lisp list for tracking on lisp side. if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) fset_param_alist (f, Fcons (XCAR (tem), f->param_alist)); - if (window_prompting & USPosition) + /* This cascading behavior (which is the job of the window manager + on X-based systems) is something NS applications are expected to + implement themselves. At least one person tells me he used + Carbon Emacs solely for this behavior. */ + if (window_prompting & (USPosition | PPosition) || FRAME_PARENT_FRAME (f)) ns_set_offset (f, f->left_pos, f->top_pos, 1); + else + { + NSWindow *frame_window = [FRAME_NS_VIEW (f) window]; + NSPoint top_left; + + if (main_window) + { + top_left = NSMakePoint (NSMinX ([main_window frame]), + NSMaxY ([main_window frame])); + top_left = [frame_window cascadeTopLeftFromPoint: top_left]; + [frame_window cascadeTopLeftFromPoint: top_left]; + } + else + [main_window center]; + } /* Make sure windows on this frame appear in calls to next-window and similar functions. */ commit db2cb522e154ce97b7a780572d2cb99d82d291ca Author: Po Lu Date: Sun Mar 6 10:02:03 2022 +0800 Reduce non-toolkit scroll bar flicker * src/xterm.c (x_scroll_bar_create): Initialize double buffer for scroll bar. (x_scroll_bar_set_handle) (x_scroll_bar_remove, x_scroll_bar_expose): Draw to back buffer instead. (x_scroll_bar_end_update): New function. (x_scroll_bar_clear): Fill the scroll bar with the background instead when double buffered. * src/xterm.h (struct scroll_bar): New field `x_drawable'. diff --git a/src/xterm.c b/src/xterm.c index 89feece10e..1d68d4e939 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -765,6 +765,10 @@ static void x_initialize (void); static bool x_get_current_wm_state (struct frame *, Window, int *, bool *, bool *); static void x_update_opaque_region (struct frame *, XEvent *); +#if !defined USE_TOOLKIT_SCROLL_BARS && defined HAVE_XDBE +static void x_scroll_bar_end_update (struct x_display_info *, struct scroll_bar *); +#endif + /* Flush display of frame F. */ static void @@ -8547,6 +8551,9 @@ x_scroll_bar_create (struct window *w, int top, int left, XSetWindowAttributes a; unsigned long mask; Window window; +#ifdef HAVE_XDBE + Drawable drawable; +#endif a.background_pixel = f->output_data.x->scroll_bar_background_pixel; if (a.background_pixel == -1) @@ -8575,6 +8582,21 @@ x_scroll_bar_create (struct window *w, int top, int left, CopyFromParent, /* Attributes. */ mask, &a); +#ifdef HAVE_XDBE + if (FRAME_DISPLAY_INFO (f)->supports_xdbe) + { + x_catch_errors (FRAME_X_DISPLAY (f)); + drawable = XdbeAllocateBackBufferName (FRAME_X_DISPLAY (f), + window, XdbeCopied); + if (x_had_errors_p (FRAME_X_DISPLAY (f))) + drawable = window; + else + XSetWindowBackgroundPixmap (FRAME_X_DISPLAY (f), window, None); + x_uncatch_errors_after_check (); + } + else + drawable = window; +#endif #ifdef HAVE_XINPUT2 /* Ask for input extension button and motion events. This lets us @@ -8599,7 +8621,11 @@ x_scroll_bar_create (struct window *w, int top, int left, XISelectEvents (FRAME_X_DISPLAY (f), window, &mask, 1); } #endif + bar->x_window = window; +#ifdef HAVE_XDBE + bar->x_drawable = drawable; +#endif } #endif /* not USE_TOOLKIT_SCROLL_BARS */ @@ -8673,7 +8699,11 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, bool rebuild) { bool dragging = bar->dragging != -1; +#ifndef HAVE_XDBE Window w = bar->x_window; +#else + Drawable w = bar->x_drawable; +#endif struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); GC gc = f->output_data.x->normal_gc; @@ -8723,10 +8753,22 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, /* Draw the empty space above the handle. Note that we can't clear zero-height areas; that means "clear to end of window." */ if ((inside_width > 0) && (start > 0)) - x_clear_area1 (FRAME_X_DISPLAY (f), w, - VERTICAL_SCROLL_BAR_LEFT_BORDER, - VERTICAL_SCROLL_BAR_TOP_BORDER, - inside_width, start, False); + { + if (f->output_data.x->scroll_bar_background_pixel != -1) + XSetForeground (FRAME_X_DISPLAY (f), gc, + f->output_data.x->scroll_bar_background_pixel); + else + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_BACKGROUND_PIXEL (f)); + + XFillRectangle (FRAME_X_DISPLAY (f), w, gc, + VERTICAL_SCROLL_BAR_LEFT_BORDER, + VERTICAL_SCROLL_BAR_TOP_BORDER, + inside_width, start); + + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_FOREGROUND_PIXEL (f)); + } /* Change to proper foreground color if one is specified. */ if (f->output_data.x->scroll_bar_foreground_pixel != -1) @@ -8740,20 +8782,38 @@ x_scroll_bar_set_handle (struct scroll_bar *bar, int start, int end, VERTICAL_SCROLL_BAR_TOP_BORDER + start, inside_width, end - start); - /* Restore the foreground color of the GC if we changed it above. */ - if (f->output_data.x->scroll_bar_foreground_pixel != -1) - XSetForeground (FRAME_X_DISPLAY (f), gc, - FRAME_FOREGROUND_PIXEL (f)); /* Draw the empty space below the handle. Note that we can't clear zero-height areas; that means "clear to end of window." */ if ((inside_width > 0) && (end < inside_height)) - x_clear_area1 (FRAME_X_DISPLAY (f), w, - VERTICAL_SCROLL_BAR_LEFT_BORDER, - VERTICAL_SCROLL_BAR_TOP_BORDER + end, - inside_width, inside_height - end, False); + { + if (f->output_data.x->scroll_bar_background_pixel != -1) + XSetForeground (FRAME_X_DISPLAY (f), gc, + f->output_data.x->scroll_bar_background_pixel); + else + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_BACKGROUND_PIXEL (f)); + + XFillRectangle (FRAME_X_DISPLAY (f), w, gc, + VERTICAL_SCROLL_BAR_LEFT_BORDER, + VERTICAL_SCROLL_BAR_TOP_BORDER + end, + inside_width, inside_height - end); + + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_FOREGROUND_PIXEL (f)); + } + + /* Restore the foreground color of the GC if we changed it above. */ + if (f->output_data.x->scroll_bar_foreground_pixel != -1) + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_FOREGROUND_PIXEL (f)); } +#ifdef HAVE_XDBE + if (!rebuild) + x_scroll_bar_end_update (FRAME_DISPLAY_INFO (f), bar); +#endif + unblock_input (); } @@ -8775,6 +8835,11 @@ x_scroll_bar_remove (struct scroll_bar *bar) XtDestroyWidget (SCROLL_BAR_X_WIDGET (FRAME_X_DISPLAY (f), bar)); #endif /* not USE_GTK */ #else +#ifdef HAVE_XDBE + if (bar->x_window != bar->x_drawable) + XdbeDeallocateBackBufferName (FRAME_X_DISPLAY (f), + bar->x_drawable); +#endif XDestroyWindow (FRAME_X_DISPLAY (f), bar->x_window); #endif @@ -9195,12 +9260,39 @@ XTjudge_scroll_bars (struct frame *f) static void x_scroll_bar_expose (struct scroll_bar *bar, const XEvent *event) { +#ifndef HAVE_XDBE Window w = bar->x_window; +#else + Drawable w = bar->x_drawable; +#endif + struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window))); GC gc = f->output_data.x->normal_gc; block_input (); +#ifdef HAVE_XDBE + if (w != bar->x_window) + { + if (f->output_data.x->scroll_bar_background_pixel != -1) + XSetForeground (FRAME_X_DISPLAY (f), gc, + f->output_data.x->scroll_bar_background_pixel); + else + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_BACKGROUND_PIXEL (f)); + + XFillRectangle (FRAME_X_DISPLAY (f), + bar->x_drawable, + gc, event->xexpose.x, + event->xexpose.y, + event->xexpose.width, + event->xexpose.height); + + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_FOREGROUND_PIXEL (f)); + } +#endif + x_scroll_bar_set_handle (bar, bar->start, bar->end, true); /* Switch to scroll bar foreground color. */ @@ -9221,6 +9313,10 @@ x_scroll_bar_expose (struct scroll_bar *bar, const XEvent *event) XSetForeground (FRAME_X_DISPLAY (f), gc, FRAME_FOREGROUND_PIXEL (f)); +#ifdef HAVE_XDBE + x_scroll_bar_end_update (FRAME_DISPLAY_INFO (f), bar); +#endif + unblock_input (); } @@ -9352,6 +9448,24 @@ x_scroll_bar_note_movement (struct scroll_bar *bar, } } +#ifdef HAVE_XDBE +static void +x_scroll_bar_end_update (struct x_display_info *dpyinfo, + struct scroll_bar *bar) +{ + XdbeSwapInfo swap_info; + + /* This means the scroll bar is double-buffered. */ + if (bar->x_drawable != bar->x_window) + { + memset (&swap_info, 0, sizeof swap_info); + swap_info.swap_window = bar->x_window; + swap_info.swap_action = XdbeCopied; + XdbeSwapBuffers (dpyinfo->display, &swap_info, 1); + } +} +#endif + #endif /* !USE_TOOLKIT_SCROLL_BARS */ /* Return information to the user about the current position of the mouse @@ -9502,6 +9616,16 @@ x_scroll_bar_clear (struct frame *f) { #ifndef USE_TOOLKIT_SCROLL_BARS Lisp_Object bar; +#ifdef HAVE_XDBE + GC gc = f->output_data.x->normal_gc; + + if (f->output_data.x->scroll_bar_background_pixel != -1) + XSetForeground (FRAME_X_DISPLAY (f), gc, + f->output_data.x->scroll_bar_background_pixel); + else + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_BACKGROUND_PIXEL (f)); +#endif /* We can have scroll bars even if this is 0, if we just turned off scroll bar mode. @@ -9509,9 +9633,23 @@ x_scroll_bar_clear (struct frame *f) if (FRAME_HAS_VERTICAL_SCROLL_BARS (f)) for (bar = FRAME_SCROLL_BARS (f); VECTORP (bar); bar = XSCROLL_BAR (bar)->next) - XClearArea (FRAME_X_DISPLAY (f), - XSCROLL_BAR (bar)->x_window, - 0, 0, 0, 0, True); + { +#ifndef HAVE_XDBE + XClearArea (FRAME_X_DISPLAY (f), + XSCROLL_BAR (bar)->x_window, + 0, 0, 0, 0, True); +#else + XFillRectangle (FRAME_X_DISPLAY (f), + XSCROLL_BAR (bar)->x_drawable, + gc, 0, 0, XSCROLL_BAR (bar)->width, + XSCROLL_BAR (bar)->height); +#endif + } + +#ifdef HAVE_XDBE + XSetForeground (FRAME_X_DISPLAY (f), gc, + FRAME_FOREGROUND_PIXEL (f)); +#endif #endif /* not USE_TOOLKIT_SCROLL_BARS */ } diff --git a/src/xterm.h b/src/xterm.h index 7f45e2f172..dd510ae257 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -1081,6 +1081,11 @@ struct scroll_bar /* The X window representing this scroll bar. */ Window x_window; +#if defined HAVE_XDBE && !defined USE_TOOLKIT_SCROLL_BARS + /* The X drawable representing this scroll bar. */ + Drawable x_drawable; +#endif + /* The position and size of the scroll bar in pixels, relative to the frame. */ int top, left, width, height; commit c9667e9b60fe0044ea4d5f000973a87a0c584033 Author: Po Lu Date: Sun Mar 6 08:56:02 2022 +0800 Fix reporting of menu bar wheel events on no toolkit builds * src/xterm.c (x_toolkit_position): Handle menu bar position on no-toolkit builds. (x_create_terminal): Always add `toolkit_position_hook'. diff --git a/src/xterm.c b/src/xterm.c index 5f8e804c62..89feece10e 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -856,7 +856,6 @@ record_event (char *locus, int type) #endif -#if defined USE_X_TOOLKIT || USE_GTK static void x_toolkit_position (struct frame *f, int x, int y, bool *menu_bar_p, bool *tool_bar_p) @@ -884,12 +883,15 @@ x_toolkit_position (struct frame *f, int x, int y, *tool_bar_p = gtk_widget_intersect (FRAME_X_OUTPUT (f)->toolbar_widget, &test_rect, NULL); } -#else +#elif defined USE_X_TOOLKIT *menu_bar_p = (x > 0 && x < FRAME_PIXEL_WIDTH (f) && (y < 0 && y >= -FRAME_MENUBAR_HEIGHT (f))); +#else + *menu_bar_p = (WINDOWP (f->menu_bar_window) + && (x > 0 && x < FRAME_PIXEL_WIDTH (f) + && (y > 0 && y < FRAME_MENU_BAR_HEIGHT (f)))); #endif } -#endif static void x_update_opaque_region (struct frame *f, XEvent *configure) @@ -17985,9 +17987,7 @@ x_create_terminal (struct x_display_info *dpyinfo) terminal->free_pixmap = x_free_pixmap; terminal->delete_frame_hook = x_destroy_window; terminal->delete_terminal_hook = x_delete_terminal; -#if defined USE_X_TOOLKIT || defined USE_GTK terminal->toolkit_position_hook = x_toolkit_position; -#endif /* Other hooks are NULL by default. */ return terminal; commit 98d2dc6522114e4044077801f11a3ed8de9c1147 Author: Robert Pluim Date: Sat Mar 5 20:00:09 2022 +0100 Use pselect instead of select in nsterm.m * src/nsterm.m ([EmacsApp fdhandler:]): Use pselect instead of the single remaining use of select (because we try to avoid using select directly) (bug#54245). diff --git a/src/nsterm.m b/src/nsterm.m index 45561b88b5..4adb13706d 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5838,7 +5838,7 @@ - (void)fd_handler:(id)unused fd_set fds; FD_ZERO (&fds); FD_SET (selfds[0], &fds); - result = select (selfds[0]+1, &fds, NULL, NULL, NULL); + result = pselect (selfds[0]+1, &fds, NULL, NULL, NULL, NULL); if (result > 0 && read (selfds[0], &c, 1) == 1 && c == 'g') waiting = 0; } commit d70ad7229aabec4e2fadf2f655d23de7bf60d1b9 Author: Lars Ingebrigtsen Date: Sat Mar 5 19:06:20 2022 +0100 Fix emacs-module-test after recent changes * test/Makefile.in ($(test_module)): Include libgnu.a in the module test (because the module uses functions from gnulib) (bug#32452). diff --git a/test/Makefile.in b/test/Makefile.in index 708c4b2fb0..79d3dcf92f 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -285,7 +285,7 @@ $(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h -o $@ $< $(LIBGMP) \ $(and $(GMP_H),$(srcdir)/../lib/mini-gmp-gnulib.c) \ $(FREE_SOURCE_$(REPLACE_FREE)) \ - $(srcdir)/../lib/timespec.c $(srcdir)/../lib/gettime.c + ../lib/libgnu.a endif src/emacs-tests.log: ../lib-src/seccomp-filter.c commit 0090318c6113828688e84fc50a13a8d9c5f71c55 (refs/remotes/origin/emacs-28) Author: Andreas Schwab Date: Sat Mar 5 13:44:08 2022 +0100 * lib-src/seccomp-filter.c (main): Use faccessat2 only if defined. diff --git a/lib-src/seccomp-filter.c b/lib-src/seccomp-filter.c index d368cbb46c..b515851010 100644 --- a/lib-src/seccomp-filter.c +++ b/lib-src/seccomp-filter.c @@ -240,7 +240,9 @@ main (int argc, char **argv) should be further restricted using mount namespaces. */ RULE (SCMP_ACT_ALLOW, SCMP_SYS (access)); RULE (SCMP_ACT_ALLOW, SCMP_SYS (faccessat)); +#ifdef __NR_faccessat2 RULE (SCMP_ACT_ALLOW, SCMP_SYS (faccessat2)); +#endif RULE (SCMP_ACT_ALLOW, SCMP_SYS (stat)); RULE (SCMP_ACT_ALLOW, SCMP_SYS (stat64)); RULE (SCMP_ACT_ALLOW, SCMP_SYS (lstat)); commit 1e1d2f18c6d797f7e49a71f998a82cb255b8bb58 Author: Po Lu Date: Sat Mar 5 10:20:04 2022 +0000 Obey decorator-specified width and height of tooltip frames on Haiku * src/haiku_support.cc (BWindow_dimensions): New functions. * src/haiku_support.h: Update prototypes. * src/haikufns.c (Fx_show_tip): Use actual dimensions, because the decorator might specify a minimum width and height for the tooltip frame. * src/haikuterm.c (haiku_update_size_hints): Ignore tooltip frames. diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 20d04163fc..057464c908 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -2080,6 +2080,16 @@ BWindow_set_offset (void *window, int x, int y) wn->MoveTo (x, y); } +void +BWindow_dimensions (void *window, int *width, int *height) +{ + BWindow *w = (BWindow *) window; + BRect frame = w->Frame (); + + *width = BE_RECT_WIDTH (frame); + *height = BE_RECT_HEIGHT (frame); +} + /* Iconify WINDOW. */ void BWindow_iconify (void *window) diff --git a/src/haiku_support.h b/src/haiku_support.h index 9d13cae47c..04079edbbc 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -939,6 +939,9 @@ extern "C" extern haiku_font_family_or_style * be_list_font_families (size_t *length); + extern void + BWindow_dimensions (void *window, int *width, int *height); + #ifdef __cplusplus extern void * find_appropriate_view_for_draw (void *vw); diff --git a/src/haikufns.c b/src/haikufns.c index ff5082030f..545edb27ae 100644 --- a/src/haikufns.c +++ b/src/haikufns.c @@ -2201,6 +2201,9 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, block_input (); void *wnd = FRAME_HAIKU_WINDOW (tip_f); BWindow_resize (wnd, width, height); + /* The window decorator might cause the actual width and height to + be larger than WIDTH and HEIGHT, so use the actual sizes. */ + BWindow_dimensions (wnd, &width, &height); BView_resize_to (FRAME_HAIKU_VIEW (tip_f), width, height); BView_set_view_cursor (FRAME_HAIKU_VIEW (tip_f), FRAME_OUTPUT_DATA (f)->current_cursor); diff --git a/src/haikuterm.c b/src/haikuterm.c index ac087e3bec..c44b350c58 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -140,6 +140,9 @@ haiku_update_size_hints (struct frame *f) int base_width, base_height; eassert (FRAME_HAIKU_P (f) && FRAME_HAIKU_WINDOW (f)); + if (f->tooltip) + return; + base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0); base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0); commit 3bb01a499bb828a8705d5f1772732ef5de18254c Author: Lars Ingebrigtsen Date: Fri Mar 4 16:19:42 2022 +0100 Fix regression in derived-mode-init-mode-variables * lisp/emacs-lisp/derived.el (derived-mode-init-mode-variables): Fix regression caused by lexical-binding derived.el (bug#54240). diff --git a/lisp/emacs-lisp/derived.el b/lisp/emacs-lisp/derived.el index dd386f14b7..72f49bf3ba 100644 --- a/lisp/emacs-lisp/derived.el +++ b/lisp/emacs-lisp/derived.el @@ -409,7 +409,7 @@ the first time the mode is used." t (eval `(defvar ,(derived-mode-abbrev-table-name mode) (progn - (define-abbrev-table (derived-mode-abbrev-table-name mode) nil) + (define-abbrev-table (derived-mode-abbrev-table-name ',mode) nil) (make-abbrev-table)) ,(format "Abbrev table for %s." mode)))))