Commit graph

5876 commits

Author SHA1 Message Date
Brian Ashworth 9099adbbe6 swaynag: revamp type configs
This revamps the type configs for swaynag. All sizing attributes for
swaynag are now `ssize_t` instead of `uint32_t` to allow for a default
value of `-1`, which allows for `0` to be a valid value. Additionally,
the initialization of the type configs has been changed from a simple
calloc to use a new function `swaynag_type_new`. `swaynag_type_new`
calloc's the memory, checks for an allocation failure, sets the name,
and all sizes to -1. The layering order has also been changed to
default, general config, type config, and as highest priority command
line arguments. Finally, `swaynag_type_merge` has been modified to
handle the layering and sizing changes.
2019-04-20 09:14:41 -06:00
Brian Ashworth 59d9a991b4 ipc: fix criteria for emitting bar_state_update
This fixes the criteria for emitting a `bar_state_update` event to
notify swaybar (and any other bars utilizing the event) on whether the
bar is visible by modifier. It is not enough to only emit the event
when both the bar mode and bar hidden state are `hide` since it is
possible to release the modifier while hidden state is `show` and then
change hidden state to `hide` without pressing the modifier. This also
emits the event whenever visible by modifier is set and should no
longer be regardless of the mode and state to ensure that it gets
properly cleared. If visible by modifier is not set and the bar is not
in `hide`/`hide`, then no events will be sent and visible by modifier
will not be set
2019-04-20 09:09:11 -06:00
Brian Ashworth 09595da0bc cmd_move: allow for all i3 syntax options
This modifies cmd_move to allow for the syntax options allowed by i3.
The following syntaxes are supported:
- `move left|right|up|down [<amount> [px]]`
- `move [--no-auto-back-and-forth] [window|container] [to] workspace
   <name>|next|prev|next_on_output|prev_on_output|current|number <num>`
- `move [window|container] [to] output <name/id>|left|right|up|down`
- `move [window|container] [to] mark <mark>`
- `move workspace to [output] <name/id>|left|right|up|down`
- `move [window|container] [to] [absolute] position <x> [px] <y> [px]`
- `move [window|container] [to] [absolute] position center`
- `move [window|container] [to] position mouse|cursor|pointer`

This also allows retains the following syntax option that is not
supported by i3, but is supported in sway 1.0:
- `move workspace [to] output <name/id>|left|right|up|down`

The changes are:
- `window` and `container` are now optional
- `output` is now optional for `move workspace` when `to` is given

There is also stricter command checking now. If `absolute` or
`--no-auto-back-and-forth` are given for commands that do not support
them, it will be treated as invalid syntax instead of being silently
ignored.
2019-04-19 08:39:57 -06:00
mwenzkowski 5e925f06e0 hide_edge_borders.c: add missing case for --i3
Disable the i3-compatible behavior if the option '--i3' is not given.
Previously it was only possible to disable it by changing the config
file. Now it also works via swaymsg.
2019-04-19 00:05:49 +03:00
Alex Maese 35ddd9aab3 Add unbindsym/unbindcode command for swaybar 2019-04-17 23:29:43 -04:00
Alex Maese 8d4f8aea46 Add unbindswitch command 2019-04-17 23:29:43 -04:00
Alex Maese 852f1f0b34 Create unbindsym and unbindcode commands 2019-04-17 23:29:43 -04:00
Brian Ashworth d7d29fe546 swaymsg: add timeout and type checks
This adds a 3 second timeout to the initial reply in swaymsg. This
prevents swaymsg from hanging when `swaymsg -t get_{inputs,seats}` is
used in i3. The timeout is removed when waiting for a subscribed event
or monitoring for subscribed events.

This also adds type checks to commands where i3 does not reply with all
of the properties that sway does (such as `modes` in `get_outputs`).

