Commit graph

152 commits

Author SHA1 Message Date
Connor E 4bd46fb079 Implement strip_workspace_name. 2018-11-17 16:11:28 +00:00
Ryan Dwyer be9348d25c Move view {x,y,width,height} into container struct
This renames/moves the following properties:

* sway_view.{x,y,width,height} ->
sway_container.content_{x,y,width,height}
    * This is required to support placeholder containers as they don't
    have a view.
* sway_container_state.view_{x,y,width,height} ->
sway_container_state.content_{x,y,width,height}
    * To remain consistent with the above.
* sway_container_state.con_{x,y,width,height} ->
sway_container_state.{x,y,width,height}
    * The con prefix was there to give it contrast from the view
    properties, and is no longer useful.

The function container_set_geometry_from_floating_view has also been
renamed to container_set_geometry_from_content.
2018-11-17 21:29:42 +10:00
Harish Krupo d8ad429e39 IPC: Send keyboard layout info in IPC_GET_INPUTS
Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
2018-11-12 22:00:22 +05:30
Cole Mickens ef888321ba ipc: move refresh from output to output->current_mode 2018-11-03 15:09:34 -07:00
Cole Mickens 71686ed0e7 fix: restore refresh to the modes_array 2018-11-03 15:09:34 -07:00
Cole Mickens d05aeb77a0 sway-ipc: includes current_mode for each output 2018-11-03 04:30:49 -07:00
Ryan Dwyer 9fc736f4e1 Move view marks properties to container struct
Like border properties, this will be needed to implement layout saving
and restoring.
2018-11-01 18:09:51 +10:00
Franklin "Snaipe" Mathieu 03ca8596d6 ipc: make class, instance, and title window properties optional
i3 seems to make all window properties, with the exception of
transient_for, optional[1].

[1]: 315ff17563/src/ipc.c (L435-L450)

Signed-off-by: Franklin "Snaipe" Mathieu <snaipe@diacritic.io>
2018-10-27 18:41:26 +01:00
Franklin "Snaipe" Mathieu 259fe1e76f ipc: remove class key from view json
It turns out that i3 does not have a `class` key in the json description
of a view, but provides it through `window_properties.class`. Since
`window_properties` has been added by 8fc9328, we can remove `class`
altogether.

Signed-off-by: Franklin "Snaipe" Mathieu <snaipe@diacritic.io>
2018-10-27 18:39:17 +01:00
Franklin "Snaipe" Mathieu 8fc9328334 xwayland: populate window_properties in json for views
window_properties is documented to contain a subset of the X11 properties
of a window (its title, class, instance, role, and transient ID). This
commit adds the missing json object from the get_tree output for
xwayland windows only.

This is a follow-up of #2911.

Signed-off-by: Franklin "Snaipe" Mathieu <me@snai.pe>
2018-10-23 19:10:50 +01:00
Ryan Dwyer c006717910 Minor refactor of input manager
The input manager is a singleton object. Passing the sway_input_manager
argument to each of its functions is unnecessary, while removing the
argument makes it obvious to the caller that it's a singleton. This
patch removes the argument and makes the input manager use server.input
instead.

On a similar note:

* sway_input_manager.server is removed in favour of using the server
global.
* seat.input is removed because it can get it from server.input.

Due to a circular dependency, creating seat0 is now done directly in
server_init rather than in input_manager_create. This is because
creating seats must be done after server.input is set.

Lastly, it now stores the default seat name using a constant and removes
a second reference to seat0 (in input_manager_get_default_seat).
2018-10-20 13:11:43 +10:00
Brian Ashworth 1c969e86f5 Implement bar bindsym 2018-10-09 08:12:46 -04:00
Ryan Dwyer 41bfd8c790 swaybar: allow null status_command
Sway sets a default status_command which runs date every second. This
patch removes this behaviour so the user can have a NULL status bar if
desired.

I had to swap swaybar's event_loop_poll and wl_display_flush so that it
would map the initial surface.
2018-10-08 22:23:55 +10:00
Ian Fan 2cda0b1fe1 ipc: set "type" of floating containers to "floating_con" 2018-10-06 18:11:05 +01: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
Arkadiusz Hiler 1e70f7b19e Turn funcs() into funcs(void)
If they really do not take undefined number of arguments.
2018-09-30 14:09:05 +03: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
Ian Fan 81f3fda6fa ipc: add pid information for views in layout tree 2018-09-19 22:21:09 +01:00
Ian Fan 34dbbb1314 ipc: handle NULL cases for node_get_output 2018-09-15 09:42:49 +01:00
Ian Fan 1c292fd43a ipc: add focus information to root node 2018-09-15 09:42:49 +01:00
Armin Preiml 7919ae5e44 code style fixes 2018-09-08 13:24:01 +02:00
Armin Preiml 2dec0d894b get_tree: percent cast to double on division 2018-09-08 13:24:01 +02:00
Armin Preiml 79eaa26b3e get_tree: default values
Added default values for all nodes, because the i3 get_tree always returns
all fields inside the json objects.

