commit b1d0d8e1f77eb3882a490aea6e31b7ec9ae642c1 (HEAD, refs/remotes/origin/master) Author: Po Lu Date: Fri Mar 11 13:59:42 2022 +0800 Allow C-mouse-2 to split windows on XInput 2 builds * src/xterm.c (handle_one_xevent): Use x_scroll_bar_handle_click if ControlMask is set. diff --git a/src/xterm.c b/src/xterm.c index 5b1e102379..2adf70b829 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -12660,17 +12660,25 @@ handle_one_xevent (struct x_display_info *dpyinfo, xembed_send_message (f, xev->time, XEMBED_REQUEST_FOCUS, 0, 0, 0); } -#ifndef USE_TOOLKIT_SCROLL_BARS else { struct scroll_bar *bar = x_window_to_scroll_bar (dpyinfo->display, xev->event, 2); +#ifndef USE_TOOLKIT_SCROLL_BARS if (bar) x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev.ie); - } +#else + /* Make the "Ctrl-Mouse-2 splits window" work for toolkit + scroll bars. */ + if (bar && xev->mods.effective & ControlMask) + { + x_scroll_bar_handle_click (bar, (XEvent *) &bv, &inev.ie); + *finish = X_EVENT_DROP; + } #endif + } if (xev->evtype == XI_ButtonPress) { commit 170cae0e9080697e1efa1678bc1504890bcf4a6e Author: Po Lu Date: Fri Mar 11 01:33:24 2022 +0000 Fix scroll bar portion on Haiku scroll bars * src/haiku_support.cc (EmacsScrollBar): Set steps to appropriate value. (ValueChanged): Test new value against old value before sending value event. (MessageReceived): Handle portion and range. (BView_scroll_bar_update): New argument for portion. * src/haiku_support.h: Update prototypes. * src/haikuterm.c (haiku_set_scroll_bar_thumb): (haiku_set_horizontal_scroll_bar_thumb): New functions. (haiku_set_horizontal_scroll_bar): (haiku_set_vertical_scroll_bar): Use those functions to set scroll bar values. (haiku_read_socket): Handle new meanings of scroll bar values. * src/haikuterm.h (struct scroll_bar): diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 2f2adfd8f8..6f5196dc1c 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1571,16 +1571,26 @@ class EmacsScrollBar : public BScrollBar vw->SetResizingMode (B_FOLLOW_NONE); horizontal = horizontal_p; get_scroll_bar_info (&info); + SetSteps (5000, 10000); } void MessageReceived (BMessage *msg) { + int32 portion, range; + if (msg->what == SCROLL_BAR_UPDATE) { old_value = msg->GetInt32 ("emacs:units", 0); - this->SetRange (0, msg->GetInt32 ("emacs:range", 0)); - this->SetValue (msg->GetInt32 ("emacs:units", 0)); + portion = msg->GetInt32 ("emacs:portion", 0); + range = msg->GetInt32 ("emacs:range", 0); + + if (!msg->GetBool ("emacs:dragging", false)) + { + this->SetRange (0, range); + this->SetValue (old_value); + this->SetProportion ((float) portion / range); + } } BScrollBar::MessageReceived (msg); @@ -1612,11 +1622,15 @@ class EmacsScrollBar : public BScrollBar return; } - rq.scroll_bar = this; - rq.window = Window (); - rq.position = new_value; + if (new_value != old_value) + { + rq.scroll_bar = this; + rq.window = Window (); + rq.position = new_value; + old_value = new_value; - haiku_write (SCROLL_BAR_VALUE_EVENT, &rq); + haiku_write (SCROLL_BAR_VALUE_EVENT, &rq); + } } BRegion @@ -2269,13 +2283,16 @@ BView_move_frame (void *view, int x, int y, int x1, int y1) } void -BView_scroll_bar_update (void *sb, int portion, int whole, int position) +BView_scroll_bar_update (void *sb, int portion, int whole, int position, + bool dragging) { BScrollBar *bar = (BScrollBar *) sb; BMessage msg = BMessage (SCROLL_BAR_UPDATE); BMessenger mr = BMessenger (bar); msg.AddInt32 ("emacs:range", whole); msg.AddInt32 ("emacs:units", position); + msg.AddInt32 ("emacs:portion", portion); + msg.AddBool ("emacs:dragging", dragging); mr.SendMessage (&msg); } diff --git a/src/haiku_support.h b/src/haiku_support.h index fb86372c4f..e7c55d4d75 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h @@ -628,7 +628,8 @@ extern "C" BView_move_frame (void *view, int x, int y, int x1, int y1); extern void - BView_scroll_bar_update (void *sb, int portion, int whole, int position); + BView_scroll_bar_update (void *sb, int portion, int whole, int position, + bool dragging); extern int BScrollBar_default_size (int horizontal_p); diff --git a/src/haikuterm.c b/src/haikuterm.c index d3168129ce..b100952f11 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -40,6 +40,9 @@ along with GNU Emacs. If not, see . */ #include #endif +/* Minimum and maximum values used for Haiku scroll bars. */ +#define BE_SB_MAX 10000000 + struct haiku_display_info *x_display_list = NULL; extern frame_parm_handler haiku_frame_parm_handlers[]; @@ -428,6 +431,78 @@ haiku_mouse_or_wdesc_frame (void *window) } } +/* Set the thumb size and position of scroll bar BAR. We are + currently displaying PORTION out of a whole WHOLE, and our position + POSITION. */ + +static void +haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, + int position, int whole) +{ + void *scroll_bar = bar->scroll_bar; + float top, shown; + int size, value; + + if (scroll_bar_adjust_thumb_portion_p) + { + /* We use an estimate of 30 chars per line rather than the real + `portion' value. This has the disadvantage that the thumb + size is not very representative, but it makes our life a lot + easier. Otherwise, we have to constantly adjust the thumb + size, which we can't always do quickly enough: while + dragging, the size of the thumb might prevent the user from + dragging the thumb all the way to the end. */ + portion = WINDOW_TOTAL_LINES (XWINDOW (bar->window)) * 30; + /* When the thumb is at the bottom, position == whole. So we + need to increase `whole' to make space for the thumb. */ + whole += portion; + } + + if (whole <= 0) + top = 0, shown = 1; + else + { + top = (float) position / whole; + shown = (float) portion / whole; + } + + /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX + is the scroll bar's maximum and MIN is the scroll bar's minimum + value. */ + size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX); + + /* Position. Must be in the range [MIN .. MAX - SLIDER_SIZE]. */ + value = top * BE_SB_MAX; + value = min (value, BE_SB_MAX - size); + + if (!bar->dragging) + bar->page_size = size; + + BView_scroll_bar_update (scroll_bar, size, BE_SB_MAX, value, + bar->dragging); +} + +static void +haiku_set_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, + int position, int whole) +{ + void *scroll_bar = bar->scroll_bar; + float shown, top; + int size, value; + + shown = (float) portion / whole; + top = (float) position / (whole - portion); + + size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX); + value = clip_to_bounds (0, top * (BE_SB_MAX - size), BE_SB_MAX - size); + + if (!bar->dragging) + bar->page_size = size; + + BView_scroll_bar_update (scroll_bar, shown, BE_SB_MAX, value, + bar->dragging); +} + static struct scroll_bar * haiku_scroll_bar_from_widget (void *scroll_bar, void *window) { @@ -2211,7 +2286,6 @@ haiku_set_horizontal_scroll_bar (struct window *w, int portion, int whole, int p if (NILP (w->horizontal_scroll_bar)) { bar = haiku_scroll_bar_create (w, left, top, width, height, true); - BView_scroll_bar_update (bar->scroll_bar, portion, whole, position); bar->update = position; bar->position = position; bar->total = whole; @@ -2234,13 +2308,9 @@ haiku_set_horizontal_scroll_bar (struct window *w, int portion, int whole, int p bar->width = width; bar->height = height; } - - if (!bar->dragging) - { - BView_scroll_bar_update (bar->scroll_bar, portion, whole, position); - BView_invalidate (bar->scroll_bar); - } } + + haiku_set_horizontal_scroll_bar_thumb (bar, portion, position, whole); bar->position = position; bar->total = whole; XSETVECTOR (barobj, bar); @@ -2271,7 +2341,6 @@ haiku_set_vertical_scroll_bar (struct window *w, if (NILP (w->vertical_scroll_bar)) { bar = haiku_scroll_bar_create (w, left, top, width, height, false); - BView_scroll_bar_update (bar->scroll_bar, portion, whole, position); bar->position = position; bar->total = whole; } @@ -2293,15 +2362,9 @@ haiku_set_vertical_scroll_bar (struct window *w, bar->width = width; bar->height = height; } - - if (!bar->dragging) - { - BView_scroll_bar_update (bar->scroll_bar, portion, whole, position); - bar->update = position; - BView_invalidate (bar->scroll_bar); - } } + haiku_set_scroll_bar_thumb (bar, portion, position, whole); bar->position = position; bar->total = whole; @@ -3191,6 +3254,7 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) struct haiku_scroll_bar_value_event *b = buf; struct scroll_bar *bar = haiku_scroll_bar_from_widget (b->scroll_bar, b->window); + int portion, whole; if (!bar) continue; @@ -3205,13 +3269,29 @@ haiku_read_socket (struct terminal *terminal, struct input_event *hold_quit) if (bar->position != b->position) { - inev.kind = bar->horizontal ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT : - SCROLL_BAR_CLICK_EVENT; + inev.kind = (bar->horizontal + ? HORIZONTAL_SCROLL_BAR_CLICK_EVENT : + SCROLL_BAR_CLICK_EVENT); inev.part = bar->horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; - XSETINT (inev.x, b->position); - XSETINT (inev.y, bar->total); + if (bar->horizontal) + { + portion = bar->total * ((float) b->position + / BE_SB_MAX); + whole = (bar->total + * ((float) (BE_SB_MAX - bar->page_size) + / BE_SB_MAX)); + portion = min (portion, whole); + } + else + { + whole = BE_SB_MAX - bar->page_size; + portion = min (b->position, whole); + } + + XSETINT (inev.x, portion); + XSETINT (inev.y, whole); XSETWINDOW (inev.frame_or_window, w); } break; diff --git a/src/haikuterm.h b/src/haikuterm.h index a2520858f5..64fd0ec2b7 100644 --- a/src/haikuterm.h +++ b/src/haikuterm.h @@ -213,6 +213,8 @@ struct scroll_bar /* True if the scroll bar is horizontal. */ bool horizontal; + + int page_size; }; #define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) commit 22dde4e621fb49b9f05d560aee22332ad60bf485 Author: Alan Third Date: Thu Mar 10 21:23:55 2022 +0000 Fix NS toolbar identifier (bug#54326) * src/nsterm.m ([EmacsWindow createToolbar:]): Set the identifier to something that will always be unique to that frame. diff --git a/src/nsterm.m b/src/nsterm.m index 4adb13706d..fd56094c28 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -8390,7 +8390,7 @@ - (void)createToolbar: (struct frame *)f EmacsToolbar *toolbar = [[EmacsToolbar alloc] initForView:view - withIdentifier:[NSString stringWithLispString:f->name]]; + withIdentifier:[NSString stringWithFormat:@"%p", f]]; [self setToolbar:toolbar]; update_frame_tool_bar_1 (f, toolbar); commit c6e079ae15002268d90869a43f66d962175e4cdb Author: Michael Albinus Date: Thu Mar 10 12:31:22 2022 +0100 Support remote home directories via connection property * doc/misc/tramp.texi (Home directories): New section. (Top, Usage): Add it to the menue. (Predefined connection information): Mention "~". (Multi-hops, File name syntax): Fix typos. * lisp/net/tramp.el (tramp-handle-expand-file-name): Check for remote home directory. (Bug#53847) diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 20e6ee0bef..62bcf9c73b 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -157,6 +157,7 @@ Using @value{tramp} @end ifset * File name completion:: File name completion. * Ad-hoc multi-hops:: Declaring multiple hops in the file name. +* Home directories:: Expanding @file{~} to home directory. * Remote processes:: Integration with other Emacs packages. * Cleanup remote connections:: Cleanup remote connections. * Renaming remote files:: Renaming remote files. @@ -1663,7 +1664,7 @@ local one, first connect via @command{ssh}, and then apply (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "@trampfn{ssh,%h,}")) (add-to-list 'tramp-default-proxies-alist - '((regexp-quote (system-name)) nil nil)) + `(,(regexp-quote (system-name)) nil nil)) @end group @end lisp @end defopt @@ -2176,6 +2177,14 @@ reestablished. A value of @code{nil} disables this feature. Most of the methods do not set this property except the @option{sudo} and @option{doas} methods, which use predefined values. +@item @t{"~"}@* +@t{"~user"} + +This is the home directory on the remote host. Setting this +connection property helps especially for methods which cannot expand +to a remote home directory, like @option{adb}, @option{rclone} and +@option{sshfs}. @ref{Home directories} for an example. + @item @t{"tmpdir"} The temporary directory on the remote host. If not specified, the @@ -3252,6 +3261,7 @@ is a feature of Emacs that may cause missed prompts when using @end ifset * File name completion:: File name completion. * Ad-hoc multi-hops:: Declaring multiple hops in the file name. +* Home directories:: Expanding @file{~} to home directory. * Remote processes:: Integration with other Emacs packages. * Cleanup remote connections:: Cleanup remote connections. * Renaming remote files:: Renaming remote files. @@ -3267,24 +3277,25 @@ is a feature of Emacs that may cause missed prompts when using @file{@trampfn{method,host,/path/to/file}} opens file @var{/path/to/file} on the remote host @var{host}, using the method @var{method}. +@c We cannot use @trampfn{} in @item. @table @file -@item @trampfn{ssh,melancholia,.emacs} +@item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}.emacs For the file @file{.emacs} located in the home directory, on the host @code{melancholia}, using method @code{ssh}. -@item @trampfn{ssh,melancholia.danann.net,.emacs} +@item @value{prefix}ssh@value{postfixhop}melancholia.danann.net@value{postfix}.emacs For the file @file{.emacs} specified using the fully qualified domain name of the host. -@item @trampfn{ssh,melancholia,~/.emacs} +@item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}~/.emacs For the file @file{.emacs} specified using the @file{~}, which is expanded. -@item @trampfn{ssh,melancholia,~daniel/.emacs} +@item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}~daniel/.emacs For the file @file{.emacs} located in @code{daniel}'s home directory on the host, @code{melancholia}. The @file{~} construct is expanded to the home directory of that user on the remote host. -@item @trampfn{ssh,melancholia,/etc/squid.conf} +@item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}/etc/squid.conf For the file @file{/etc/squid.conf} on the host @code{melancholia}. @end table @@ -3534,6 +3545,66 @@ file name is equivalent to the previous example: @samp{@trampfn{ssh@value{postfixhop}remotehost|su,,}}. +@node Home directories +@section Expanding @file{~} to home directory + +Home directories on remote hosts can be typed as tilde @file{~}. If +possible, they are expanded to the remote user's home directory on the +remote host. Example: + +@example +@group +@trampfn{ssh,user@@host,~} +@result{} @trampfn{ssh,user@@host,/home/user} +@end group +@end example + +This works in general for @option{ssh}-like methods, and for +@option{sudoedit}. These methods allow also the home directory +expansion for another user, like + +@example +@group +@trampfn{sudoedit,,~otheruser} +@result{} @trampfn{sudoedit,root@@localhost,/home/otheruser} +@end group +@end example + +For other methods, a home directory can be expanded only if supported. +This happens for example for the @option{sftp} method. Methods, which +require a share directory in the remote file name (@option{afp}, +@option{smb}), use the value of this share directory as home +directory: + +@example +@group +@trampfn{smb,user@@host,~} +@result{} @trampfn{smb,user@@host,/share} +@end group +@end example + +Since Tramp cannot know in advance which share directory is intended +to use, this expansion can be applied only when a share directory has +been used already. + +The methods @option{adb}, @option{rclone} and @option{sshfs} do not +support home directory expansion at all. However, @value{tramp} keeps +the home directory in the cache. Therefore, those methods could be +configured to expand a home directory via a connection property, +@xref{Predefined connection information}. Example: + +@lisp +@group +(add-to-list 'tramp-connection-properties + (list (regexp-quote "@trampfn{sshfs,user@@randomhost.your.domain,}") + "~user" "/home/user")) +@end group +@end lisp + +When your remote file name does not contain a @samp{user} part, the +connection property @t{"~"} must be used instead. + + @node Remote processes @section Integration with other Emacs packages @cindex @code{compile} diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 8f54f96573..49778cbfee 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3501,6 +3501,17 @@ Let-bind it when necessary.") (with-parsed-tramp-file-name name nil (unless (tramp-run-real-handler #'file-name-absolute-p (list localname)) (setq localname (concat "/" localname))) + ;; Expand tilde. Usually, the methods applying this handler do + ;; not support tilde expansion. But users could declare a + ;; respective connection property. (Bug#53847) + (when (string-match "\\`~\\([^/]*\\)\\(.*\\)\\'" localname) + (let ((uname (match-string 1 localname)) + (fname (match-string 2 localname)) + hname) + (when (zerop (length uname)) + (setq uname user)) + (when (setq hname (tramp-get-home-directory v uname)) + (setq localname (concat hname fname))))) ;; Tilde expansion is not possible. (when (and (not tramp-tolerate-tilde) (string-match-p "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)) commit 1044338ae7537e4516e426c4090c2b6414a9b787 Author: Po Lu Date: Thu Mar 10 10:39:03 2022 +0000 Fix display of minibuffer prompts in some circumstances on Haiku * src/haikuterm.c (haiku_flush): Always flip buffers as long as buffer flipping is not blocked. diff --git a/src/haikuterm.c b/src/haikuterm.c index 413eedd668..d3168129ce 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -2514,7 +2514,7 @@ haiku_flush (struct frame *f) { /* This is needed for tooltip frames to work properly with double buffering. */ - if (FRAME_DIRTY_P (f) && FRAME_TOOLTIP_P (f)) + if (FRAME_DIRTY_P (f) && !buffer_flipping_blocked_p ()) haiku_flip_buffers (f); if (FRAME_VISIBLE_P (f) && !FRAME_TOOLTIP_P (f))