This is mostly just a behavioral adjustment since swaymsg should run on
i3. When running under i3, some command reply's (such as the one for
`get_outputs) may have more useful information in the raw json than the
pretty printed version.
2019-04-17 09:07:08 +03:00
Ashkan Kiani aa4deef8a8 Fix the payload type returned by IPC
If a client is subscribed and sends a subsequent ipc command which
causes event updates, then those event updates override the
`client->current_command` and send the incorrect type for the payload
associated with the command.

Example:

SUBSCRIBE {window}
RUN_COMMAND focus -> PAYLOAD_TYPE is 0x80000002 for window events

Therefore, we decouple the `client->current_command` by passing it as an
argument to the ipc_send_reply function, avoiding a data race. The same
is done for the `client->payload_length` as a precautionary measure for
the same reason.
2019-04-16 23:48:44 -04:00
mwenzkowski 9ac2342a67 Don't apply hide_edge_borders to floating windows
This change matches i3's behavior.
2019-04-16 17:05:49 -04:00
mwenzkowski e9e1fbc501 view.c: refactor view_autoconfigure() 2019-04-16 17:05:49 -04:00
Ashkan Kiani 2f9eed659d Add documentation for rename workspace 2019-04-16 07:34:07 -06:00
Ranieri Althoff fd6903673b Send disabled output available modes on IPC get_outputs
- Also fix missing trailing newline on pretty print

Signed-off-by: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com>
2019-04-16 00:16:20 -04:00
Connor E b2cfcebef6 Add deprecation warnings for new_float, new_window, and force_focus_wrapping. 2019-04-14 20:44:12 -04:00
Benjamin Cheng bd3720585e Implement input type configs (#3784)
Add support for configurations that apply to a type of inputs
(i.e. natural scrolling on all touchpads). A type config is
differentiated by a `type:` prefix followed by the type it
corresponds to.

When new devices appear, the device config is merged on top of its
type config (if it exists). New type configs are applied on top of
existing configs.
2019-04-14 19:31:36 -04:00
Benjamin Cheng 6737b90cb9 Add heuristics to differentiate touchpads
Use libinput_device_config_tap_get_finger_count to determine whether
a pointer is a touchpad.

swaymsg is also updated to reflect the new touchpad type.
2019-04-14 19:31:36 -04:00
Brian Ashworth 6961bf2e4c Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and
swaybg are already done
2019-04-14 12:41:59 +03:00
Brian Ashworth 8c69da11bb swaynag: fix pointer management
Currently on master, swaynag will retrieve a pointer instance whenever
the capabilities change and WL_SEAT_CAPBILITY_POINTER is set. The
pointer instances were never being destroyed so swaynag received events
multiple times due to having several instances of the pointer.

This fixes it so if there is already a pointer instance, swaynag does
not attempt to retrieve another. Additionally, if the pointer
capability is removed, the pointer instance is destroyed.
2019-04-14 10:24:19 +03:00
Brian Ashworth 69a1a0ff99 Fix scratchpad fullscreen behavior and crash
When setting fullscreen on a hidden scratchpad container, there was a
check to see if there was an existing fullscreen container on the
workspace so it could be fullscreen disabled first. Since the workspace
is NULL, it would cause a SIGSEGV. This adds a NULL check to avoid the
crash.

This also changes the behavior of how fullscreen is handled when adding
a container to the scratchpad or changing visibility of a scratchpad
container to match i3's. The behavior is as follows:
- When adding a container to the scratchpad or hiding a container back
  into the scratchpad, there is an implicit fullscreen disable
- When setting fullscreen on a container that is hidden in the
  scratchpad, it will be fullscreen when shown (and fullscreen disabled
  when hidden as stated above)
- When setting fullscreen global on a container that is hidden in the
  scratchpad, it will be shown immediately as fullscreen global. The
  container is not moved to a workspace and remains in the
  scratchpad. The container will be visible until fullscreen disabled
  or killed. Since the container is in the scratchpad, running
  `scratchpad show` or `move container to scratchpad` will have no
  effect

This also changes `container_replace` to transfer fullscreen and
scratchpad status.
2019-04-13 08:48:37 -06:00
Ashkan Kiani 913445e112 Fix potential null accesses 2019-04-13 08:35:17 -06:00
Simon Ser e7d6b8ec3e swaybg: add manpage 2019-04-13 10:26:17 -04:00
Ashkan Kiani 27f51360b7 Fix scratchpad logic for floating windows
When a tiled window is sent to the scratchpad, we want to use sane
defaults, which is to center it and resize it to the default.

For floating windows, we want to use their existing geometry.
2019-04-12 16:52:24 -04:00
Martin Michlmayr 090e101581 sway-input.5: add xkeyboard-config(7) to "see also"
Since xkeyboard-config(7) is mentioned in the man page, add a reference
to the "see also" section.
2019-04-12 21:45:13 +03:00
Brian Ashworth bd4c3957ba cmd_focus: raise floating for <criteria> focus
Floaters are currently raised for `focus <direction>`. This extends the
same functionality to `<criteria> focus`.
2019-04-11 09:19:45 -06:00
Brian Ashworth 195226120f Honor output for xdg_toplevel_set_fullscreen
This honors the fullscreen output request for
`xdg_toplevel_set_fullscreen` and `zxdg_toplevel_v6_set_fullscreen`.

If the request was sent before mapping, the fullscreen output request
will be retrieved from the client_pending state for the toplevel. The
output will be passed to `view_map` and if there is a workspace on the
output, the view will be placed on that workspace.

If the request comes in after being mapped, the view will be moved to
the workspace on the output (if there is one) before becoming
fullscreen.
2019-04-11 09:18:48 -06:00
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
Dmitri Kourennyi 4b892a79aa Add margin to short_text handling.
Add a 3xscale margin matching other spacing in swaybar as part of short
text width calculations
2019-04-04 14:14:08 -06:00
Dmitri Kourennyi 94dc57f3c5 Ensure predicted position for short text handling doesn't overflow.
- Predicted status line can be negative, so corresponding variables should
  not be unsigned. Changed to double as position is actually calculated as
  double.
2019-04-04 14:14:08 -06:00
Dmitri Kourennyi 0553e75b53 Implement handling of short_text field of i3 input protocol.
Matches i3bar behavior of setting all blocks to use the short_text if the full
text width does not fit.
2019-04-04 14:14:08 -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
Dacheng Gao 1e1d9e1299 fix broken link to README.zh-CN.md 2019-04-02 10:35:21 +03:00
Dacheng Gao 5e0a928201 fix typo 2019-04-02 08:42:10 +03:00
Drew DeVault f3140506a8 Update formatting of zh-cn link in README.md 2019-04-01 10:56:56 -04:00
Dacheng Gao 4938da2a34 add link to README-zh-CN 2019-04-01 08:55:49 -06:00
Dacheng Gao 078935ac88 fix cs 2019-04-01 08:55:49 -06:00
Dacheng Gao 3353bb5832 fix cs 2019-04-01 08:55:49 -06:00
Dacheng Gao a32125c984 add chinese translation 2019-04-01 08:55:49 -06: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
Alex Maese 31eeda11b0 Fix a crash in swaybar when an icon dir is not readable 2019-03-30 20:13:34 +02: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
Igor Sviatniy e9d096468a Update README.uk.md 2019-03-26 07:25:02 -06: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
Philz69 c3d7036867 Updated the french readme (#3964)
* Updated the french readme

Removed the image at the start of the readme.
Removed the mention of bounties.
Updated the dependencies.
Removed a few lines that were not present in the english readme anymore.

* Fix errors.

Fixed capitalisation.
Changed "root" to italics.
2019-03-24 21:19:13 +02:00