Commit Graph

147 Commits

Author SHA1 Message Date
Drew DeVault 236ca63419 swaybg: split into standalone project
The new upstream is https://github.com/swaywm/swaybg

This commit also refactors our use of gdk-pixbuf a bit, since the only
remaining reverse dependency is swaybar tray support.
2019-04-25 18:44:28 +03:00
Connor E b2cfcebef6 Add deprecation warnings for new_float, new_window, and force_focus_wrapping. 2019-04-14 20:44:12 -04:00
Brian Ashworth d9de5b8758 Implement inhibit_idle command
This implements the following command to set/unset a user idle
inhibitor for a view:
`inhibit_idle focus|fullscreen|open|none|visible`

The modes are as follows:
- focus: inhibited when the view is focused by any seat
- fullscreen: inhibited when the view is fullscreen (or a descendant of
  a fullscreen container) and is visible on any output
- open: inhibited until the view is closed or the inhibitor is unset or
  changed
- none: unsets any user set idle inhibitors for the view
- visible: inhibited when the view is visible on any output

This should have no effect on idle inhibitors set by the applications
themselves and those should still work as intended.

Since this operates on the view in the handler context, it is possible
to set it on the currently focused view, on any existing view with
criteria, or for any future view with for_window.
2019-03-24 19:26:12 -06:00
Geoff Greer 6e3046878d Add support for manually setting subpixel hinting on outputs.
Many laptop screens report unknown subpixel order. Allow users to manually set subpixel hinting to work around this.

Addresses https://github.com/swaywm/sway/issues/3163
2019-03-24 09:37:24 +02:00
Ryan Walklin bdb402404c Support WLR_INPUT_DEVICE_SWITCH in sway
This commit adds support for laptop lid and tablet
mode switches as provided by evdev/libinput and
handled by wlroots.

Adds a new bindswitch command with syntax:
bindswitch <switch>:<state> <command>

Where <switch> is one of:
tablet for WLR_SWITCH_TYPE_TABLET_MODE
lid for WLR_SWITCH_TYPE_LID

<state> is one of:
on for WLR_SWITCH_STATE_ON
off for WLR_SWITCH_STATE_OFF
toggle for WLR_SWITCH_STATE_TOGGLE

(Note that WLR_SWITCH_STATE_TOGGLE doesn't map to
libinput and will trigger at both on and off events)
2019-03-19 23:58:47 -04:00
Ryan Dwyer e9a476244d Remove debug tree
This feature has served its purpose. It's better to use IPC now.
2019-03-18 11:29:19 -04:00
Ryan Dwyer 7b9ae42331 Introduce default seatop
This introduces a `default` seat operation which is used when no mouse
buttons are being held. This means there is now always a seat operation
in progress. It allows us to separate `default` code from the standard
cursor management code.

The sway_seatop_impl struct has gained callbacks `axis`, `rebase` and
`end`, and lost callbacks `finish` and `abort`. `axis` and `rebase` are
only used by the default seatop. `end` is called when a seatop is being
replaced by another one and allows the seatop to free any resources,
though no seatop currently needs to do this. `finish` is no longer
required, as each seatop can gracefully finish in their `button`
callback. And `abort` is not needed, as calling `end` would achieve the
same thing. The struct has also gained a bool named allow_set_cursor
which allows the client to set a new cursor during `default` and `down`
seatops.

Seatops would previously store which button they were started with and
stop when that button was released. This behaviour is changed so that it
only ends once all buttons are released. So you can start a drag with
$mod+left, then click and hold right, release left and it'll continue
dragging while the right button is held.

The motion callback now accepts dx and dy. Most seatops don't use this
as they store the cursor position when the seatop is started and compare
it with the current cursor position. This approach doesn't make sense
for the default seatop though, hence why dx and dy are needed.

The pressed_buttons array has been moved from the sway_cursor struct to
the default seatop's data. This is only used for the default seatop to
check bindings. The total pressed button count remains in the
sway_cursor struct though, because all the other seatops check it to
know if they should end.

The `down` seatop no longer has a `moved` property. This was used to
track if the cursor moved and to recheck focus_follows_mouse, but seems
to work without it.

The logic for focus_follows_mouse has been refactored. As part of this
I've removed the call to wlr_seat_keyboard_has_grab as we don't appear
to use keyboard grabs.

