Commit graph

248 commits

Author SHA1 Message Date
Mikkel Oscar Lyderik 16b8c2e915 Handle SIGTERM sent to sway
This makes sway handle and gracefully shut down everything when
receiving a SIGTERM.

Fix #416
2015-12-29 13:03:53 +01:00
progandy 8fefdb3c64 swaybar: fix memory leaks 2015-12-22 17:54:47 +01:00
Drew DeVault 91c102a897 Merge pull request #393 from robotanarchy/musl-libc-compatibility
musl libc compatibility
2015-12-21 20:42:08 -05:00
robotanarchy c3e9ee5e43 replace non-standard qsort_r with qsort
I've tried to make as few changes, as possible.

Usually the reason for using qsort_r is, that you can pass an extra userdata pointer to the
compare function. However, in sway list_sort wrapped qsort_r and always called a wrapper
function for comparing, the wrapper function then had the real compare function as argument.
The only thing, that the wrapper function does, is dereferencing the 'left' and 'right' function
arguments before passing them to the real compare function.

I have renamed list_sort to list_qsort to avoid confusion (so nobody tries to use list_qsort like
list_sort) and removed the wrapper functionality. Now the dereferencing must be done in the
compare function, that gets passed.

Some compare functions were used in both list_sort and list_seq_find. To make the difference
clear, I've added a '_qsort' suffix to the compare functions, that are intended to be used with
the new list_qsort. (In other words: list_qsort is not compatible anymore with list_seq_find).

