Commit graph

3541 commits

Author SHA1 Message Date
Jan Beich e0324fc88c config/output: unbreak on 32-bit architectures
sway/config/output.c:624:54: error: format specifies type 'long' but the argument has type 'size_t' (aka 'unsigned int') [-Werror,-Wformat]
                sway_log(SWAY_DEBUG, "spawn_swaybg cmd[%ld] = %s", k, cmd[k]);
                                                       ~~~         ^
                                                       %zu
include/log.h:40:74: note: expanded from macro 'sway_log'
        _sway_log(verb, "[%s:%d] " fmt, _sway_strip_path(__FILE__), __LINE__, ##__VA_ARGS__)
                                                                                ^~~~~~~~~~~
2019-04-08 14:02:52 -06:00
Brian Ashworth 75e7bd24cc swaybg: one instance for all outputs
This makes it so there will only be one swaybg instance running
instead of one per output. swaybg's cli has been changed to a xrandr
like interface, where you select an output and then change properties
for that output and then select another output and repeat. This also
makes it so swaybg is only killed and respawned when a background
changes or when reloading.
2019-04-04 20:08:21 +03:00
Brian Ashworth 0ad905f23c idle_inhibit: fix crash during view destruction
This fixes a crash for application set idle inhibitors when their
associated view is being destroyed. There is a call to
`view_is_visible` to determine is the view is visible and it assumes
that the view has an container, but it is possible for the container
to already have been destroyed at this point. There is a NULL check for
the view in `check_active` and this re-adds the NULL check for the
container that I accidentally dropped when refactoring during the
inhibit_idle command PR
2019-04-03 19:46:08 +03:00
Brian Ashworth f0f20f96aa root_scratchpad_hide: fix crash when layer focused
This fixes a crash in `root_scratchpad_hide` when a layer surface is
focused. Since `seat_get_focus` is NULL when a layer surface is
focused, the call to `node_has_ancestor` was causing a SIGSEGV since it
was attempting to access the parent of NULL. This changes the call to
`seat_get_focus_inactive`, which will return a node even when a layer
surface is focused and is also guaranteed to have something in the
focus stack if a scratchpad container is being hidden (otherwise there
would not be any containers yet).
2019-04-03 19:45:17 +03:00
Brian Ashworth 679c058fac scratchpad: set initial size
This matches i3's behavior of setting scratchpad containers to 50% of
the workspace's width and 75% of the workspace's height, bound by the
minimum and maximum floating width/height.
2019-03-31 17:49:05 -06:00
Brian Ashworth 0676ace97f floating: fix size of non-view containers
This fixes the sizing of floating non-view containers. On master, the
floater will get set to the maximum width and height, which by default
is the entire output layout. When setting a non-view container to
floating, this will set a sane default size of 50% of the workspace
width and 75% of the workspace height, or whatever the closest is that
the minimum and maximum floating width/height values allow for. On all
future calls to `floating_natural_resize`, the width and height will be
kept unless they need to be changed to respect the min/max floating
width/height values.
2019-03-31 17:49:05 -06:00
Brian Ashworth dd28e6a6d6 Fix xwayland configure request scratchpad crash
This fixes a crash in `container_init_floating` when a xwayland view
sends a configure request while in the scratchpad.

`container_init_floating` gets called so the configured minimum and
maximum sizes gets respected when resizing to the requested size. Since
the workspace was NULL, it would SIGSEGV when attempting to get the
workspace's output for the output box retrieval.

This extracts the resizing portion of `container_init_floating` into a
separate function. If the container is in the scratchpad, it will just
be resized and skip the centering.

Additionally, `container_init_floating` has been renamed to
`container_floating_resize_and_center` to more accurately describe what
it does.
2019-03-31 09:32:23 +03:00
Ryan Dwyer 2cae0d5e3a Fix null pointer crash when doing tiling drag
* Create layout S[V[view view] view]
* Drag bottom view to the top
* Sway would crash when the cursor hovers the V[view view] title while
dragging
2019-03-29 09:26:06 -06:00
Jan Pokorný bfdee1319f bindings: fix overwrite log argument mismatch
Thanks, @RedSoxFan, for the review spotting another instance.
2019-03-27 12:07:52 -04:00
Ashkan Kiani 3a31889d7c Fix crash for floating command on scratchpad window 2019-03-26 23:38:23 -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
Philipe Goulet 8d2c982f3f Fix #3924
Removes "unescape_string(argv[i]);".

Since "do_var_replacement(argv[i])" never adds escape
characters, it is both wrong and unnecessary to remove escape characters
on the next line.

This caused characters that were meant to be escaped to not be anymore.
2019-03-24 19:04:15 -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
mliszcz 200833caae Allow for workspace renaming during exec handling
This change adds support for renaming a workspace when `exec` command
is being processed by keeping sway_workspace and pid_workspace names in
sync.

The change can be verified by running following command:

swaymsg exec <application>; swaymsg rename workspace number 1 to 5

Fixes: #3952
2019-03-23 17:49:27 -04:00
Brian Ashworth cd8b4ace92 fix opening a floating view on the NOOP output
Since the NOOP output has no size, the minimum floating size is greater
than the workspace size for the NOOP output. In this case, the floater
gets centered in the output instead of the workspace. However, the
NOOP output is not part of the output layout and thus has a NULL box.
Attempting to access the properties of this box was causing a segfault.

This fixes the issue by just setting the floater's box to all zeroes
when mapping on the NOOP output. When the workspace gets moved from the
NOOP output to a new output, any floater whose width or height is zero
or has an x or y location outside of the output, gets passed to
`container_init_floating` again. This will then set the appropriate
size and centering. For any floater that has a valid size and location,
they are preserved.
2019-03-23 23:39:42 +02:00
Brian Ashworth 7d2076cbff criteria: fix __focused__ when no focus or unset
This fixes the behavior of `__focused__` when there is no focused view
to match i3's behavior of successfully matching no views instead of
returning an error of a missing value. It also applies the same logic
when a token is not applicable (or unset) for a view such as `app_id`
for a focused xwayland view or `class` for a focused xdg-shell view.

This adds an `autofail` boolean to `struct criteria`. If it is set to
`true`, then `criteria_matches_view` will immediately bail out as a
no match. If `autofail` is set, the criteria will also not be
considered empty by `criteria_is_empty`.

To set this new `autofail` property, `get_focused_prop` will now take
in a boolean pointer of the same name. If `__focused__` is supported
for the token and there is no focused view or the focused view does not
have a value for the token, then the boolean will be set to true. In
`parse_token`, the boolean value will be checked and if set to true,
then `criteria->autofail` will be set to true and `parse_token` will
bail successfully. Tokens will still be parsed to make sure the whole
criteria is syntactically valid, which is also why
`&criteria->autofail` is not passed to `get_focused_prop` and a local
boolean is declared in `parse_token`.
2019-03-23 09:53:23 +02:00
Brian Ashworth 8cd7f0171a cmd_mode: allow cmd_set to be a subcommand
This allows set to be used in mode blocks
2019-03-23 08:07:25 +02:00
Ryan Dwyer cdcc2a5bb5 Support focus <direction> for floating containers
This kind of worked before in that focus would change, but it wasn't
intentionally supported and had side effects such as not raising
the container, and being unable to cycle through all floaters depending
on the direction used.

This commit makes it properly supported. The new focus is chosen based
on the distance to the center point of each floating container in the
workspace, and the container is raised.

In a multi output setup, if both visible workspaces have floating
containers, focus will NOT cross into the other output. It is assumed
the user will use a workspace binding in this case.

If two floating containers occupy the exact same center point and you
try to focus in a direction, the behaviour is undefined.
2019-03-20 08:55:28 -06: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 bfa20e65d8 Clean up focus follows mouse logic
Firstly, this fixes a recent regression where having
`focus_follows_mouse yes` and hovering an inactive tab caused it to gain
focus. The code was missing a view_is_visible check.

The code is handling the logic for both focus_follows_mouse yes and
focus_follows_mouse always, where the latter will apply when nudging the
mouse after a workspace switch. However, the view_is_visible check
didn't apply when using focus_follows_mouse always, so hovering a tab
with that configuration would cause is to focus. This was a bug. When
adding the view_is_visible check, it now applies to both yes and always.

Note that the comment about the split container was wrong. At this point
the hovered node cannot be a split container because it passed the
node_is_view check. The comment has been removed.

Lastly, the else condition is completely removed. This didn't appear to
have any practical use. Setting focus to the result of
seat_get_focus_inactive is very likely going to be a no op. There is a
slim chance that this will break something, and if so I'd like to find
out what so it can be properly documented in the code.
2019-03-19 14:38:06 -06: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 38bd60c4b3 Document the title_format command 2019-03-18 11:27:36 -04:00
Brian Ashworth 0327c999d7 config/output: handle wildcard in get_output_config
In #3916, I overlooked that `get_output_config` does not handle
wildcards unless the config is reloading, which is a remnant of older
iterations of the output config handling that went unnoticed due to
`output_find_config` handling it. With the current version of the
output config handling, having `get_output_config` handle wildcard
configs is actually preferable. This fixes having only a wildcard
output config in the config file or when connecting/enabling a new
output with only a wildcard config existing.
2019-03-17 18:05:27 +02: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
Ryan Dwyer fb3475e291 Replace seatup allows_events with button callback 2019-03-17 10:02:04 -06:00
Brian Ashworth 73605dac2a config/output: revamp identifier/name layering
This revamps the way that output configs are handled when referencing
an output by both identifier and name. If an output is always referred
to by name or by identifier, this should have no noticeable change. As
soon as there is a name output config and an identifier output config
that matches an output, an output config is generated that is named
`<identifier> on <name>` that is generated with the identifier output
config merged on top of the name output config and stored. When a
change to either is stored, the delta is merged on top of that
"id on name" output config, as well. If the "id on name" output config
exists, it has the highest precedence and will be used when applying
a config to the output.

This fixes the following case:
- `swaymsg output <name> bg /path/to/wallpaper1 fill`
- `swaymsg output <identifier> bg /path/to/wallpaper2 fill`
- `swaymsg output <name> dpms on`

Without this, the wallpaper is changed to `/path/to/wallpaper1`. With
this, the wallpaper remains `/path/to/wallpaper2`.
2019-03-16 10:41:02 -06:00
Brian Ashworth 3106ef23a7 Fix output config retrieval for new outputs
This removes `output_find_config`, which would take the first matching
output config it found. This is fine if only a name output config,
identifier output config, or even just wildcard exist, but if there is
a name output config and identifier output config, they are not merged.
Instead, this introduces find_output_config, which is just a wrapper
for `get_output_config`. This ensures that both the name and identifier
output configs are respected.

This fixes the following case:
- For simplicity in this example, remove all output configs from config
- Run `swaymsg output <name> bg #ff0000 solid_color`
- Run `swaymsg output <identifier> scale 2`
- Disconnect and reconnect output

Without this, the output will have the background, but not the scale.
With this, the output will have both the background and scale
2019-03-16 10:40:46 -06:00
minus 264e213c08 Fix quoting of commands passed to for_window
E.g. `for_window [class="mpv"] move container to output "Dell Inc. ..."`
does not work because the executed move command only uses `Dell` as
output name.
2019-03-15 14:52:38 -04:00
Brian Ashworth e687e120e0 output_cmd_background: validate colors
This validates the color and fallback color in `output_cmd_background`
to ensure that only colors of the form `#RRGGBB` are accepted.
2019-03-15 09:50:10 +02:00
Brian Ashworth d8f74e4706 Set prev_workspace_name based off of focus
This moves setting `seat->prev_workspace_name` from `workspace_switch`
to `set_workspace`. `workspace_switch` is only called when using a
`workspace` command to change the workspace so any workspace change
based on criteria was not altering `seat->prev_workspace_name`. By
moving it to `set_workspace`, which is called by `seat_set_focus`, it
will change any time focus changes to a node on a different workspace
2019-03-14 10:03:45 -06:00
Brian Ashworth acdb4ed7a3 xwayland: handle floating configure request size
This makes it so the container gets resized by a configure request for
xwayland floating views. The minimum and maximum sizes are also
respected. Previously, the configure request was resizing the surface
to the size requested, but never changing the container size. This
caused the surface to be rendered outside of the container or to be
smaller than the container. The former is never ideal and the latter
makes no sense for floating views since the container itself can just
be shrunk.
2019-03-13 09:06:04 +01:00
Brian Ashworth 52a61671e9 criteria: change workspace to support regex
This changes the workspace criteria to support regex instead of basic
strings. This matches i3's behavior.
2019-03-12 20:52:09 -06:00
Brian Ashworth 3330faded5 Handle seat_get_focused_workspace returning NULL
This modifiers the callers of seat_get_focused_workspace to handle
getting NULL as the return value, if they did not already.
2019-03-12 19:14:04 +01:00
Brian Ashworth 1bab5a9553 get_deco_rect: fix floaters on tabbed/stacked ws
This fixes the decoration rects for floating containers on a workspace
that is either tabbed or stacked. Without this, the floater would
incorrectly try to calculate where it's tab or stack decorations were
on the workspace. This would cause a SIGFPE (due to a divide-by-zero)
when the floater was on a tabbed workspace without any tiling children.
Furthermore, the floater does not care what the workspace's layout is
and should just use the location relative to the workspace. This should
have no effect on children of a floating container.
2019-03-11 21:31:47 -06:00
Ian Fan 055d662baa commands: allow tiled sticky containers to be moved
Namely, to a workspace on the same output.
However, tiled sticky children of floating containers are still restricted.
2019-03-11 21:49:37 -04:00
emersion 076257a978 Stop using wlr_output->{lx,ly}
Also fixes sway_output->{lx,ly,width,height} not being updated. Also fixes
output_get_in_direction adding buffer coords to layout coords.
2019-03-11 12:43:01 -04:00
Ryan Dwyer 783b3d6b37 Fix click behaviour
By the time seatop_allows_events was called, seatop_impl was already
NULL, causing the function to always return false. This means a press
event was sent to clients without a corresponding release event.

This patch moves the call to seatop_finish to after the
seatop_allows_events check.
2019-03-11 14:55:54 +01:00
Ryan Dwyer d16845d5f0 Don't send button events to surfaces when dragging or resizing
It turns out sending button events during all seat operations is not
desirable. This patch introduces a new property
`seatop_impl.allows_events` which allows each operation to define
whether button events should be passed to the surface or not.

The `down` seat operation is the only one that supports this. As all the
other seatops don't support it, the calls to seat_pointer_notify_button
prior to starting them have been removed.
2019-03-11 14:55:54 +01:00
Brian Ashworth 017a7c4da1 sway_view_child: add listener for view unmap
Since not all child views's have an unmap event, it is possible for it
to still be mapped (default state) in the destruction handler. When
the destruction handler is called, the corresponding view may have
already been freed and the memory location reallocated. This adds a
listener for the view unmapping and removes the mapped status. This
ensures that the child view is damaged due to destruction while the
view still exists and not after.
2019-03-11 10:02:52 +01:00
Brian Ashworth 20c4d242f6 detect_proprietary: use strncmp
Only the main nvidia module needs to be blocked. Others such as
nvidiafb are benign and do not need to be blocked
2019-03-10 22:16:09 -06:00
Brian Ashworth a729bda17f fullscreen: init floating on disable without size
If a container gets mapped as fullscreen and set to floating by
criteria, the size and location are never set for the floating
container. This adds a check in container_fullscreen_disable for a
width or height of 0 and calls container_init_floating
2019-03-10 23:55:22 +01:00
Ben Challenor 30931ad9e7
Make raw keysyms take precedence over translated
Allows both BackSpace and Shift+BackSpace to be bound under the US
keyboard layout, per #3705.
2019-03-10 23:01:49 +01:00
emersion 191305468c Fix crash in cmd_workspace when layer surface has focus 2019-03-10 14:59:34 -06:00
Drew DeVault 83b68b2154 Update language in sway.desktop & sway(1) 2019-03-10 15:09:52 -04:00
Brian Ashworth 9a75f0010f arrange: use int not size_t for title offsets
This changes `apply_tabbed_layout` and `apply_stacked_layout` to use
`int` instead of `size_t`. This is necessary for tabbed and stacked
containers to be positioned correctly when the y-location is negative.
The reasoning for this is signed plus unsigned is always an unsigned
value. This was causing the y-location of the container to be
positioned near `INT_MIN` due to an unsigned integer underflow
2019-03-10 13:07:32 -06:00
Brian Ashworth c02d2a0128 damage: remove output_damage_view
This removes `output_damage_view` since it is unnecessary. The logic
has been moved into its only caller `output_damage_from_view`. When
damaging the whole view, `output_damage_whole_container` should be used
instead
2019-03-10 01:23:03 +01:00
Brian Ashworth 7580718d12 output_damage_whole_container: damage subsurfaces
This adds an iterative call in `output_damage_whole_container` to
damage the subsurfaces for all visible views that are inside of the
container. This is needed to damage subsurfaces that extend outside the
box of the container. Without this, those subsurfaces will create
artifacts when moving or resizing.
2019-03-10 01:20:36 +01:00
Jeff Peeler a73e8f1328 fix "directive argument is null" errors 2019-03-09 14:59:28 -07:00
minus 5fab8a2ad4 Fix crash when moving window to scratchpad 2019-03-09 11:21:41 +01:00
Brian Ashworth 7f700e08ac ipc: describe libinput device configuration
This adds the device configurations to the ipc response for libinput
devices. Only supported configuration options for the device will be
added. This also moves `libinput_send_events` inside a new `libinput`
object that contains the rest of the configuration options. sway-ipc(7)
has been updated to reflect the changes and document the new additions.
2019-03-07 08:41:19 -07:00
Brian Ashworth 0df76ed96a ipc: fix fullscreen deco_rect
This fixes the deco_rect reported by the ipc for fullscreen containers
to be all zeroes. Children of the fullscreen container should still
have their decorations reported correctly
2019-03-06 10:49:45 -07:00
Brian Ashworth 8ada2daba5 ipc: fix rect for stacked children
This now takes all titlebars for stacked children into account for the
ipc property `rect`
2019-03-06 10:49:32 -07:00
emersion 8b6bd106aa Fix container_parent_layout for scratchpad windows 2019-03-06 11:50:23 -05:00
Brian Ashworth 19df2e5906 ipc: change {,deco_}rect to match i3
This fixes the `deco_rect` and `rect` properties in the IPC responses
to match i3's behavior.

`deco_rect` should be relative to the parent node, not the current
node. This also takes tabbed and stacked decorations into account and
will calculate `deco_rect` for all containers since tabbed and stacked
child containers will have decorations.

`rect` should exclude the window decorations.
2019-03-06 10:05:00 +01:00
emersion a6711740bc Set DISPLAY after initializing Xwayland
This is necessary after https://github.com/swaywm/wlroots/pull/1596
2019-03-04 21:16:00 +01:00
Ryan Dwyer bdac0df4f8 Allow concurrent clicks
If two cursor buttons are pressed at the same time, the client will now
be notified of the second button press.

The main reason for not sending the concurrent presses was due to an
early return in dispatch_cursor_button if a seatop is in progress. This
patch makes it call seat_pointer_notify_button prior to returning. But
it also has to make sure there's not a mismatch in events such as a
release without a press.

Prior to this patch, the down seatop would send press and release events
in its begin and finish functions. No other seatops did this. A press
event would be sent prior to starting tiling drag, but never an
associated release.

After this patch, no seatops send their own press or release events. We
send them prior to calling the seatop begin functions, then the first
part of dispatch_cursor_button handles all presses during seatops and
when releasing the seatop.
2019-03-04 07:51:22 -07:00
Brian Ashworth a053823f39 sway.1.scd: document environment vars set by sway
This just documents the few environment variables set by sway in
sway.1.scd
2019-03-03 18:47:32 +01:00
Brian Ashworth 23f075e71d render_floating: skip fullscreen floaters
If a floater is fullscreen either on a workspace or globally, it
should not be rendered on any output is is not fullscreened on. When
rendering it on an output it should not be rendered on, there will be
an extraneous border along the adjacent side of the output. This adds
a check in render_floating to skip all fullscreened floaters
2019-03-03 09:25:10 +01:00
Noam Preil 1c329f2fe6 Fixes crash in spawn_swaybg (closes #3733) 2019-03-03 01:08:05 +01:00
Brian Ashworth 430359519c floating_maximum_size: change default behavior
This changes the way zero (which is the default) is interpreted for both
the width and height of `floating_maximum_size`. It now refers to the
width and height of the entire output layout, which matches i3's
behavior.

This also removes duplicated code to calculate the floating constraints
in three files. Before this, `container_init_floating` used two-thirds
of the workspace width/height as the max and the entire workspace
width/height was used everywhere else. Now, all callers use a single
function `floating_calculate_constraints`.
2019-03-02 09:10:26 +01:00
hugbubby 37f0e1f1a2 Minor fix of code duplication.
Removes 3~ lines of code that didn't need to be restated.
2019-03-02 00:49:02 +01:00
emersion 88b283c557 seat: don't send button release when not pressed
All seat operations except "down" eat the button pressed event and don't send
it to clients. Thus, when ending such seat operations we shouldn't send the
button released event.

This commit moves the logic used to send pressed/released into the "down"
operation.
2019-02-28 23:02:06 -05:00
Brian Ashworth 56217bfbc0 sway-ipc.7: clarify window_rect omits decorations
According to the i3 ipc documentation, `window_rect` excludes the window
decorations from the calculation. This just clarifies that in
`sway-ipc.7.scd`
2019-02-27 22:11:58 -05:00
emersion 4431ae68fc Add output dpms to manpage 2019-02-27 16:33:03 -05:00
Drew DeVault 9f58b27d86
Merge pull request #3766 from RedSoxFan/sway-ipc-scdoc
Add sway-ipc.7.scd to document IPC protocol
2019-02-27 16:01:55 -05:00
Brian Ashworth f876009c7f Add sway-ipc.7.scd to document IPC protocol
This add `sway-ipc.7.scd` that documents the IPC protocol.

This also increased the minimum scdoc version from 1.8.1 to 1.9.0 to
allow for table cells to be continued on the following line
2019-02-27 13:23:10 -05:00
Rouven Czerwinski d016848bce config: remove double assignement to result in get_output_config 2019-02-27 00:35:51 -05:00
Rouven Czerwinski 4e028dba47 cursor: intitialize sx and sy to zero
If node_at_coords does an early return without setting these values, they can be
used uninitialized later. Initialize both to zero.
2019-02-27 00:35:51 -05:00
Rouven Czerwinski 35d610a43c cursor: remove unused node assignement
The node variable is not used before its reassigned later in the function,
remove the assignement.
2019-02-27 00:35:51 -05:00
Brian Ashworth efe370ba12 execute_command: do not strip qoutes for cmd_mode
`cmd_mode` performs its own quote stripping for the mode string to
avoid double stripping quotes for `cmd_bindcode` and `cmd_bindsym` in
`config_command` and `execute_command`. Stripping quotes in
`execute_command` for `cmd_mode` will also result in double stripping,
which will cause issues for any mode string with spaces, such as pango
markup.
2019-02-26 08:06:50 +01:00
Carlo Abelli b00b0fb9d3 fix smart_borders description in manual
The wording for smart_borders was opposite the actual behavior.
2019-02-25 14:52:29 -05:00
Connor E 9032be4f08 Allow 0 degree transform (normal transform). 2019-02-25 11:28:29 +01:00
Milkey Mouse 2f7247e08a swaybar: add overlay mode (fix #1620)
Overlay mode puts the bar above normal windows and passes through/ignores any
touch/mouse/keyboard events that would be sent to it.
2019-02-24 20:05:47 -05:00
db 2510e3df38 add --i3 flag to hide_edge_borders
Enables i3-compatible behavior regarding hiding the title bar on tabbed and
stacked containers with one child.

Related issues and merge requests: #3031, #3002, #2912, #2987.
2019-02-24 15:26:37 -05:00
Connor E d4b1e71b91 Make load_include_configs void. Fix some cases where WD would not be restored. 2019-02-24 00:01:35 -05:00
minus 713883f04c Fix crash exiting fullscreened floating container
container_floating_move_to_center and container_fullscreen_disable were
calling recursively when the container spawned as a fullscreen floating
container (via for_window). Such a window now doesn't crash sway anymore
but is still configured with a wrong, zero size, making it not directly
usable.
2019-02-23 21:40:03 -05:00
Caleb Bassi f84ac3f114 ipc: add missing fields to disabled outputs
i3 requires all outputs to have certain fields, including 'primary', 'current_workspace', and 'rect' which were missing on disabled outputs.

https://i3wm.org/docs/ipc.html#_outputs_reply
2019-02-23 20:27:59 +01:00
emersion 656541bcc4
Update for swaywm/wlroots#1517 2019-02-23 19:04:10 +01:00
Brian Ashworth 9350a52c0e handle_seat_node_destroy: update seat->workspace
If an unmanaged or layer surface is focused when an output gets
disabled and an empty workspace on the output was focused by the seat,
the seat needs to refocus it's focus inactive to update the value of
`seat->workspace`.
2019-02-23 09:21:19 +01:00
Brian Ashworth bcec866c6b handle_layer_shell_surface: do not use noop output
If the noop output is focused (all other outputs disabled/disconnected),
do not auto assign a layer surface to it. The noop output is not enabled
and does not have the `output->layers` list initialized. It also does
not make sense to map the layer surfaces to something that is not
visible.
2019-02-23 09:15:35 +01:00
Rouven Czerwinski 3ead287064 view: set xdg_decoration->view to NULL, check decoration destroy
Fixes heap-use-after-free:

==32046==ERROR: AddressSanitizer: heap-use-after-free on address 0x615000064d20 at pc 0x55571ce4d303 bp 0x7fff545c64c0 sp 0x7fff545c64b0
WRITE of size 8 at 0x615000064d20 thread T0
    #0 0x55571ce4d302 in xdg_decoration_handle_destroy ../sway/xdg_decoration.c:13
    #1 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #2 0x7f64009d3c46 in toplevel_decoration_handle_resource_destroy ../types/wlr_xdg_decoration_v1.c:65
    #3 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)
    #4 0x7f6400a19fed in wl_resource_destroy (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7fed)
    #5 0x7f64009d3d1f in toplevel_decoration_handle_surface_destroy ../types/wlr_xdg_decoration_v1.c:82
    #6 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #7 0x7f64009b059c in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:453
    #8 0x7f64009b0688 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:483
    #9 0x7f64009af08c in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #10 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)
    #11 0x7f6400a1e211  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0xc211)
    #12 0x7f6400a1e6fe  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0xc6fe)
    #13 0x7f6400a1a0ec in wl_client_destroy (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x80ec)
    #14 0x7f6400a1a1c4  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x81c4)
    #15 0x7f6400a1b941 in wl_event_loop_dispatch (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x9941)
    #16 0x7f6400a1a569 in wl_display_run (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x8569)
    #17 0x55571ce4c7fd in server_run ../sway/server.c:214
    #18 0x55571ce4ad59 in main ../sway/main.c:405
    #19 0x7f640071109a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #20 0x55571ce2cfa9 in _start (/usr/local/bin/sway+0x35fa9)

0x615000064d20 is located 32 bytes inside of 504-byte region [0x615000064d00,0x615000064ef8)
freed by thread T0 here:
    #0 0x7f6401531b70 in free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedb70)
    #1 0x55571ce6c72b in destroy ../sway/desktop/xdg_shell.c:252
    #2 0x55571cee3f7b in view_destroy ../sway/tree/view.c:60
    #3 0x55571cee4090 in view_begin_destroy ../sway/tree/view.c:73
    #4 0x55571ce6dd95 in handle_destroy ../sway/desktop/xdg_shell.c:464
    #5 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #6 0x7f64009b059c in reset_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:453
    #7 0x7f64009b0688 in destroy_xdg_surface ../types/xdg_shell/wlr_xdg_surface.c:483
    #8 0x7f64009af08c in xdg_client_handle_resource_destroy ../types/xdg_shell/wlr_xdg_shell.c:71
    #9 0x7f6400a19f8d  (/usr/lib/x86_64-linux-gnu/libwayland-server.so.0+0x7f8d)

previously allocated by thread T0 here:
    #0 0x7f6401532138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
    #1 0x55571ce6df39 in handle_xdg_shell_surface ../sway/desktop/xdg_shell.c:485
    #2 0x7f64009d6f36 in wlr_signal_emit_safe ../util/signal.c:29
    #3 0x7f64009b0167 in handle_xdg_surface_commit ../types/xdg_shell/wlr_xdg_surface.c:350
    #4 0x7f64009ce2a5 in surface_commit_pending ../types/wlr_surface.c:372
    #5 0x7f64009ce523 in surface_commit ../types/wlr_surface.c:444
    #6 0x7f63ff63ddad in ffi_call_unix64 (/usr/lib/x86_64-linux-gnu/libffi.so.6+0x5dad)

Fixes #3759
2019-02-23 03:03:03 -05:00
Brian Ashworth f078a1ccb8 input/cursor: allow whole-window bindings on ws
To match i3's behavior, this allows mouse bindings to be triggered over
a workspace when `--whole-window` is given.
2019-02-22 13:32:34 +01:00
Ian Fan 923cd865f5
Merge pull request #3740 from Emantor/fix/ipc_allocs
Fix small memory leaks reported in #3658
2019-02-22 08:20:26 +00:00
Brian Ashworth 7252ca09a7 move scratchpad: hide visible scratchpad container
This makes it so running `move [to] scratchpad` on a container already
in the scratchpad does not return an error. To match i3's behavior, a
visible scratchpad container will be hidden and a hidden scratchpad
container will be treated as a noop.
2019-02-22 08:13:51 +01:00
Rouven Czerwinski 16ddd00102 commands/move: reintroduce wrongly removed NULL check
Commit d3d7956576 removed this NULL check, which
leads to the following backtrace:

  #0  0x0000557bd201df46 in node_is_view (node=0x0) at ../sway/sway/tree/node.c:41
  #1  0x0000557bd1ff5d4e in seat_get_focus_inactive (seat=0x557bd3fc7580, node=0x0) at ../sway/sway/input/seat.c:968
          current = 0x557bd2033485
  #2  0x0000557bd2009f24 in cmd_move_container (argc=3, argv=0x557bd46b19c0) at ../sway/sway/commands/move.c:557
          new_output_last_focus = 0x0
          error = 0x0
          node = 0x557bd469f360
          workspace = 0x557bd4572ee0
          container = 0x557bd469f360
          no_auto_back_and_forth = false
          seat = 0x557bd3fc7580
          old_parent = 0x0
          old_ws = 0x557bd4572ee0
          old_output = 0x557bd411f740
          destination = 0x557bd46a0cc0
          new_output = 0x557bd411f740
          new_output_last_ws = 0x0
          focus = 0x557bd469f360
          __PRETTY_FUNCTION__ = "cmd_move_container"
          new_workspace = 0x557bd4572ee0
  […]

Reintroduce the NULL check to fix the bug.

Fixes #3746
2019-02-22 00:52:57 -05:00
Brian Ashworth d3d7956576 Handle NULL from output_get_active_workspace
This modifies the places where output_get_active_workspace is called to
handle a NULL result. Some places already handled it and did not need a
change, some just have guard off code blocks, others return errors, and
some have sway_asserts since the case should never happen. A lot of this
is probably just safety precautions since they probably will never be
called when `output_get_active_workspace` is not fully configured with a
workspace.
2019-02-21 21:18:03 +01:00
Brian Ashworth 03dfdb1edb output_get_active_workspace: check workspaces length
If an output's node was dirty and the transaction was committed before a
workspace was moved to or created for the output, the instruction would
have a bad value for `state->active_workspace` due to a missing
length check in `output_get_active_workspace`. If there was no focus on
the output, the first workspace was being returned. If the workspace
list was currently empty, the value was either garbage, or in the case of
an output being disabled and re-enabled, a workspace that may have been
previously freed. This just adds the length check to avoid returning out
of bounds value.
2019-02-21 08:06:35 -05:00
Rouven Czerwinski aa4ccd845c run_as_ipc_client: free response after running the IPC command
Fixes memory leaks in the form of:

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c799569f2 in ipc_recv_response ../common/ipc-client.c:94
    #2 0x563c79957062 in ipc_single_command ../common/ipc-client.c:138
    #3 0x563c798a56cc in run_as_ipc_client ../sway/main.c:127
    #4 0x563c798a6a3a in main ../sway/main.c:349
    #5 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:32:55 +01:00
Rouven Czerwinski a968a650e2 ipc-client: free payload after sending it over the socket
Fixes memory leaks in the form of:

Direct leak of 20 byte(s) in 1 object(s) allocated from:
    #0 0x7f5f7c2f4f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
    #1 0x563c7995b36a in join_args ../common/stringop.c:268
    #2 0x563c798a6a1a in main ../sway/main.c:348
    #3 0x7f5f7b4d609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
2019-02-21 11:31:05 +01:00
Brian Ashworth 546b976baa output_evacuate: call workspace_consider_destroy
This calls `workspace_consider_destroy` on the workspace that was
visible on an output that a workspace was just evacuated to. This
prevents having hidden empty workspaces.
2019-02-20 20:17:45 +01:00
emersion 444e00662c
Add wp-primary-selection-unstable-v1 2019-02-20 11:16:05 +01:00
Eric Drechsel 9bbf10bdfc layout cmd: always operate on parent container, like i3Fixes #3724 2019-02-19 10:50:49 -05:00
emersion b799a30962 Don't use SOCK_CLOEXEC
Manually set the CLOEXEC flag instead, since SOCK_CLOEXEC isn't POSIX.
2019-02-19 16:34:07 +01:00
Drew DeVault c939453bea
Merge pull request #3714 from emersion/fix-drag-icon-map-listener
Fix drag icon map listener not removed
2019-02-18 15:29:07 -05:00
Yorick van Pelt fc397f52bb
Add 'visible' key to view json response 2019-02-18 13:57:16 +01:00
emersion 59f2056022
Fix drag icon map listener not removed 2019-02-18 13:19:58 +01:00
Drew DeVault a1e171080d
Merge pull request #3712 from RedSoxFan/fix-typo-seat-cursor
seat_cmd_cursor: fix typo in expected syntax
2019-02-18 05:18:46 +01:00
Brian Ashworth 041594d2ab Use container under cursor for mouse bindings
This matches i3's behavior of executing mouse bindings in regards to the
container under the cursor instead of what is focused.
2019-02-17 20:33:37 -05:00
Brian Ashworth 73c8e63438 seat_cmd_cursor: fix typo in expected syntax
This just fixes a typo in the expected syntax for seat_cmd_cursor
2019-02-17 20:16:23 -05:00
Brian Ashworth faf15ee733 workspace_next_name: fallback to next available number
This changes `workspace_next_name` to use the next available number as
the workspace name instead of the number of outputs. This fixes the case
where a number that is already in use could be returned. The workspace
numbers in use have no relation to the number of outputs so it makes
more sense to use the lowest available number
2019-02-17 19:15:19 +01:00