The functions for handling relative motion, absolute motion and tool
axis have been changed. Previously the handler functions were
handle_cursor_motion, handle_cursor_motion_absolute and
handle_tool_axis. The latter two both called cursor_motion_absolute.
Both handle_cursor_motion and cursor_motion_absolute did very similar
things. These are now simplified into three handlers and a single common
function called cursor_motion. All three handlers call cursor_motion. As
cursor_motion works with relative distances, the absolute and tool axis
handlers convert them to relative first.
2019-03-17 10:02:04 -06:00
Brian Ashworth ebe5399ed6 pointer_constraint: change to a seat subcommand
This changes the `pointer_constraint` command to be a subcommand of seat
to allow for per-seat settings. The current implementation that is not a
seat subcommand will only operate on the current seat and will segfault
in the config due to `config->handler_context.seat` only being set at
runtime.

This also allows for the wildcard identifier to be used to alter the
pointer constraint settings on all seats and allows for the setting to
be merged with the rest of the seat config.
2019-01-31 22:58:52 -05:00
Drew DeVault a6d41254c9 Add pointer_constraint command 2019-01-30 19:53:59 +01:00
emersion bb2f007ad3
meson: remove rpath options 2019-01-18 08:26:44 +01:00
emersion 08a5b304e4
Use Meson feature options 2019-01-17 18:26:24 +01:00
Brian Ashworth 02bbefda20 bar_cmd_tray_bind: Use mouse button helpers
This modifies `bar_cmd_tray_bindsym` to use `get_mouse_bindsym` for
parsing mouse buttons. This also introduces `bar_cmd_tray_bindcode`,
which will use `get_mouse_bindcode` for parsing mouse buttons. Like with
sway bindings, the two commands are encapsulated in a single file to
maximize shared code.

This also modifies tray bindings to work off of events codes rather than
x11 buttons, which allows for any mouse buttons to be used.

For `get_bar_config`, `event_code` has been added to the `tray_bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
2019-01-16 11:12:45 +01:00
Drew DeVault 4879d40695
Merge pull request #3144 from emersion/cmd-xwayland
Add xwayland command
2019-01-13 20:42:39 -05:00
Drew DeVault 81bb675274
Merge pull request #3344 from RedSoxFan/bar-mouse-bindings-improved
Improve mouse button parsing: bar mouse bindings
2019-01-13 20:41:05 -05:00
Drew DeVault 23ab56bbf7
Merge pull request #3402 from RyanDwyer/refactor-seatops
Refactor seat operations to use an interface
2019-01-13 20:38:34 -05:00
Brian Ashworth ca0a75d540 swaybar: add status_edge_padding command
This adds the bar subcommand `status_edge_padding <padding>` to set the
padding used when the status line is on the right edge of the bar.
2019-01-11 00:12:24 -05:00
Brian Ashworth c0f92cb2fb swaybar: add status_padding command
Adds the bar subcommand `status_padding <padding>` which allows setting
the padding used for swaybar. If `status_padding` is set to `0`, blocks
will be able to take up the full height of the bar.
2019-01-11 00:07:58 -05:00
Brian Ashworth 3d6440ec26 bar_cmd_bind: utilize mouse button helpers
This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing
mouse buttons. This also introduces `cmd_bar_bindcode`, which will use
`get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the
two commands are encapsulated in a single file with shared code.

This also modifies swaybar to operate off of event codes rather than x11
button numbers, which allows for any mouse button to be used.

This introduces two new IPC properties:
- For `get_bar_config`, `event_code` has been added to the `bindings`
section and will include to event code for the button. If the event code
can be mapped to a x11 button, `input_code` will still be the x11 button
number. Otherwise, `input_code` will be `0`.
- Likewise for `click_events`, `event` has been added and will include
the event code for the button clicked. If the event code can be mapped
to a x11 button, `button` will still be the x11 button number.
Otherwise, `button` will be `0`.
2019-01-10 12:43:10 -05:00
Ryan Dwyer ed5aafd90b Refactor seat operations to use an interface
This splits each seat operation (drag/move tiling/floating etc) into a
separate file and introduces a struct sway_seatop_impl to abstract the
operation.

The move_tiling_threshold operation has been merged into move_tiling.

The main logic for each operation is untouched aside from variable
renames.

