Commit graph

136 commits

Author SHA1 Message Date
Daniel Eklöf
6d0f8e52cb
wayland: force-trigger a resize on 'configured' event
This ensures we _always_ commit a **new** buffer in response to a
configured event.

This fixes an issue in Gnome where e.g. tiling the window (on the
left/right side) only worked if that caused the windows size to
change.
2020-05-12 18:35:28 +02:00
Daniel Eklöf
69c3e74498
util.h: new header file defining commonly used macros 2020-05-01 11:46:24 +02:00
Daniel Eklöf
fc2e385d87
term: don't enable ptmx FDM callback until Wayland window has been configured
The way things works right now, we cannot enable the ptmx FDM callback
right away. We need to wait for the Wayland window to have been
configured.

Before the window is configured, we don't have a size, and no
grid. Thus, if we try to process ptmx data we'll crash since we have
no where to write it to.

So, registering the ptmx fd with the FDM is now delayed until we've
received the first 'configure' event from Wayland.
2020-04-30 17:22:57 +02:00
Daniel Eklöf
2fd5a9ee8d
wayland: monitor unplug: call surface_leave() to handle terminal unmapping 2020-04-28 19:05:10 +02:00
Daniel Eklöf
9cfe720000
wayland: handle outputs disappearing
That is, deal with monitors being unplugged.

At least on Sway 1.4, surfaces are not unmapped before the output is
removed. Thus, in addition to free:ing the monitor resources, we also
need to update all terminals that are mapped on this output - remove
the output from their "mapped on" list.
2020-04-27 20:46:40 +02:00
Daniel Eklöf
37871aad84
wayland: group handle_global() together with handle_global_removed() 2020-04-27 20:18:03 +02:00
Daniel Eklöf
6f83ef81e5
render: use output's subpixel mode when rasterizing glyphs 2020-04-20 18:38:55 +02:00
Daniel Eklöf
4d52a870b4
conf: add app-id config option and --app-id command line option 2020-04-01 18:40:51 +02:00
Daniel Eklöf
0419156494
search: replace hard-coded key bindings with "user configurable" ones
They aren't really user configurable. At least not yet.

However, with this, we now handle raw key codes just like the normal
key bindings. Meaning, e.g. ctrl+g, ctrl+a, ctrl+e etc now works while
searching with e.g. a russian layout.
2020-03-18 15:30:14 +01:00
Daniel Eklöf
6d30e7d15d
input: bind key bindings to raw key codes too
Before, when looking for a matching user key binding, we only
matched *symbols*.

This means that the physical keys that generate a specific key binding
is layout dependent. What's worse, it may not even be possible to
generate the key binding at all.

Russian is one such layout, where all the "normal" (us) symbols are
replaced.

By using raw key codes, we can get around this - the key code has a
direct mapping to the physical key.

However, matching raw key codes **only** doesn't always make sense
either. For now, match **both** symbols _and_ key codes. Symbols take
precedence.

TODO: we might have to make this configurable _per binding_.