- Changed and renamed function (it isn't used anywhere but in commands.c, and only for sorting):
	compare_set -> compare_set_qsort
- New wrapper functions:
	sway_binding_cmp_qsort (for sway_binding_cmp)
	sway_mouse_binding_cmp_qsort (for sway_mouse_binding_cmp)
2015-12-22 00:38:18 +01:00
Mikkel Oscar Lyderik 50b04884b6 Trigger ipc_event_workspace in all cases
This makes sure that the workspace IPC event is triggered when needed.

Fixes #382 while making sure that the IPC event is only triggered once.
2015-12-21 23:07:52 +01:00
Mikkel Oscar Lyderik 66c66c7304 Implement barconfig_update IPC event 2015-12-21 15:28:34 +01:00
Drew DeVault 3082245243 Merge pull request #373 from sce/per_panel_config
Per panel config
2015-12-20 12:05:32 -05:00
progandy 21014e606b make gdk-pixbuf dependency really optional 2015-12-20 17:37:52 +01:00
S. Christoffer Eliesen e45fd9b6c5 extensions: Track panels by wl_resource, position per panel.
Track each panel separately via its wl_resource. `set_panel_position`
might be called before `set_panel`, so reuse panel config.

Place the position in panel_config so that each panel has its own
position.
2015-12-20 12:54:34 +01:00
S. Christoffer Eliesen 6db0f6f80f extensions: panel_config->resource => wl_surface_res.
Change the name to something less ambigious.
2015-12-20 12:54:34 +01:00
Drew DeVault 7647762bab Fix default workspace name generation
This fixes the issue where workspace 10 ends up being the default.
2015-12-18 18:52:51 -05:00
Drew DeVault b9f14cee41 Merge pull request #359 from mikkeloscar/i3bar-command
Add bar option: swaybar_command <command>
2015-12-18 18:19:59 -05:00
Mikkel Oscar Lyderik 9d7f1afdfb Add bar option: swaybar_command <command> 2015-12-19 00:13:51 +01:00
Mikkel Oscar Lyderik 90ff36cab8 Terminate children when freeing output container 2015-12-18 18:27:54 +01:00
Mikkel Oscar Lyderik ede27eabc5 Reload swaybar/swaybg on config reload.
This works by tracking the pids of the child processes in the related
output container and terminating the processes and spawning new ones on
a config reload.

Should solve: #347
2015-12-18 18:27:44 +01:00
Drew DeVault 7558a274fa Add shims for swaylock on compositor 2015-12-18 08:49:04 -05:00
progandy 76c520a04b sway: insert numbered workspaces in order
fixes #308

Ordered by number ascending, with insert before same numbers.
Workspaces without numbers are appended at the end of the list.

Example order:
1 2:named 3:the_second 3:the_first 9 FIRST_NAME SECOND_NAME ...
2015-12-18 01:22:07 +01:00
progandy 8f1ac1ef2c sway: enable workspace selection by number 2015-12-18 01:21:31 +01:00
Drew DeVault f6da4dda4b Bring unmanaged windows to front on output arrange
Fixes #312
2015-12-16 19:20:34 -05:00
Mikkel Oscar Lyderik 2fd7dd64ec Implement bar option: separator_symbol 2015-12-16 13:01:11 +01:00
Mikkel Oscar Lyderik f59f5d27aa Implement bar option: output <output> 2015-12-15 22:01:53 +01:00
Mikkel Oscar Lyderik 6834a33290 Add bar height option (Airblader/i3) 2015-12-15 15:02:13 +01:00
Mikkel Oscar Lyderik de1f625c27 Add rgba support for bar colors 2015-12-15 13:45:04 +01:00
Mikkel Oscar Lyderik 8c1d56812b Implement bar option: colors {} 2015-12-15 13:12:55 +01:00
Mikkel Oscar Lyderik 0513322c03 Move default bar config to bar creation.
Get rid of `config->bar` and define the default bar config options when
a bar is initialized.
2015-12-15 01:05:00 +01:00
Yacine Hmito 87126a9fc2 Added bar_cmd_bindsym
Defined a sway_mouse_binding for clicks on the swaybar
2015-12-15 00:15:32 +01:00
Mikkel Oscar Lyderik 0aeee6963d Make mouse key used for drag/resize configurable
This makes it possible to define what mouse button key (left|right) to
use for dragging/resizing.
2015-12-14 22:31:34 +01:00
Mikkel Oscar Lyderik c6b13163c9 Add initial support for custom bar-id 2015-12-14 17:17:06 +01:00
Mikkel Oscar Lyderik 45b959f601 Move numlen(1) to sway/util.c 2015-12-14 17:07:52 +01:00
Drew DeVault 4d17aa9919 Revert "Make mouse key used for drag/resize configurable"
This reverts commit 22916e9ebc.
2015-12-14 08:57:00 -05:00
Mikkel Oscar Lyderik 74152043f4 Implement 'bar { }' block parsing 2015-12-14 12:56:45 +01:00
Drew DeVault e277d4e094 Subscribe to workspace change events and redraw 2015-12-13 16:04:54 -05:00
Drew DeVault d361ce656d Track the fullscreen view on a workspace swayc_t 2015-12-13 07:58:00 -05:00
Drew DeVault 34277207fd Pass keys along from wayland backend to clients 2015-12-12 15:19:23 -05:00
Drew DeVault 029e0c7a2c Add some more keyboard handling for wayland clients 2015-12-12 12:54:10 -05:00
Mikkel Oscar Lyderik 22916e9ebc Make mouse key used for drag/resize configurable
This makes it possible to define what mouse button key (left|right) to
use for dragging/resizing.
2015-12-11 18:04:27 +01:00
Drew DeVault a7710c5537 Initialize keyboard in registry poll 2015-12-10 18:34:12 -05:00
Drew DeVault 266393a705 Include wayland-server.h instead of -core.h 2015-12-10 17:04:09 -05:00
Drew DeVault 7614cb0373 Add keyboard handling shims to registry 2015-12-10 08:32:56 -05:00
Drew DeVault 067ac6cfa7 Discover swaylock extension in registry 2015-12-10 08:05:27 -05:00
Drew DeVault 080a263785 Refactor gdk pixbuf code into shared client lib 2015-12-10 07:57:46 -05:00
Drew DeVault 71afa38890 Add swaylock protocol, add resource destructors
This prevents sway crashing if swaybg or swaybar dies.
2015-12-03 08:35:22 -05:00
Drew DeVault 44d0f731c3 Add framework for switching command sets
This will allow the bar {} block to have a different command set (and
also bar { colors { } }.
2015-11-29 17:20:27 -05:00
Drew DeVault 4f89735fc4 Add bar config struct and defaults 2015-11-29 17:05:04 -05:00
Christoph Gysin b1bd3ae6f3 cmd_output: Merge instead of replace output config 2015-11-29 23:17:56 +02:00
Christoph Gysin ae7ed79573 config: Store 'enabled' as int 2015-11-29 23:17:55 +02:00
Drew DeVault 82d464bb90 Add text rendering support to wayland clients 2015-11-29 15:27:28 -05:00
Drew DeVault e59cffcea2 Support desktop shell panels in compositor 2015-11-29 12:03:13 -05:00
Drew DeVault 4c1fad95b9 Remove trailing semicolon 2015-11-29 09:07:50 -05:00
Christoph Gysin 7d82cd9c0a cmd_output: Use list_seq_find() to find matching config 2015-11-29 15:29:06 +02:00
Drew DeVault e0cb8284fb Rearrange logging headers
Ref #270
2015-11-28 08:49:02 -05:00
S. Christoffer Eliesen 2d0f78c0d6 workspace: Learn sticky.
A floating window that's sticky will move to the new active workspace
whenever the workspace on the same output changes.
2015-11-27 17:58:10 +01:00
Drew DeVault 062c74b7d0 Add command line to swaygrab
Also modifies IPC client so that we can work with persistent
connections.
2015-11-27 10:10:29 -05:00
Drew DeVault 27f03c705d Move IPC client into common, refactor IPC 2015-11-27 09:50:04 -05:00
S. Christoffer Eliesen a06cb7cd01 criteria: Add. Learn for_window command.
A criteria is a string in the form of `[class="regex.*" title="str"]`.
It is stored in a struct with a list of *tokens* which is a
attribute/value pair (stored as a `crit_token` struct). Most tokens will
also have a precompiled regex stored that will be used during criteria
matching.

for_window command: When a new view is created its metadata is tested
against all stored criteria, and if a match is found the associated
command list is executed.

Unfortunately some metadata is not available in sway at the moment
(specifically `instance`, `window_role` and `urgent`). Any criteria
string that tries to match an unsupported attribute will fail.

(Note that while the criteria code can be used to parse any criteria
string it is currently only used by the `for_window` command.)
2015-11-25 14:34:33 +01:00
S. Christoffer Eliesen 4367e6d3e3 container: Store app_id attribute for views. 2015-11-24 16:00:41 +01:00
S. Christoffer Eliesen 47c313fe3e container: Store class attribute for views. 2015-11-24 16:00:41 +01:00
S. Christoffer Eliesen a0c5a0bb30 cmd_bindsym: Detect/handle duplicates.
Also replace `bindsym_sort` with function `sway_binding_cmp` that takes
all data into account when comparing.
2015-11-22 21:17:36 +01:00
S. Christoffer Eliesen 5531dbe1b2 cmd_workspace: Don't fill up config->workspace_outputs with duplicates.
This also fixes a bug where issuing a new "workspace a output b" command
for an already assigned workspace would not work (the old config would
be found first and used instead).
2015-11-22 11:08:08 +01:00
S. Christoffer Eliesen d0af224e6d stringop: lenient_strcmp: Add. 2015-11-21 22:22:09 +01:00
S. Christoffer Eliesen a33e3badad list: Add list_seq_find.
Sometimes one has to traverse a list to find out if some data already
exists there in order to avoid dupilcates in the list, and this function
facilitates in that without requiring that the data is ordered.
2015-11-21 22:22:08 +01:00
Drew DeVault 79b277fe9b Parse output background config 2015-11-19 18:25:15 -05:00
Drew DeVault b4e5e1381f Refactor the crap out of wayland clients
And create a background surface on every output when invoking swaybg.
2015-11-19 07:58:57 -05:00
Drew DeVault 4a1584be53 Fix background extensions
Thanks @Cloudef, it works great
2015-11-19 07:23:11 -05:00
Drew DeVault 65b8a5c3ce Add background handling
This does not work as expected. I think the problem is on the wlc side.
Please review, @Cloudef. To reproduce the issues:

1. Run sway
2. Open terminal in sway
3. Run swaybg

swaybg will create a surface and ask to have it set as the background,
but wlc_handle_from_wl_surface_resource will return 0. If the swaybg
surface is a shell surface, then it works - but wlc complains about the
pointer type and segfaults as soon as the pre-render hook tries to draw
the background.
2015-11-18 22:14:57 -05:00
Drew DeVault 82db2a57a9 Basic support for extensions in server and clients 2015-11-18 22:01:22 -05:00
Drew DeVault 7a40eb6de6 Support cursors over wayland clients
Apparently wayland has fucking client-side cursors, too
2015-11-18 19:38:42 -05:00
Drew DeVault 86372d00db Fix SIGBUS from wayland clients 2015-11-18 09:55:55 -05:00
Drew DeVault 665d4baaf1 Normalize indentation 2015-11-18 08:44:08 -05:00
Drew DeVault 9a1e95b7da Clean up memory pool files better 2015-11-18 08:36:08 -05:00
Drew DeVault 399220f14b Fix up wayland client implementation
Now it receives frame callbacks and renders properly, and is double
buffered and such.
2015-11-18 08:22:53 -05:00
S. Christoffer Eliesen 236f26f62e output: Support multiple adjacent outputs.
When querying for an adjacent output we now need an absolute position in
order to know which adjacent output that matches. (The position is
either the current mouse position or the center of the currently focused
container, depending on context.)

If two outputs have one edge each that at least partially align with
each other they now count as adjacent.

Seamless mouse is affected by this and now properly moves and positions
itself between outputs with "uneven" placement (as long as they have at
least some part of the edge adjacent to each other).

When focusing or moving a container in a specified direction the center
of the current focused container decides where to look for an adjacent
output. So if e.g. an output has two adjacent outputs to the right and a
"focus right" command is issued then it's the placement of the currently
focused container that decides which output actually gets focused.

Also, if an output has at least one output adjacent in some direction
but the entire edge is not covered (ie. it has "holes" with no outputs),
then the algorithm will choose the output that is closest to the
currently focused container (this does not apply to seamless mouse, the
pointer will just stop at the edge in that case).
2015-11-16 21:32:18 +01:00
S. Christoffer Eliesen a94a91a723 cmd_output: Replace existing config if called multiple times. 2015-11-16 15:57:42 +01:00
Drew DeVault c43ef2aedd We don't need to implement strdup
After defining _GNU_SOURCE
2015-11-12 19:43:03 -05:00
Drew DeVault 11b1ba397f Further refinement of wayland client support 2015-11-12 19:35:39 -05:00
Drew DeVault bfcabe48ef Start fleshing out wayland client implementation
This introduces a basic shared framework for making wayland clients
within sway itself.
2015-11-12 19:04:01 -05:00
Drew DeVault ef8335d694 Start working on IPC for get_pixels
This is broken
2015-11-12 12:37:23 -05:00
Drew DeVault d729032ba2 Add file and line number to log in Debug build 2015-11-11 08:32:32 -05:00
Drew DeVault edb3e4b5ab Add some documentation comments
This is mostly setting a precedent, I hope that others will continue to
write docs for more headers.

Ref #218
2015-11-08 12:06:51 -05:00
S. Christoffer Eliesen abc5fbfaec Learn "gaps edge_gaps <on|off|toggle>".
When yes, the old behaviour of adding half the inner gap around each
view is used.

When no, don't add any gap when an edge of the view aligns with the
workspace. The result is inner gap only between views, not against the
workspace edge.

The algorithm is not perfect because it means the extra space is
distributed amongst edge-aligned views only, but it's simple, looks good
and it works.
2015-11-04 13:21:10 +01:00
S. Christoffer Eliesen af31a3f04a commands: Learn 'move workspace to output <direction|name>'. 2015-11-03 22:38:53 +01:00
S. Christoffer Eliesen 515ed86f4d container.h: Remove unused. 2015-10-29 19:13:52 +01:00
S. Christoffer Eliesen 5ba47d4a44 input_state: Remove mouse_origin (x&y). Query wlc instead. 2015-10-29 18:02:02 +01:00
S. Christoffer Eliesen 78ca619769 commands: Learn mouse_warping.
Place mouse at center of focused view when changing to a workspace on a
different output, if option is enabled. (This replicates existing i3
option.)

This can be triggered in multiple ways:
A) via `workspace <name>` which changes output
B) via `focus <direction>` which changes output
C) via `focus output <name>` which (obviously) changes output
2015-10-29 17:41:33 +01:00
S. Christoffer Eliesen 4799d07ac1 input_state: Extract 'pointer_position_set' function from handlers. 2015-10-29 16:37:19 +01:00
S. Christoffer Eliesen 865b30f138 container: Move container_under_pointer here from handlers. 2015-10-29 16:37:19 +01:00
Drew DeVault 6cd106d23c Merge pull request #208 from minus7/ipc_subscribe
implemented IPC subscribe for workspace event
2015-10-27 17:19:18 -04:00
minus 9925554ea4 implemented IPC subscribe for workspace event 2015-10-27 21:59:17 +01:00
S. Christoffer Eliesen 9f02b0bf16 commands: Learn 'debuglog'.
Replicates i3 option. Verbosity level given as command line argument
becomes default log level, and using 'debuglog toggle' switches back and
forth between default and debug (or L_ERROR and debug if default is also
L_DEBUG).
2015-10-27 14:37:44 +01:00
S. Christoffer Eliesen 5a70853253 log: Add swayc_log, use at a few key places.
swayc_log works just like sway_log, but appends type and name from given
container to the log output.
2015-10-25 13:14:28 +01:00
S. Christoffer Eliesen c6bb23b7dd sway/output: Create, move code from handlers.c here. 2015-10-25 13:14:23 +01:00
S. Christoffer Eliesen c1479701de seamless_mouse: Move pointer only if successfully changed workspace.
If e.g. a window has a popup open then that will lock the current focus,
making a workspace switch denied.