The following previously-static functions have been made public:
* node_at_coords
* container_raise_floating
* render_rect
* premultiply_alpha
* scale_box
2019-01-10 22:04:42 +10:00
Brian Ashworth 5bf4daf263 Implement tiling_drag_threshold
Implements `tiling_drag_threshold <threshold>` to prevent accidental
dragging of tiling containers. If a container (and all of its
descendants) are unfocused and the tile bar is pressed, a threshold
will be used before actually starting the drag. Once the threshold has
been exceeded, the cursor will change to the grab icon and the operation
will switch from `OP_MOVE_TILING_THRESHOLD` to `OP_MOVE_TILING`.
2019-01-02 23:33:33 +01:00
Ian Fan 6b03c68775 swaybar: implement tray config 2018-12-31 20:40:18 +00:00
Brian Ashworth 4d88c95790 hide_cursor: change to a seat subcommand
This makes hide_cursor a seat subcommand, which allows for seat specific
timeouts.
2018-12-30 14:17:24 +01:00
Brian Ashworth 5fca74a1f1 Implement hide_cursor <timeout> command
Allows the cursor to be hidden after a specified timeout in
milliseconds
2018-12-25 13:31:56 +01:00
Brian Ashworth a223030b70 Change mouse buttons to x11 map and libevdev names
This modifies the way mouse bindings are parsed. Instead of adding to
BTN_LEFT, which results in button numbers that may not be expected,
buttons will be parsed in one of the following ways:

1. `button[1-9]` will now map to their x11 equivalents. This is already
the case for bar bindings. This adds support for binding to axis events,
which was not possible in the previous approach.

2. Anything that starts with `BTN_` will be parsed as an event code name
using `libevdev_event_code_from_name`. This allows for any button to be
mapped to instead of limiting usage to the ones near BTN_LEFT. This also
adds a dependency on libevdev, but since libevdev is already a dependency
of libinput, this should be fine. If needed, this option can have dependency
guards added.

Binding changes:
- button1: BTN_LEFT -> BTN_LEFT
- button2: BTN_RIGHT -> BTN_MIDDLE
- button3: BTN_MIDDLE -> BTN_RIGHT
- button4: BTN_SIDE -> SWAY_SCROLL_UP
- button5: BTN_EXTRA -> SWAY_SCROLL_DOWN
- button6: BTN_FORWARD -> SWAY_SCROLL_LEFT
- button7: BTN_BACK -> SWAY_SCROLL_RIGHT
- button8: BTN_TASK -> BTN_SIDE
- button9: BTN_JOYSTICK -> BTN_EXTRA

Since the axis events need to be mapped to an event code, this uses the
following mappings to avoid any conflicts:
- SWAY_SCROLL_UP: KEY_MAX + 1
- SWAY_SCROLL_DOWN: KEY_MAX + 2
- SWAY_SCROLL_LEFT: KEY_MAX + 3
- SWAY_SCROLL_RIGHT: KEY_MAX + 4
2018-12-25 13:27:08 +01:00
Brian Ashworth 1bd8463481 Implement bar gaps
Adds the bar subcommand `gaps <amount>|<horizontal> <vertical>|<top>
<right> <bottom> <left>` to set gaps for swaybar. Due to restrictions on
margins for a layer_surface, only the sides that are anchored to an edge
of the screen can have gaps. Since there is support for per-side outer
gaps for workspaces, those should be able to be used instead for the
last side.
2018-11-28 11:24:14 -05:00
Brian Ashworth e6562c8cd2 Implement title alignment
This adds support for `i3 4.16`'s ability to set the title alignment.
The command is `title_align left|center|right`.

When the title is on the right, marks are moved to the left. Otherwise,
they are on the right.
2018-11-25 22:08:58 -05:00
Florent de Lamotte 7555c7efdc Adding commands for configuring titlebar borders and padding 2018-11-22 10:30:04 +01:00
emersion bf7af9c690
Merge pull request #3083 from c-edw/feature/StripWorkspaceName
Implement strip_workspace_name.
2018-11-19 17:56:18 +01:00
emersion 311c7db7e3
Add xwayland command 2018-11-19 17:38:37 +01:00
Spencer Michaels 70bc4c3ab6 Add scroll factor config option. 2018-11-18 13:49:30 -05:00
Connor E 4bd46fb079 Implement strip_workspace_name. 2018-11-17 16:11:28 +00:00
Ryan Dwyer b9b1b0e566 Remove raise_floating directive
The directive controlled whether floating views should raise to the top
when the cursor is moved over it while using focus_follows_mouse. The
default was enabled, which is undesirable. For example, if you have two
floating views where one completely covers the other, the smaller one
would be inaccessible because moving the mouse over the bigger one would
raise it above the smaller one.