Note: 'search' mode still uses mostly hardcoded shortcuts that still
have this problem (i.e. ctrl+g doesn't work with a russian layout).
2020-03-18 14:29:34 +01:00
Daniel Eklöf
6eeea06cc0
wayland: add FDs to FDM as soon as the FDs are ready 2020-03-15 13:37:56 +01:00
Daniel Eklöf
71fde3bfac
wayland: store display FD in wayland struct
This way we:

* Don't have to call wl_display_get_fd() all the time
* No longer call fdm_del_no_close() even though the FD hasn't been
  added to the FDM.
2020-03-15 13:36:35 +01:00
Daniel Eklöf
59a1204c50
Merge branch 'scale-fonts-using-logical-dpi-plus-scale-factor' 2020-03-13 18:48:15 +01:00
Daniel Eklöf
acecab1c8b
term: use logical DPI+scale factor when scaling fonts
This fixes an issue where the fonts were rendered too small when the
output had fractional scaling.

For integral scaling, using the logical (scaled) DPI multiplied with
the scaling factor results in the same final DPI value as if we had
used the physical DPI.

But for fractional scaling, this works around the fact that the
compositor downscales the surface after we've rendered it.

Closes #5
2020-03-11 16:10:55 +01:00
Daniel Eklöf
2be999a752
Merge branch 'master' into bindings 2020-03-10 18:21:48 +01:00
Daniel Eklöf
270604b318
wayland: remove empty line 2020-03-10 18:06:10 +01:00
Daniel Eklöf
fc7b3b2d85
Merge branch 'master' into bindings 2020-03-09 18:49:44 +01:00
Daniel Eklöf
3e5f011f75
wayland: make a missing presentation time interface an error
If the user wanted to do presentation timing, and the interface isn't
there, then this is an error.
2020-03-09 18:46:09 +01:00
Daniel Eklöf
404365ec56
wayland: register FDM hook early, to avoid unregister errors when failing 2020-03-09 18:45:43 +01:00
Daniel Eklöf
cb21ede020
wayland: free 'search' key bindings on destroy 2020-03-08 15:30:05 +01:00
Daniel Eklöf
fcf4832775
input: convert the rest of the normal key bindings to configurable bindings
New actions defined and implemented:

* scrollback up/down
* font size up/down/reset
* spawn terminal

Break out key combo parsing to a new function,
parse_key_binding_for_action(). This function parses a string
containing one or more space separated key combo definitions on the
form (mod1+mod2+...+key), where key is a XKB key name (e.g. KP_Add).

Convert all hardcoded key bindings to configuration based
bindings. These still cannot actually be configured by the user, but
at least lives in the conf struct.
2020-03-08 15:17:57 +01:00
Daniel Eklöf
b22bb30976
wip: initial framework for dealing with key/mouse bindings in different modes
This adds initial support for defining key and mouse bindings that are
applied in different terminal modes/states.

For example, there are two arrays dealing with key and mouse bindings
in the "normal" mode. Most bindings will go here.

There's also an array for "search" mode. These bindings will be used
when the user has started a scrollback search.

In the future, there may be a model selection mode as well. Or maybe
"search" and "modal selection" will be combined into a single
"keyboard" mode. We'll see.

Since the keyboard bindings depend on the current XKB keymap,
translation from the user specified key combination string cannot be
done when loading the configuration, but must be done when we've
received a keymap from the wayland server.

We should explore if it's possible to load some kind of default keymap
just to be able to verify the validity of the key combination strings
at configuration load time, to be able to reject the configuration at
startup.

A couple of key bindings have been added as proof of concept.

Mouse bindings aren't handled at all yet, and is likely to be
re-written. For example, we can probably translate the configuration
strings at configuration load time.
2020-03-08 12:08:46 +01:00
Daniel Eklöf
e6feed5311
wayland: remove debug logs 2020-03-06 19:19:18 +01:00
Daniel Eklöf
4f90cbda59
wayland: log: say 'requesting' instead of 'referring' client/server decorations 2020-03-06 19:18:59 +01:00
Daniel Eklöf
d76484ae50
wayland: set window geometry to exclude the invisible CSD borders
But it *does* include the title bar. This simplifies the 'adjustment'
needed to be done to the configured window size.

It also fixes a number of issues:

* the compositor will now properly snap the window to screen
  edges (before, there was an empty space between the edge and the
  window - the CSD border).
* This also removes the need for the mutter 'commit' workaround. We
  must be doing something right now.
2020-03-03 18:26:15 +01:00
Daniel Eklöf
f0892988c0
wayland: don't destroy keyboard/pointer if they haven't been removed
When the seat capabilities change, we used to destroy all pointers and
keyboards, and then re-creating them as necessary.

This caused a crash on mutter - probably because we removed a keyboard
device the compositor had already sent an event for (or was about to).

Now, we only destroy and create devices when it's needed.
2020-03-03 18:20:53 +01:00
Daniel Eklöf
9699c9b8bf
csd: initial implementation of minimize/maximize/close buttons 2020-03-02 20:29:28 +01:00
Daniel Eklöf
def4395bd1
wayland: log whether CSDs or SSDs are used at info level, not debug 2020-03-02 18:43:07 +01:00
Daniel Eklöf
22ce09eb44
config: make CSD user configurable
The user can now configure the following:

* Whether to prefer CSDs or SSDs. But note that this is only a hint to
  the compositor - it may deny our request. Furthermore, not all
  compositors implement the decoration manager protocol, meaning CSDs
  will be used regardless of the user configuration (GNOME/mutter
  being the most prominent one).
* Title bar size and color, including transparency
* Border size and color, including transparency

Also drop support for rendering the CSDs inside the main surface.
2020-03-02 18:42:49 +01:00
Daniel Eklöf
d6f0a47fb8
wayland: always update window->is_fullscreen, not just when using CSDs 2020-02-29 17:24:45 +01:00
Daniel Eklöf
32a3f56710
wayland: don't resize when we're not mapped anywhere
Normally, we resize and update the font's DPI whenever our window
enters or leaves an output.

This is since a change in the outputs we're mapped on means the scale
factor to use, or the DPI to use for the fonts may have changed.

However, a special case is when we're removed from the last
output. This should only happen at shutdown, when we're un-mapping
ourselves.

In this case, we typically don't have a access to e.g. the PTMX
fd (often, the reason we're shutting down is because the client
exited). This resulted in (harmless) error messages when emitting the
TIOCSWINSZ event.

Since we're shutting down anyway, we can simply skip the resize and
everything. This gets rid of the error message, and also means we're
shutting down faster.
2020-02-29 15:46:40 +01:00
Daniel Eklöf
43b07b122a
input: csd: add a small delay before initiating a move
This ensures the user has time to double-click to toggle the maximized
state.
2020-02-29 12:56:04 +01:00
Daniel Eklöf
c917a74f48
wayland: remove all usages of wayl_terminal_from_surface()
Use the 'user data' pointer from the wayland surface instead.
2020-02-29 12:13:58 +01:00
Daniel Eklöf
43c0551806
wayland: store pointer to window instance in all surfaces 2020-02-29 12:09:28 +01:00
Daniel Eklöf
6ba476b3bd
wayland: configure: work around GNOME/mutter weirdness
When resizing the window under mutter, mutter seems to expect a
configure ack *and* a surface commit *right* away, or things get out
of sync.

Unlike kwin, which is requires a commit for each configure ack, but is
fine with having the commit arrive later (after we've rendered it),
mutter is not.

I even tried delaying the configure ack until just before the commit,
but still no go.

So for now, detect when we're running under mutter and always do a
surface commit right away.

This can *not* be done on any other compositor as it breaks the CSD
and main surface synchronization; we've resized the CSDs, but not the
main surface.

I.e. this *should* not work, but for some reason is the *only* way to
make things work on mutter.

Interestingly, doing it any other way on mutter causes visual
glitches; window jumping around when resizing, or de-synchronized
CSDs/main surface.
2020-02-28 18:43:33 +01:00
Daniel Eklöf
b69c9b5f58
wayland: fix window size adjustment for CSDs placed outside main surface
* Do this both in XDG configure, and when the decoration manager
  switches between CSDs/SSDs at run-time.

* Exclude CSD borders when we're maximized
2020-02-28 18:42:10 +01:00
Daniel Eklöf
6c20abf279
wayland: warn when compositor doesn't implement the decoration manager interface 2020-02-28 18:37:07 +01:00
Daniel Eklöf
7d021b5b37
wayland: request server side decorations 2020-02-28 18:36:52 +01:00
Daniel Eklöf
3c7e17e8c1
wayland: drop required wl_output interface version from 3 -> 2
We don't need version 3, and mutter 3.34 only implements version 2.
2020-02-28 18:35:50 +01:00
Daniel Eklöf
02fedfb2fc
wayland: resize main surface when enabling CSDs runtime
When we position CSDs inside the main surface, and CSDs are switched
on run-time, we need to force a grid resize, since the actual window
content will now be smaller.

Alternative solution: call resize with width/height increased, to
account for the CSDs. This would increase the window size, but would
keep the grid size fixed.
2020-02-26 13:46:37 +01:00
Daniel Eklöf
5fbbd2f80e
wayland: track window maximized state 2020-02-26 13:23:00 +01:00
Daniel Eklöf
020ce60778
wayland: don't adjust size when CSDs are positioned inside main surface 2020-02-26 13:02:15 +01:00
Daniel Eklöf
6ca880bd3e
wayland: disable debug logs 2020-02-26 12:47:00 +01:00
Daniel Eklöf
1e1b204377
csd: don't draw CSDs in fullscreen mode 2020-02-26 12:39:17 +01:00
Daniel Eklöf
be5988dd3a
wayland: decoration configure: no need to force a resize - just update the CSDs 2020-02-26 12:28:12 +01:00
Daniel Eklöf
135ca0884d
wayland: configure: adjust configured size when using CSDs
The size (width, height) arguments provided by the compositor in the
XDG toplevel configure event *include* the surrounding CSDs.

Since our code assumes the size is for the main surface only (and then
positions the sub-surfaces *outside* the main surface), adjust the
provided size when using CSDs.

This ensures our actual window size ends up being what the compositor
wants it to be, and it fixes resize-glitches when resizing using CSDs.
2020-02-26 12:26:03 +01:00
Daniel Eklöf
ea97a0dc87
wayland: instantiate sub-surfaces on-demand
While most compositors handle instantiated but not-yet-mapped
sub-surfaces correctly, e.g. kwin does not.

For example, it will incorrectly offset the main surface both
horizontally and vertically with a couple of pixels, leaving two
transparent areas at the top and left, between the SSDs and the main
surface.

Note that a workaround is to position the sub-surfaces inside the main
surface while they're unmapped. However, since the surfaces may be
larger than the main surface (the CSDs, for examples, always are),
this doesn't quite work since kwin, at least, resizes the window to
include the sub-surfaces, even when unmapped.

So, instead we instantiate all sub-surfaces on demand, when we know
where to position them, and when they should be mapped.
2020-02-26 12:22:16 +01:00
Daniel Eklöf
2f587f6f3d
csd: position CSD sub-surfaces *outside* the main window
For now, this behavior is controlled with an ifdef. At least kwin
seems very buggy when the decorations are positioned like this (but
normally you'd use server-side decorations with kwin anyway).

This commit also changes 'use_csd' to be a tri-state variable;
when instantiating a window it is set to 'unknown'.

If there's no decoration manager available (e.g. weston), we
immediately set it to 'yes' (use CSDs).

Otherwise, we wait for the decoration manager callback to indicate
whether we should use CSDs or not.
2020-02-26 12:17:58 +01:00
Daniel Eklöf
2855d06c6e
wayland: mark the whole search surface as opaque 2020-02-25 19:57:19 +01:00
Daniel Eklöf
f05e0ad0ae
wayland: synchronize the CSD surfaces to the main surface 2020-02-25 19:56:56 +01:00