1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-01 00:35:46 +03:00
Commit Graph

781 Commits

Author SHA1 Message Date
Wez Furlong
81bac8b3f2 x11: trace expose events. invalidate geometry in some cases
Main idea here is to add expose events to the trace so that we
can get a sense of whether those are emitted when a WM isn't delivering
CONFIGURE_NOTIFY consistently.

If the exposed area is bigger than what we think the window is,
then we mark geometry as unsure.

I'm considering always marking as unsure for an expose event,
or at least, adding a config option to enable that, as a way
to workaround this situation.

refs: https://github.com/wez/wezterm/issues/2063
refs: https://github.com/wez/wezterm/issues/1992
2022-06-02 09:52:36 -07:00
Wez Furlong
c3b1aa72d3 x11: use focus change as a signal that the size may have changed
From the logs shared in https://github.com/wez/wezterm/issues/2063#issuecomment-1144957250
it looks like focus change events can correlate with the WM tiling
windows, even though the WM doesn't send a CONFIGURE_NOTIFY event.

So let's set a flag to query the geometry when the focus changes

refs: https://github.com/wez/wezterm/issues/2063
refs: https://github.com/wez/wezterm/issues/1992
2022-06-02 08:00:55 -07:00
Wez Furlong
a648d6d8d2 windows: reduce EGL->WGL fallback warning to trace 2022-06-01 05:57:59 -07:00
Wez Furlong
03e07ece56 x11: try harder to detect missing resize/focus events
This commit:

* Logs atom names in property change events (makes it easier to
  understand user's logs)
* Sets flags in cases where property changes might imply that a
  configure or focus event should have or should be sent
* Adjusts the "unsure about state" logic so that it doesn't just
  trigger on the initial paint, but also on those flags being set

refs: https://github.com/wez/wezterm/issues/1992
2022-05-27 08:56:29 -07:00
Wez Furlong
8f222d9559 wayland: make scaling workaround accomodate wlroots
Rather than detaching the buffer, replace it with an appropriately
sized little one.

refs: #1727
2022-05-27 07:07:44 -07:00
Wez Furlong
e83f2c95f4 Allow tracking left/right control and shift modifiers
I think this might only be a thing on Windows.

This commit speculatively (I'm on a mac at the moment!) allows tracking
the left/right control/shift modifier flags and passing that through
to the win32 input mode logic.

refs: https://github.com/wez/wezterm/issues/2009
2022-05-25 18:47:47 -07:00
kumattau
89d78ac410 Fix IME candidate window position on macOS 2022-05-24 09:37:49 -07:00
kumattau
342fa3f55b Add support of IME preedit rendered by system on X11 2022-05-22 06:02:51 -07:00
kumattau
c890c238c1 Add support of IME preedit rendered by system on Windows 2022-05-22 06:02:51 -07:00
Wez Furlong
f72207e7f0 wayland: fix weirdness with recent mutter and display scaling
Mutter recently started to enforce a protocol error that enforces
the ordering of buffer updates and that is flushing out some
bugs in various places; here's a related issue that I stumbled
into when I set my scaling to 300% and got stuck:

https://gitlab.gnome.org/GNOME/mutter/-/issues/2083

What that means to us is that we have to be careful when updating
the buffer scaling properties on our EGL surface.

We don't actually own the underlying buffer or the underlying
buffer commits, so we have to be a little indirect: what
we do here is detach the EGL managed buffer when we notice
that scaling has changed, and that appears to satisfy the
compositor.

refs: https://github.com/wez/wezterm/issues/1727
2022-05-20 08:54:07 -07:00
Wez Furlong
1e61d1ea8b wayland: avoid noisy panic-within-panic on shutdown
Ensure that we eagerly clear the window map to avoid
drop-during-global-dtor related panic which confuses
the root cause of wayland protocol errors.
2022-05-20 07:54:00 -07:00
Funami580
cbd13c5e2a wayland: clipboard: fix pasting if active surface id was not set
refs: #1385
2022-05-16 14:18:28 -07:00
kumattau
bf0f502823 Fix compile error by using i686-pc-windows-msvc 2022-05-16 14:17:38 -07:00
kumattau
ab8ea8b559 Fix X11 IME candidate window position 2022-05-12 09:01:04 -07:00
kumattau
ae4e3a65a2 Fix Windows IME candidate window position 2022-05-12 09:01:04 -07:00
Wez Furlong
cd623dffa8 fix xcb raising a fatal error when closing a window
The rust xcb bindings seem to have gotten more strict in 1.x;
previously we might generate two DestroyWindow calls for the same
window when closing one and things were fine, but now the second
call generates a protocol error which has the effect of terminating
the program.

This commit ensures that we only generate a single DestroyWindow
call by zeroing out the saved window_id after we emit it.

refs: #1974
2022-05-11 06:52:52 -07:00
Wez Furlong
e5a483ff8b window: point to re-integrated xkbcommon
refs: https://github.com/rust-x-bindings/xkbcommon-rs/pull/30
2022-05-09 17:24:20 -07:00
datasone
74e1cdcb40
Add support for drag and drop files in Windows (#1953)
* Add support for drag and drop files in Windows

* Add two drag and drop filename quoting patterns (mainly) for Windows, change doc examples.

* Code style cleanup

* Improve Windows quoting pattern and rename DoubleQuoteAlways to WindowsAlwaysQuoted

* Improve special char finding for DroppedFileQuoting::Windows and fix doc.
2022-05-09 07:38:52 -07:00
Wez Furlong
6484b3adc0 switch macos clipboard crate
This cleans up the `cargo audit` output on linux because the `clipboard`
crate (which hasn't been updated in 3 years) depends on xcb=0.8.2
which is flagged by cargo audit.

We don't use `clipboard` on any platform except macos

This commit switches to the `clipboard_macos` crate; that appears to
use a copy and paste of the macos specific code from the `clipboard`
crate, so this shouldn't have any change in functionality.

refs: https://github.com/wez/wezterm/issues/1952
2022-05-08 21:11:39 -07:00
Wez Furlong
4b018f564a window: point to my xcb for for IME changes
refs: https://github.com/rust-x-bindings/rust-xcb/pull/190
refs: https://github.com/H-M-H/xcb-imdkit-rs/pull/2
2022-05-08 14:02:25 -07:00
Wez Furlong
0a0a1004eb fixup for imdkit changes 2022-05-08 11:53:47 -07:00
Wez Furlong
b365cdbb94 deps: x11 to 2.19 2022-05-07 14:55:08 -07:00
Wez Furlong
abc42f7bcb window: deps: upgrade to xcb 1.1
Was a bit fiddly.

Eliminated the xcb_util crate

refs: https://github.com/wez/wezterm/issues/1952
2022-05-07 14:52:16 -07:00
Wez Furlong
021c0a9bcd window: ignore EINTR, which mio now propagates
The upgrade to a newer mio version caused the poll method
to report EINTR in some cases.

We don't need to terminate for those, so suppress it.

refs: https://github.com/wez/wezterm/issues/1955
2022-05-06 06:56:32 -07:00
Wez Furlong
745bf24d87 deps: upgrade to mio 0.8 2022-05-04 20:16:41 -07:00
Wez Furlong
4d09fe1f7d windows: use ? operator to tidy up a little bit 2022-04-26 07:36:20 -07:00
Wez Furlong
8005c9df98 windows: fix stuck IME composition when switching input methods
refs: https://github.com/wez/wezterm/issues/1922
2022-04-26 07:29:48 -07:00
Wez Furlong
bd70cad6fa macos: more urgh with swapped chars/unmod
a redo of 81d08325c1, which was a bit
more nuanced. Partially revert the logic from that commit and rephrase
it as factoring out the condition to make that part clearer, but restore
the original action, which is important in order to propagate the
modifiers through.

refs: https://github.com/wez/wezterm/issues/1907#issuecomment-1108797343
2022-04-25 19:26:41 -07:00
Ye Sijun
ccd3403bad add docs for quote_dropped_files
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-04-25 09:49:32 -07:00
Ye Sijun
8f6facd584 support drag and drop files for macos
Signed-off-by: Ye Sijun <junnplus@gmail.com>
2022-04-25 09:49:32 -07:00
Wez Furlong
19cfdf1aa1 macos: simplify keycode imports a little 2022-04-24 16:14:39 -07:00
Wez Furlong
81d08325c1 macos: ctrl-shift-/ also swaps chars and unmod
I don't like this :-/

refs: https://github.com/wez/wezterm/issues/1907
2022-04-24 16:12:44 -07:00
Wez Furlong
63414b9826 window: macos: refactor UCKeyTranslate calls
Makes them a little easier to follow.

This shouldn't change any behavior.
2022-04-22 22:49:26 -07:00
Wez Furlong
80fcedbf92 window: macos: remove on horrible keyboard hack
We can synthesize the key down for ctrl-tab in perform_key_equivalent,
so let's do that!
2022-04-22 22:43:48 -07:00
Wez Furlong
26500c675f macOS: fix Shift-Tab
refs: https://github.com/wez/wezterm/issues/1902
2022-04-21 18:38:27 -07:00
Wez Furlong
453381251c macos: more weirdness with alt/shift/bracket
It looks like we don't need to special case left/right bracket any more;
tested with both Italian (right-alt-shift-leftbracket) and Norwegian
(right-alt-shift-9), and confirmed that right-alt-shift-grave does
produce alt-tilde.

refs: https://github.com/wez/wezterm/issues/1901
refs: https://github.com/wez/wezterm/issues/1706
refs: https://github.com/wez/wezterm/issues/760
2022-04-21 07:32:49 -07:00
Wez Furlong
924b63eb42 macos: fixup Backspace key
refs: https://github.com/wez/wezterm/issues/1891#issuecomment-1103501418
2022-04-19 23:24:36 -07:00
Wez Furlong
b92f31e7a6 macos: fix CTRL-Backslash on German layouts
refs: https://github.com/wez/wezterm/issues/1891
2022-04-19 14:17:04 -07:00
Wez Furlong
d64bc7248e pty: pre-fill base env from registry env settings on Windows
I think I'd like to make a config option for this, but for the moment,
this first pass unconditionally updates the base environment with
data from the registry.

refs: https://github.com/wez/wezterm/issues/1848
2022-04-19 09:56:23 -07:00
Wez Furlong
77ecbe29b1 x11: set _NET_WM_NAME for clients like polywins/polybar 2022-04-18 08:05:20 -07:00
Wez Furlong
47addfa53c Ctrl-[ and Ctrl-Esc didn't send key_down until key_up
Looking closer, I think I'd misread the key event generated by
perform_key_equivalent for the ctrl-escape case as a key down.

Fixing this is fairly straightforward: when we return YES from
perform_key_equivalent we synthesize a key_down event.
macos will follow up with the key up.

We can fold two cases together in there and remove the horrible
hack style fix I just added in a4b68247bb

refs: https://github.com/wez/wezterm/issues/1877
2022-04-15 21:28:26 -07:00
Wez Furlong
325c1a9e91 window: macos: suppress UNHANDLED logging for Shift-Tab 2022-04-15 21:23:24 -07:00
Wez Furlong
3688055ced macos: remove .normalize_ctrl from key processing
We don't want/need this any longer.

refs: https://github.com/wez/wezterm/issues/1851#issuecomment-1099501144
2022-04-15 21:04:12 -07:00
Wez Furlong
a4b68247bb window: fix CTRL-[ on macos
This is another key combination that doesn't generate a key-down
event.

refs: https://github.com/wez/wezterm/issues/1877
2022-04-15 20:51:01 -07:00
Wez Furlong
fdb3471017 xkeyboard: resolve ambiguous CTRL-i / CTRL-Tab
We want to avoid normalizing control key presses; there were
two places where it was happening; one in our own code and
the other was in the xkeyboard mapping stuff itself.

refs: https://github.com/wez/wezterm/issues/1851
2022-04-15 07:27:01 -07:00
Wez Furlong
e680cc848a macos: workaround weird CMD-. behavior
There are certain key combinations that macOS prefers to handle
without giving the application much opportunity to process them.

CTRL-ESC and CMD-. both cause doCommandBySelector(cancel:) to be
called.  The former we had already special cased but since we
can't disambiguate the two things, we need a better way.

performKeyEquivalent: is a method we can implement to have an
opportunity to "do something" and prevent the default macOS behavior.

So we implement that. What's interesting is that saying that we handled
CMD-. results in no further processing at all by macOS, whereas saying
that we handled CTRL-ESC results in macOS doing the normal key event
dispatch.  So we need to route that event for ourselves in that one
case.

Doesn't feel great!

refs: https://github.com/wez/wezterm/issues/1867
2022-04-12 17:41:37 -07:00
Wez Furlong
bbb842c3e9 macos: suppress IME UNHANDLED warning for shift up/down 2022-04-09 22:19:22 -07:00
Wez Furlong
738e180295 x11/wayland: add tracing to xcursor loading code
Makes it easier to understand what is happening when debugging xcursor
issues:

```
WEZTERM_LOG=window::os::x11::cursor=trace,info wezterm
```
2022-04-09 06:48:29 -07:00
David Rios
44a26c78f2 wayland: improve touchpad scroll precision
- Save the remainder of the scroll delta to be used on the next event
when it doesn't meet the activation threshold

refs: https://github.com/wez/wezterm/issues/1827
2022-04-08 07:50:47 -07:00
Wez Furlong
b35e3b2aad deps: remove pretty_env_loggger
Go directly to the underlying env_logger crate, as pretty_env_logger
hasn't been updated in some time, and I'd like to be able to redirect
the log output to a file more directly, and that feature is in a newer
version of the env logger than pretty_env_logger was pulling in.
2022-04-07 08:24:07 -07:00
Wez Furlong
0cfdf0999c macos: send_composed_key_when_X_alt_is_pressed now ignores other mods
For reasons that I cannot remember, I made
`send_composed_key_when_left_alt_is_pressed` and
`send_composed_key_when_right_alt_is_pressed` only take effect if only
the ALT modifiers were pressed.  If SHIFT or CTRL were pressed, then
the purpose of `send_composed_key_when_left_alt_is_pressed` was
bypassed.

This commit scopes this back to the alt mods - other kinds of mods
don't affect this functionality any more.

refs: https://github.com/wez/wezterm/issues/1826
2022-04-06 18:26:16 -07:00
Wez Furlong
6c5e54c47e deps: unpin glium from git, use latest release
We were pinned on the revision where I had added dual source blending,
because I wanted that feature ahead of the crate being published.

Since then a couple of releases have been made so we can unpin.

On Windows 11, we had a report of glium complaining about the opengl
version. I can't find that error message string in the current version
of the code so it's possible that that situation has been resolved.

refs: https://github.com/wez/wezterm/issues/1813
2022-04-04 06:54:49 -07:00
Wez Furlong
0284bcdd3d x11: set position only if explicitly requested
refs: #1794
2022-04-03 18:00:27 -07:00
Wez Furlong
603f6d69ce try harder to set the x,y position on x11
refs: #1794
2022-04-03 17:01:03 -07:00
Wez Furlong
7526b0567c x11: add KP_End keysym mapping
refs: #1804
2022-04-03 07:36:48 -07:00
Wez Furlong
02d5d9425d x11: improve trace logging for keyboard handling
refs: #1804
2022-04-03 06:32:42 -07:00
Wez Furlong
e95707fe70 flesh out % based and named display for positioning on X11
refs: #1794
2022-04-02 22:45:13 -07:00
Wez Furlong
13bfa27d2e flesh out % based and named display for positioning on macOS
refs: #1794
2022-04-02 15:40:09 -07:00
Wez Furlong
9a324385eb flesh out % based and named display for positioning on Windows
refs: #1794
2022-04-02 11:11:28 -07:00
Wez Furlong
02aae83794 fix windows build
refs: #1794
2022-04-02 09:46:36 -07:00
Wez Furlong
52edc8bb11 window: speculative code to enable initial position on windows
need to move this to my windows machine to try it

refs: #1794
2022-04-02 09:40:41 -07:00
Wez Furlong
8ac793a619 add --position CLI option for requesting initial window position
refs: #1794
2022-04-02 09:32:21 -07:00
Wez Furlong
2faa6822f9 fix mac, windows builds
refs: https://github.com/wez/wezterm/issues/1794
2022-04-02 07:58:27 -07:00
Wez Furlong
89b653acb8 x11: respect requested x/y geometry if provided
refs: https://github.com/wez/wezterm/issues/1794
2022-04-02 07:47:03 -07:00
Wez Furlong
69288aee4c window: Add RequestedWindowGeometry type
This is mostly a refactoring: pulling out the discrete width/height from
the `new_window` method and preparing to pass down x/y coords as well.

The types are expressed as Dimension so that screen relative sizes could
be expressed in the future... once we know how to obtain that
information on each platform.

refs: https://github.com/wez/wezterm/issues/1794
2022-04-02 07:25:59 -07:00
Wez Furlong
67218d3a85 fix formatting 2022-04-01 08:15:32 -07:00
Wez Furlong
8ba0ef2375 macos: notch avoidance tweak
https://github.com/wez/wezterm/issues/1737#issuecomment-1085923867
2022-04-01 08:14:11 -07:00
David Rios
821b6f67bb Improve touchpad precision on Wayland 2022-03-31 07:15:45 -07:00
Wez Furlong
ff88fec880 window: add Debug trait to os parameters types 2022-03-30 07:02:47 -07:00
David Rios
45072fa475 Overhaul scroll thumb calculation
- Simplify scroll thumb calculations
- Correct thumb position when dragging with mouse
- Support border OS parameters
- Use usize for OS borders, to explicitly only accept positive integers
- Get correct tab height when using fancy tab bar
- Correctly draw depending on tab bar position
- Adjust minimum thumb size to be 1/2 of a cell height, so it has consistent size across platforms and screen densities

Fixes #1525
2022-03-29 08:55:25 -07:00
Wez Furlong
045698e6ca x11: query focus prior to painting if we don't know focus state
We don't assume that we start up focused, and some WM don't tell
us our focus state, so prior to painting, if we don't know the
focus state, explicitly query it and synthesize a focus change event.

refs: https://github.com/wez/wezterm/issues/1757
2022-03-27 07:10:47 -07:00
Wez Furlong
4cd893335b fix build for intel mac 2022-03-26 23:14:15 -07:00
Wez Furlong
4e343eb1e5 macos: try to avoid the notch
Flesh out the get_os_parameters impl for macOS.  When running on a
system that provides `NSScreen::safeAreaInsets`, use that to determine
the border required to avoid the "notch" on certain models of mac.

In the GUI layer: when the os parameters include a border, adjust
the render position to account for it.

This is a bit of a speculative change, as I don't have a mac with
a notch.

refs: https://github.com/wez/wezterm/issues/1737
2022-03-26 22:47:42 -07:00
Wez Furlong
a61d3a1b99 macos: clear scroll remainder when changing scroll direction 2022-03-26 20:46:28 -07:00
David Rios
491fe14ca9 Fix touchpad on windows 2022-03-26 17:45:40 -07:00
David Rios
fca3559a0f
Implement native window dragging on Windows (#1771)
Implement native window dragging on Windows
2022-03-26 17:28:43 -07:00
Wez Furlong
91a0903246 windows: simplify logfont assignment/fetch 2022-03-26 07:52:25 -07:00
David Rios
109330fefa Get window state on resize, fixes #1502 2022-03-26 07:27:54 -07:00
David Rios
5c5f2dbca5 Cache title_font 2022-03-26 07:27:54 -07:00
David Rios
eaaf98ad2f Uncomment title font 2022-03-26 07:27:54 -07:00
David Rios
c55d44aa72 Use anyhow ensure
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2022-03-26 07:27:54 -07:00
David Rios
da74100d5e Use equality to check focus
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2022-03-26 07:27:54 -07:00
David Rios
b3f1ef7577 Remove unused function 2022-03-26 07:27:54 -07:00
David Rios
a95b081620 Improve the responsiveness of the drawn border 2022-03-26 07:27:54 -07:00
David Rios
b036bb3b05 Improve RESIZE window_decoration on Windows 2022-03-26 07:27:54 -07:00
Wez Furlong
623f617951 x11: window icon had red/blue channels swapped
closes: #1754
closes: #1755
2022-03-23 07:01:26 -07:00
Wez Furlong
5c8ff787c6 x11: query geometry if we're painting and never had CONFIGURE_NOTIFY
If the WM has never confirmed our size and we're about to paint,
explicitly query it and generate a resize event so that we stand
a better chance of showing the right stuff.

refs: https://github.com/wez/wezterm/issues/1710
2022-03-22 09:50:52 -07:00
Wez Furlong
57c66053d2 x11: more logging around configure notify events
refs: #1710
2022-03-22 09:30:50 -07:00
Wez Furlong
9936b8a5ab add xcursor_theme and xcursor_size config options
refs: #1742
2022-03-22 08:23:17 -07:00
Wez Furlong
bd9088372a wayland: speculative handling of pointer when seat changes
It compiles and launches under weston, so that's promising.
I can't test the suspend/resume case on the hardware I have available.

refs: #1497
2022-03-19 05:47:04 -07:00
Adam Harvey
0c7e735a86 window: correctly handle keyboard input after seat updates
When the user switches to another virtual console and then back into a
Wayland session, a number of seat updates are received by the listener
installed by `Environment::listen_for_seats()`. These updates
essentially flip the keyboard and pointer flags off and then back on in
the seat data, which indicates that new handlers need to be assigned to
the keyboard and pointer objects.

However, because one update is received for _each_ flag being toggled,
this means that the listener is fired twice with `has_keyboard` set to
true, which means that two keyboard handlers end up being installed.
Users then experience each keypress being delivered twice to the
terminal.

This commit adds a map to track the keyboard object that has been
assigned on each seat, thereby preventing duplicate assignments and (by
extension) duplicate keypresses being registered. This logic is
essentially the same as what's used in the `kbd_input` example in SCTK,
which doesn't have this issue.

Something similar is required for pointer handling, which also breaks
after switching to another virtual console and back into Wayland, but I
was scared off by the TODO in the `listen_for_seats` callback and didn't
investigate this further.
2022-03-19 05:11:04 -07:00
Wez Furlong
0b7cb6550b macos: more urgh with alt+shift key combinations
refs: https://github.com/wez/wezterm/issues/760
refs: https://github.com/wez/wezterm/issues/1706
2022-03-18 13:32:43 -07:00
Wez Furlong
8c3d2f6eb6 windows: make repeated dead key handling consistent with other apps
On Windows in FRA layout, `^^SPACE` results in `^^SPACE`, whereas
on Linux it results in `^SPACE`.  We were doing the latter instead
of the former.

Let's just be consistent with other windows apps.

closes: #1729
closes: #1730
2022-03-18 10:42:14 -07:00
Wez Furlong
edd997d0f7 macos: fix CTRL-Tab
refs: https://github.com/wez/wezterm/issues/1684
2022-03-12 13:25:42 -07:00
Wez Furlong
c1fb73409d macos: improve handling of keys when both ALT+SHIFT are pressed
refs: https://github.com/wez/wezterm/issues/1706
2022-03-12 12:01:16 -07:00
Sebastian Wiesner
277d30ef2e Support primary selection on Wayland
Closes #1423
2022-03-12 05:42:01 -08:00
David Rios
aaad2be606
Detect mouse leaving the window (#1679)
* Detect mouse leaving the window

* Implement leave

* Use new API

* Fix mouse leave

* Fix mouse leave on Wayland

* Mouse leave on X11

* Detect mouse leaving window on macOS

* Fix example

refs:  #1434
2022-03-11 08:26:09 -08:00
David Rios
3b05dac0c6 Use newer windows crate 2022-03-11 07:40:39 -08:00
Greg V
9879005f87 add support for XF86Copy/XF86Paste keys 2022-03-11 06:43:18 -08:00
Wez Furlong
3234ef0ec9 x11: add fallbacks when loading xcursor themes
refs: #1655
2022-02-23 08:53:11 -07:00