So don't move the mouse pointer in such cases.
2015-10-23 16:35:48 +02:00
S. Christoffer Eliesen 362413bd50 commands: cmd_results->input is duplicated/freed. 2015-10-23 13:03:14 +02:00
S. Christoffer Eliesen af30a1b67c ipc,commands,config: Replace cmd_status enum with cmd_results struct.
In i3 the ipc reply will contain a human readable error message, and
this patch replicates that behaviour.

However, that error message is also useful for logging, which this
patch takes advantage of.

E.g. instead of logging errors directly in commands.c/checkargs, it is
fed back to the caller which eventually ends up logging everything with
maximum context available (config.c/read_config).

So instead of logging e.g. "Error on line 'exit'" it will now log:
"Error on line 'exit': Can't execute from config."
2015-10-22 23:36:24 +02:00
S. Christoffer Eliesen edf33aad29 config: Add "seamless_mouse" to decide if pointer crosses output edges. 2015-10-22 01:39:12 +02:00
S. Christoffer Eliesen ca862a5bd4 config: Apply output config also during config reload. 2015-10-21 23:24:06 +02:00
S. Christoffer Eliesen 3be11a08e6 main: Implement --get-socketpath switch. 2015-10-18 19:53:56 +02:00
taiyu 0d51f62224 merge + no c_extensions 2015-09-18 07:23:04 -07:00
Drew DeVault 318e1be240 Fix warnings introduced by prior commit 2015-09-18 07:27:35 -04:00
taiyu 0bea2e2122 multi command keybinds 2015-09-14 19:59:25 -07:00