There is no known use case for having raise_floating enabled, so this
patch removes the directive and implements the raise_floating disabled
behaviour instead.
2018-10-20 17:51:32 +10:00
Ryan Dwyer 832ebc8966 Implement popup_during_fullscreen
This introduces a new view_impl function: is_transient_for. Similar to
container_has_ancestor but works using the surface parents rather than
the tree.

This patch modifies view_is_visible, container_at and so on to allow
transient views to function normally when they're in front of a
fullscreen view.
2018-10-08 22:49:59 +10:00
Jonathan Buch 298ccb539c
Add configuration for raising containers on focus
* New configuration option: raise_floating
  (From the discussion on https://github.com/i3/i3/issues/2990)
* By default, it still raises the window on focus, otherwise it
  will raise the window on click.
2018-10-03 16:23:12 +02:00
Drew DeVault 06c214a800
Merge pull request #2703 from RyanDwyer/csd-border
Add CSD to border modes
2018-10-03 13:03:06 +02:00
Brian Ashworth bb25194844 Handle border options for gaps
Fixes `hide_edge_borders smart` when gaps are in use.
Implements `hide_edge_borders smart_no_gaps` and `smart_borders
on|no_gaps|off`.

Since `smart_borders on` is equivalent to `hide_edge_borders smart`
and `smart_borders no_gaps` is equivalent to `hide_edge_borders
smart_no_gaps`, I opted to just save the last value set for
`hide_edge_borders` and restore that on `smart_borders off`. This
simplifies the conditions for setting the border.
2018-10-01 21:19:06 -04:00
Arkadiusz Hiler eed0bc3ebd Add support for installing binaries with DT_RPATH
It's better to use DT_RPATH dynamic section of the elf binary to store
the paths of libraries to load instead of overwriting LD_LIBRARY_PATH
for the whole environment, causing surprises. This solution is much more
transparent and perfectly suitable for running contained installations
of wayland/wlroots/sway.

The code unsetting the LD_LIBRARY_PATH/LD_PRELOAD was also deleted as
it's a placebo security at best - we should trust the execution path
that leads us to running sway, and it's way too late to care about those
variables since we already started executing our compositor, thus we
would be compromised anyway.
2018-09-30 15:37:01 +03:00
Drew DeVault 8f6aca2166
Merge pull request #2725 from PumbaPe/add-tap-and-drag
Add tap and drag to sway-input
2018-09-30 13:44:11 +02:00
Arkadiusz Hiler 00dfb76832 Remove libcap/prctl artifacts
They seem like relics of the pasts, from when we were retaining the
ptrace cap.

Some translations still may need updates.
2018-09-30 13:39:26 +03:00
PP ae2b70f59e add tap-and-drag setting to sway-input 2018-09-29 11:49:41 +02:00
Ryan Dwyer 7b138e5ef0 Add CSD to border modes
This replaces view.using_csd with a new border mode: B_CSD. This also
removes sway_xdg_shell{_v6}_view.deco_mode and
view->has_client_side_decorations as we can now get these from the
border.

You can use `border toggle` to cycle through the modes including CSD, or
use `border csd` to set it directly. The client must support the
xdg-decoration protocol, and the only client I know of that does is the
example in wlroots.

If the client switches from SSD to CSD without us expecting it (via the
server-decoration protocol), we stash the previous border type into
view.saved_border so we can restore it if the client returns to SSD. I
haven't found a way to test this though.
2018-09-27 22:51:37 +10:00
Ryan Dwyer db28459634 Introduce create_output command (for developer use)
Should help with testing hotplugging.
2018-09-19 21:54:27 +10:00
Ryan Dwyer ec9c4de564 Introduce tiling_drag directive 2018-09-11 17:17:19 +10:00
Ryan Dwyer 7586f150c0 Implement type safe arguments and demote sway_container
This commit changes the meaning of sway_container so that it only refers
to layout containers and view containers. Workspaces, outputs and the
root are no longer known as containers. Instead, root, outputs,
workspaces and containers are all a type of node, and containers come in
two types: layout containers and view containers.

In addition to the above, this implements type safe variables. This
means we use specific types such as sway_output and sway_workspace
instead of generic containers or nodes. However, it's worth noting that
in a few places places (eg. seat focus and transactions) referring to
them in a generic way is unavoidable which is why we still use nodes in
some places.

If you want a TL;DR, look at node.h, as well as the struct definitions
for root, output, workspace and container. Note that sway_output now
contains a workspaces list, and workspaces now contain a tiling and
floating list, and containers now contain a pointer back to the
workspace.

There are now functions for seat_get_focused_workspace and
seat_get_focused_container. The latter will return NULL if a workspace
itself is focused. Most other seat functions like seat_get_focus and
seat_set_focus now accept and return nodes.

In the config->handler_context struct, current_container has been
replaced with three pointers: node, container and workspace. node is the
same as what current_container was, while workspace is the workspace
that the node resides on and container is the actual container, which
may be NULL if a workspace itself is focused.

The global root_container variable has been replaced with one simply
called root, which is a pointer to the sway_root instance.

The way outputs are created, enabled, disabled and destroyed has
changed. Previously we'd wrap the sway_output in a container when it is
enabled, but as we don't have containers any more it needs a different
approach. The output_create and output_destroy functions previously
created/destroyed the container, but now they create/destroy the
sway_output. There is a new function output_disable to disable an output
without destroying it.

Containers have a new view property. If this is populated then the
container is a view container, otherwise it's a layout container. Like
before, this property is immutable for the life of the container.

Containers have both a `sway_container *parent` and
`sway_workspace *workspace`. As we use specific types now, parent cannot
point to a workspace so it'll be NULL for containers which are direct
children of the workspace. The workspace property is set for all
containers, except those which are hidden in the scratchpad as they have
no workspace.

In some cases we need to refer to workspaces in a container-like way.
For example, workspaces have layout and children, but when using
specific types this makes it difficult. Likewise, it's difficult for a
container to get its parent's layout when the parent could be another
container or a workspace. To make it easier, some helper functions have
been created: container_parent_layout and container_get_siblings.

container_remove_child has been renamed to container_detach and
container_replace_child has been renamed to container_replace.

`container_handle_fullscreen_reparent(con, old_parent)` has had the
old_parent removed. We now unfullscreen the workspace when detaching the
container, so this function is simplified and only needs one argument
now.

container_notify_subtree_changed has been renamed to
container_update_representation. This is more descriptive of its
purpose. I also wanted to be able to call it with whatever container was
changed rather than the container's parent, which makes bubbling up to
the workspace easier.

There are now state structs per node thing. ie. sway_output_state,
sway_workspace_state and sway_container_state.

The focus, move and layout commands have been completely refactored to
work with the specific types. I considered making these a separate PR,
but I'd be backporting my changes only to replace them again, and it's
easier just to test everything at once.
2018-09-05 18:01:43 +10:00
Ryan Dwyer f057a0195e Implement focus_on_window_activation
Depends on https://github.com/swaywm/wlroots/pull/1223
2018-09-02 18:20:34 +10:00
Ryan Dwyer 5dbbab7bdc Remove layout.c
When we have type safety we'll need to have functions for
workspace_add_tiling and so on. This means the existing container
functions will be just for containers, so they are being moved to
container.c. At this point layout.c doesn't contain much else, so I've
relocated everything and removed the file.

* container_swap and its static functions have been moved to the swap
command and made static.
* container_recursive_resize has been moved to the resize command and
made static.
* The following have been moved to container.c:
    * container_handle_fullscreen_reparent
    * container_insert_child
    * container_add_sibling
    * container_add_child
    * container_remove_child
    * container_replace_child
    * container_split
* enum movement_direction and sway_dir_to_wlr have been moved to util.c.

Side note: Several commands included layout.h which then included
root.h. With layout.h gone, root.h has to be included by those commands.
2018-08-26 12:05:16 +10:00
Ian Fan c1af79532f commands: add nop 2018-08-18 15:50:26 +01:00
emersion 700941dde8 Listen to server-decoration mode changes 2018-08-06 15:20:30 +01:00
Ryan Dwyer 04489ff420 Separate root-related code
This creates a root.c and moves bits and pieces from elsewhere into it.

* layout_init has been renamed to root_create and moved into root.c
* root_destroy has been created and is called on shutdown
* scratchpad code has been moved into root.c, because hidden scratchpad
containers are stored in the root struct
2018-08-04 14:01:20 +10:00
Brian Ashworth a7f7d4a488 Write to swaynag pipe fd directly on config errors 2018-08-03 10:37:35 -04:00