Add geometry and window for views. Window is only availabel on
x11 windows otherwise it's NULL.

Calculate percent only if parent is not empty to avoid division by 0.
2018-09-08 13:24:01 +02:00
Armin Preiml 3d8c3e560b missing ipc stuff: rebase to typesafety 2018-09-08 13:24:01 +02:00
Ryan Dwyer 3133d0c03c Fix swaybars with no defined output 2018-09-05 18:01:43 +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
vilhalmer 03718aaebb
Add app_id and class to get_tree output 2018-08-21 20:51:01 -04:00
Ryan Dwyer 2b5a404ac9 Replace hacky L_FLOATING container with a list
Workspaces previously had a magical `workspace->floating` container,
which had a layout of L_FLOATING and whose children were actual floating
views. This allowed some conveniences, but was a hacky solution because
the container has to be exempt from focus, coordinate transactions with
the workspace, and omit emitting IPC events (which we didn't do).

This commit changes it to be a list directly in the sway_workspace. The
L_FLOATING layout is no longer used so this has been removed as well.

* Fixes incorrect check in the swap command (it checked if the
containers had the L_FLOATING layout, but this layout applied to the
magical container).
* Introduces workspace_add_floating
2018-08-19 16:18:33 +10:00
Ian Fan 317217f2c8 ipc: add window::mark event 2018-08-01 16:57:15 +01:00
Ryan Dwyer be28c18ad5 Mark containers as urgent in IPC if they have urgent views 2018-07-16 14:30:31 +10:00
Ryan Dwyer 5f0a4bb6a4 Update workspace urgent state when views close or move workspaces 2018-07-16 13:15:35 +10:00
Ryan Dwyer 64e3bc3ab0 Fix crash in ipc_json_describe_view
I didn't expect a function called ipc_json_describe_view to be passed a
container which wasn't a view :\
2018-07-16 11:55:53 +10:00
Ryan Dwyer f86087d78f Fix urgency IPC events 2018-07-16 08:19:25 +10:00
Ryan Dwyer 315d5311b2 Implement urgency base functionality
Introduces a command to manually set urgency, as well as rendering of
urgent views, sending the IPC event, removing urgency after focused for
one second, and matching urgent views via criteria.
2018-07-16 08:19:25 +10:00
Ian Fan 23c1c26c3f Add get_config message type to ipc 2018-07-10 12:37:37 +01:00
emersion 88cd7616db
Fix compilation errors related to disabled outputs 2018-06-09 11:38:16 +01:00
Brian Ashworth a1b5b93d29 Store sway_outputs so that they can be reenabled 2018-06-06 20:11:24 -04:00
Ryan Dwyer 34f35f0bad Use L_FLOATING instead of reapable boolean 2018-06-01 23:14:58 +10:00
Ryan Dwyer 1f2e399ade Implement floating 2018-06-01 23:14:58 +10:00
Drew DeVault 1132efe42e Send frame done to floating views
Also centers them on the screen when initially floated

In the future we'll need a more sophisticated solution than that
2018-06-01 23:14:58 +10:00
Brian Ashworth 64225b1137 Send IPC layout of node itself 2018-05-29 21:45:18 -04:00
Brian Ashworth f5e44d4b2c Fix layout in -t get_tree 2018-05-29 11:21:55 -04:00
Ryan Dwyer 6f4cb2b29d Add tree representation to IPC workspace description 2018-05-29 17:42:11 +10:00
Ryan Dwyer c72940837c Implement IPC get_seats command 2018-05-12 18:17:36 +10:00
Ryan Dwyer ae39d7b28c Remove sway_container.workspace_layout
Fixes #1716.
2018-04-26 10:14:18 +10:00
Tony Crisci 0ff22c1755 implement ipc focus stack 2018-04-07 16:23:53 -04:00
Drew DeVault 640232eb22
Revert "Break everything^W^WUse wlr_box for sway_container" 2018-04-06 16:13:26 -04:00
Drew DeVault 764489e737 Break everything^W^WUse wlr_box for sway_container 2018-04-06 15:38:37 -04:00
emersion c2b1beef15
Remove L_TYPES 2018-04-05 23:22:08 -04:00
Tony Crisci 6b308dbeb7 address feedback 2018-04-05 22:50:10 -04:00
Tony Crisci bbfc5487bc add layout to ipc containers 2018-04-05 17:33:35 -04:00
Tony Crisci 04ce09630c add type to container json 2018-04-04 22:41:05 -04:00
Tony Crisci 0828c77251 rename input-manager functions 2018-04-02 08:49:38 -04:00
Tony Crisci e677c5b204 rename seat functions 2018-04-02 08:45:37 -04:00
Drew DeVault b28e6d2369 IPC fixes 2018-03-30 13:56:31 -04:00
Drew DeVault f26ecd9f58 Merge remote-tracking branch 'origin/wlroots' into swaybar-layers 2018-03-30 00:04:04 -04:00
Tony Crisci dc8c9fbeb6 Revert "Merge pull request #1653 from swaywm/revert-1647-refactor-tree"
This reverts commit 472e81f35d, reversing
changes made to 6b7841b11f.
2018-03-29 23:41:33 -04:00
Drew DeVault d0c7f66e95
Revert "Refactor tree" 2018-03-29 23:29:29 -04:00
Drew DeVault 6836074fed Implement enough IPC for swaybar to work 2018-03-29 22:11:08 -04:00
Tony Crisci b90099b4b7 rename container functions 2018-03-29 16:40:40 -04:00
Tony Crisci 874f009866 move tree includes to their own directory 2018-03-29 14:21:42 -04:00
emersion 4ab5506064
ipc: add output modes 2018-03-12 13:48:42 +01:00
Tony Crisci ad879c99e0 ipc show focused container 2018-02-26 19:07:59 -05:00
Tony Crisci 93084c9cf8 remove old focus member 2018-02-10 19:53:50 -05:00
Tony Crisci f2985000f3 ipc get_inputs 2017-12-18 14:27:38 -05:00
emersion 4e2ab53119
Add IPC get_outputs 2017-12-18 14:06:03 +01:00
Tony Crisci 421f49fe03 basic get_tree 2017-12-03 08:33:52 -05:00
Drew DeVault 7753a0ec75 Wire up IPC server 2017-11-22 21:37:07 -05:00
Drew DeVault 733993a651 Move everything to sway/old/ 2017-11-18 11:22:02 -05:00
Drew DeVault 1efd5f819f Wire up output frame loop 2017-11-11 14:41:18 -05:00
Drew DeVault 7eafcc75f6 Initialize outputs from backend and add to tree 2017-11-11 11:58:43 -05:00
Drew DeVault 46e5aeac50 Fix crash on swaygrab with scratchpad populated
Fixes #1217
2017-10-08 10:48:33 -04:00
lbonn fd7c4bacbd ipc/tree: populate focus fields
Ids of children, by order of focus
2017-10-08 11:51:03 +02:00
lbonn 661625b29e ipc/tree: output mandatory fields for all nodes
Still missing: focus
2017-10-08 11:51:03 +02:00
Calvin Lee 843ad38b3c Implement Tray Icons
This commit implements the StatusNotifierItem protocol, and enables
swaybar to show tray icons. It also uses `xembedsniproxy` in order to
communicate with xembed applications.
The tray is completely optional, and can be disabled on compile time
with the `enable-tray` option. Or on runtime with the bar config option
`tray_output none`.

Overview of changes:
In swaybar very little is changed outside the tray subfolder except
that all events are now polled in `event_loop.c`, this creates no
functional difference.

Six bar configuration options were added, these are detailed in
sway-bar(5)

The tray subfolder is where all protocol implementation takes place and
is organised as follows:

tray/sni_watcher.c:
	This file contains the StatusNotifierWatcher. It keeps track of
	items and hosts and reports when they come or go.
tray/tray.c
	This file contains the StatusNotifierHost. It keeps track of
	sway's version of the items and represents the tray itself.
tray/sni.c
	This file contains the StatusNotifierItem struct and all
	communication with individual items.
tray/icon.c
	This file implements the icon theme protocol. It allows for
	finding icons by name, rather than by pixmap.
tray/dbus.c
	This file allows for asynchronous DBus communication.

See #986 #343
2017-06-07 17:49:16 -07:00
Sebastian Noack 173b338567 Add -DVERSION flag for release version numbers 2017-04-26 15:56:46 +02:00
Jerzi Kaminsky b463fb8adc Remain compat with libinput < 1.7.0 2017-04-14 02:30:41 +03:00
Drew DeVault 60ce81e06a Add pretty printing to swaymsg
If stdout is a tty, it will pretty print unless -r (--raw) is given.

Sample outputs:

```
~/s/s/build > ./bin/swaymsg fullscreen toggle
Error: Permission denied for fullscreen toggle via IPC

~/s/s/build > ./bin/swaymsg -t get_workspaces
Workspace 3:三
  Output: DVI-I-1
  Layout: splith

Workspace 1:一 (off-screen)
  Output: HDMI-A-1
  Layout: splith

Workspace 5:五 (focused)
  Output: HDMI-A-1
  Layout: splith

~/s/s/build > ./bin/swaymsg -t get_inputs
Input device Metadot - Das Keyboard Das Keyboard
  Type: Keyboard
  Sway ID: 9456:320:Metadot_-_Das_Keyboard_Das_Keyb

Input device Wacom Intuos S 2 Pen
  Type: Tablet tool
  Sway ID: 1386:827:Wacom_Intuos_S_2

Input device Wacom Intuos S 2 Pad
  Type: Tablet pad
  Sway ID: 1386:827:Wacom_Intuos_S_2

Input device Logitech Gaming Mouse G502
  Type: Keyboard, Mouse
  Sway ID: 1133:49277:Logitech_Gaming_Mous

~/s/s/build > ./bin/swaymsg -t get_outputs
Output DVI-I-1
  Geometry: 1920x1080 @ 3840,0
  Scale factor: 1x
  Workspace: 3:三

Output DVI-D-1
  Geometry: 1920x1080 @ 0,0
  Scale factor: 1x
  Workspace: 4:四

Output HDMI-A-1
  Geometry: 1920x1080 @ 1920,0
  Scale factor: 1x
  Workspace: 5:五
```
2017-04-03 07:27:25 -04:00
Mykyta Holubakha e714fbcbec Add window instance support 2017-01-19 03:14:59 +02:00
Hummer12007 d59af31256 Fix workspace layouts in json data 2017-01-06 01:28:36 +02:00
Drew DeVault 10c8b73075 Handle calloc failures 2016-12-15 19:01:41 -05:00
D.B 58eb7ac19f change bar colors from char[10] to *char
This commit removes has_* booleans from bar color struct. It also
generalizes of functions in commands/bar/colors.c.
2016-11-02 21:07:04 +01:00
D.B ad4d21d60b add bar colours for focused_(workspace|statusline|separator)
If these aren't defined in config, color settings without 'focused_'
prefix are used as a fallback.
2016-11-02 18:58:33 +01:00
D.B 39ee0ec552 use urgent_ws color in swaybar if binding_mode is undefined 2016-11-02 18:58:33 +01:00
Zandr Martin ba581c4442
consolidate nodes json 2016-10-02 22:21:16 -05:00
Zandr Martin 7d947fdb95
add unique IDs to containers 2016-09-21 21:05:09 -05:00
Zandr Martin 0516dba3f6
implement "focused container" feature for swaygrab 2016-09-18 16:41:08 -05:00
Zandr Martin 87080bb9cc
take four! 2016-09-17 16:36:55 -05:00
Drew DeVault 416417a54c Reorganize includes 2016-09-01 08:18:37 -04:00
Tony Crisci 50901a0892 ipc: always include nodes in views
This is for i3 (and i3ipc library) compatability.
2016-08-04 21:19:52 -04:00
Tony Crisci c98e91f01f Use uintptr_t for ipc container id
This is for compatability with i3.
2016-08-03 20:34:47 -04:00
Zandr Martin 9fa92951fe
remove unmanaged nodes from get_tree 2016-08-02 13:24:21 -05:00
Drew DeVault cad085ed9d Update IPC JSON responses for HiDPI setups 2016-07-28 14:42:39 -04:00
Mykyta Holubakha f022628a2e Handle transient_for 2016-07-21 21:53:36 +03:00
Mykyta Holubakha f52daa26c9 Unite describe_view and describe_window 2016-07-21 21:51:20 +03:00
Mykyta Holubakha 2029fef6b8 More progress on window events 2016-07-21 21:51:20 +03:00
Drew DeVault 3bb880bf20 Implement configurable wrapping on bar ws scroll 2016-07-17 11:26:38 -04:00
Hummer12007 cf7c6c5822 Fix a memory leak 2016-07-17 00:00:51 +03:00
Mykyta Holubakha ea7917784d Fix build on x86 2016-07-12 09:43:48 +00:00
Zandr Martin c65d6e6e95
get_tree json fixes
- null pointer check against container names
- use actual json null values instead of "null" strings
- add "visible" property to all containers
2016-07-05 07:23:44 -05:00