Commit graph

165 commits

Author SHA1 Message Date
Daniel Eklöf
f928c1fa68
wayland: properly restore window size when being un-tiled
Bind to xdg-shell version 2 if available, as this enables us to
track our window’s ‘tiled’ state in the ‘configure’ events.

This in turn allows us to stash the ‘old’ window size when being
tiled, to be used again when restoring the window size when un-tiled.
2020-10-20 20:58:03 +02:00
Daniel Eklöf
6afe64b7f4
wayland: don’t instantiate a decoration object when user disabled decorations
An application opts *in* for being compositor-decorated by
instantiating a decoration object.

This means, even if we request e.g. CSDs, the compositor can choose to
use SSDs.

By *not* instantiating a decorator object, the compositor *must* not
decorate the window for us.

So, when the user has set csd.preferred=none, we absolute do not want
the compositor to decorate us. Thus, we refrain from instantiating a
decoration object.
2020-10-11 18:47:26 +02:00
Daniel Eklöf
6ff97128fc
conf: csd.preferred can now be set to ‘none’
When csd.preferred == none, we will request CSDs from the compositor,
but internally render as if we are using SSDs. That is, we don’t
render any window decorations at all.

Note that some compositors may ignore our request to use CSDs, and
still render SSDs for us.

Closes #163
2020-10-10 13:07:29 +02:00
Daniel Eklöf
f2c59f8608
wayland: register xdg-output interface on pre-existing output objects
The XDG output manager object may arrive *after* output objects. In
this case, we need to register the pre-existing output objects with
the XDG output manager.

This fixes an issue with some monitors having a DPI value of 0 on
Gnome/mutter, which resulted in incorrect font sizes.
2020-09-04 17:56:40 +02:00
Daniel Eklöf
640445acb4
render: render-timer: position sub-surface similar to the scrollback indicator 2020-08-14 07:48:40 +02:00
Daniel Eklöf
49eea3893e
wayland: global-remove: return after finding a matching seat 2020-08-13 18:47:19 +02:00
Daniel Eklöf
6b18bd998a
wayland: global-remove: fix call to pointer_listener.leave()
Don't call it when we have keyboard focus, call it when we have mouse
focus.
2020-08-13 18:47:19 +02:00
Daniel Eklöf
544c1b1976
config: wip: add support for modifiers in mouse bindings
Mouse bindings can now include modifiers. They are specified in pretty
much the same way as in keyboard bindings:

  Control+BTN_LEFT
2020-08-13 18:47:19 +02:00
Daniel Eklöf
17070a0d54
config: add tweak.render-timer option
This can be set to 'none' (the default), 'osd', 'log' or 'both'.

When 'osd' is enabled, we'll render the frame rendering time to a
sub-surface after each frame.

When 'log' is enabled, the frame rendering time is logged on stderr.
2020-08-13 18:35:17 +02:00
Craig Barnes
4e6100494c Handle allocation failures explicitly in *_init() functions 2020-08-09 08:55:20 +01:00
Craig Barnes
7a77958ba2 Convert most dynamic allocations to use functions from xmalloc.h 2020-08-08 20:37:57 +01:00
Daniel Eklöf
295083059c
Merge branch 'master' into diagonal-dpi 2020-07-28 20:01:56 +02:00
Daniel Eklöf
2815c1c076
wayland: add scrollback indicator surface + sub-surface to wl_window 2020-07-26 10:00:50 +02:00
Daniel Eklöf
e955a14dd0
wayland: calculate a single, scaled DPI value
Previously, we calculated the monitors horizontal and vertical PPI
values.

For font sizing, we used the vertical PPI value. It seems however,
that using the diagonal PPI value, i.e. diagonal_px / diagonal_inch,
gives more consistent results.

This is still a PPI value, but since it is intended to be used as a
FontConfig DPI value, name it 'dpi'.
2020-07-26 07:41:57 +02:00
Daniel Eklöf
067cf6ccb1
wayland: don't assume data-device globals are added before seats
When we're handling the initial set of globals, the data-device and
primary-selection-device objects may, or may not be registered before
the seat(s).

We need to handle both cases.

When adding a seat, instantiate the data-device and
primary-selection-device **if available**.

When adding the device objects, instantiate them on **all** currently
available seats.
2020-07-16 17:47:47 +02:00
Daniel Eklöf
d169e96346
wayland: configure: do a regular resize instead of a force resize
The commit log says that was needed to get tiling in GNOME
working. However, I don't know *which* extension that was.

Force resizing in a configure event means we'll trash a perfectly
valid buffer on e.g. 'activated' state changes.

So, let's revert this for now, and if this breaks GNOME, let's try to
find another solution. If worse comes to worse, we can detect if we're
running under GNOME and do a force-resize then, but not on sane
compositors.
2020-07-13 15:01:27 +02:00
Daniel Eklöf
1c13061f35
wayland: destroy cursor theme when removing pointer capability 2020-07-10 19:32:48 +02:00
Daniel Eklöf
5677df629e
wayland: seat: instantiate pointer surface in capabilities event
This way we only instantiate the surface for seats that actually have
a pointer.
2020-07-10 19:24:33 +02:00
Daniel Eklöf
bf62519d83
wayland: read XCURSOR_{THEME,SIZE} in reload_xcursor theme 2020-07-10 12:06:55 +02:00
Daniel Eklöf
a6da07b3dd
wayland: globals: destroy: seat: use keyboard/pointer listener interfaces 2020-07-09 08:52:39 +02:00
Daniel Eklöf
b6342bb36d
wayland: globals: destroy: handle seats being destroyed 2020-07-09 08:47:56 +02:00
Daniel Eklöf
98f3ccfe79
wayland: log: be clear that these are the XCRUSOR_* environment variables 2020-07-08 20:04:02 +02:00
Daniel Eklöf
d377221e24
xcursor: trigger theme reload in pointer-enter event
Previously, we triggered a theme reload on output changes. This is
completely wrong. We may get a new output with a scale different from
the output the pointer is actually on.

Now, we store the current scale along with the theme. We then trigger
a call to reload the xcursor theme *every* time the pointer enters a
surface. When it does, we use the current scale factor of the terminal
that owns that surface.

If the terminal covers multiple outputs, with different scale factors,
we'll use the largest scale factor. This may not be 100% correct. But
to fix that, we'd need to track which regions of a surface are mapped
on which outputs. Too complicated I say.
2020-07-08 19:52:17 +02:00
Daniel Eklöf
5539af2597
wayland: seat: log keyboard/pointer capability 2020-07-08 19:30:34 +02:00
Daniel Eklöf
4c7d29f7eb
multi-seat: re-enable selection support (excluding OSC 52) 2020-07-08 18:41:09 +02:00
Daniel Eklöf
04e566492c
multi-seat: re-enable scrollback search support 2020-07-08 18:20:34 +02:00
Daniel Eklöf
be2490022d
multi-seat: enable xcursor theme support again 2020-07-08 18:08:39 +02:00
Daniel Eklöf
c470825067
wip: multi-seat support
Compiles and runs, but mouse, clipboard and other things have been
disabled.
2020-07-08 16:45:26 +02:00
Daniel Eklöf
32e70263f9
wayland: use xdg_output's description if there's no 'model' 2020-06-25 17:30:51 +02:00
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