Commit graph

629 commits

Author SHA1 Message Date
Yacine Hmito f3f77f9ff1 FALLBACK_CONFIG_DIR did not work. Fixed.
- Flag was ignored. Now it's taken into account.
- Missing trailing slashes in path now behaves properly.
2015-12-01 19:41:44 +01:00
Yacine Hmito 09feef89ee Can customize config fallback directory
CMake takes a `FALLBACK_CONFIG_DIR` flag which is the directory where the
standard configuration file `config` is copied at installation.
If loading from typical configuration directories fails, sway loads
FALLBACK_CONFIG_DIR/config (/etc/sway/config by default).
2015-12-01 01:07:48 +01: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
Drew DeVault 3f950b6e52 Merge pull request #278 from christophgysin/merge
cmd_output: Merge instead of replace output config
2015-11-29 16:26:11 -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
Christoph Gysin 3c8763af22 cmd_output: check for missing subcommand arguments 2015-11-29 22:36:17 +02:00
Drew DeVault 5a369b3132 Only strip comments at the start of a line
This is necessary because i3 config files use CSS notation for colors
(i.e. #rrggbb).
2015-11-29 14:02:58 -05:00
Drew DeVault ef91764bc7 Fix output adjustment for panels 2015-11-29 13:59:12 -05:00
Drew DeVault e59cffcea2 Support desktop shell panels in compositor 2015-11-29 12:03:13 -05:00
Drew DeVault 9d2bbe2640 Merge pull request #274 from sce/fix_stray_floats
cmd_floating: Don't add non-float as sibling to float.
2015-11-29 09:10:29 -05:00
Drew DeVault 25ad3181f5 Merge pull request #276 from sce/earlier_logging
main: Setup logging before wlc_init.
2015-11-29 09:08:56 -05:00
Drew DeVault c942f1624e Merge pull request #275 from christophgysin/cmd_output
refactor cmd_output
2015-11-29 09:07:22 -05:00
Drew DeVault 0af15cc19e Merge pull request #269 from christophgysin/usage
Add --help to print usage
2015-11-29 09:04:39 -05:00
S. Christoffer Eliesen c26a4b42cf main: Setup logging before wlc_init.
If `wlc_init` fails the error message will never be logged or printed
anywhere.
2015-11-29 15:01:47 +01:00
Christoph Gysin 7059eccaa1 cmd_output: Log enable/disable state 2015-11-29 15:32:02 +02:00
Christoph Gysin ffdfaaa985 apply_output_config: use list_seq_find() to find config 2015-11-29 15:31:58 +02:00
Christoph Gysin 7d82cd9c0a cmd_output: Use list_seq_find() to find matching config 2015-11-29 15:29:06 +02:00
Christoph Gysin 88f372a22a cmd_output: Cleanup cmd_output argument handling 2015-11-29 14:51:56 +02:00
S. Christoffer Eliesen badfb4bb43 cmd_floating: Don't add non-float as sibling to float.
When turning a float to a non-float, `get_focused_container` might
return another floating view, causing the active view to be inserted
into the floating list on its workspace instead of the normal child list
which it should. (Since it has `is_floating` as false the resulting
discrepency triggered other bad behaviour eventually leading sway to
crash.)

This patch fixes that by simply checking floating status before making
it a sibling.
2015-11-29 13:00:10 +01:00
Christoph Gysin 923c3245ac Fix option parsing
Using 'flag' results in duplicate code paths for short and long options.

This broke the -q short option in swaymsg, because there was:

 {"quiet", no_argument, &quiet, 'q'}

Which will set quiet to 'q' and return 0, not 'q'.
2015-11-28 23:50:44 +02:00
Christoph Gysin 2f2e1f3fc7 sway: Add --help option that prints usage 2015-11-28 23:50:44 +02:00
Christoph Gysin e48a16ce5e sway: Print usage and exit on unknown options 2015-11-28 23:50:44 +02:00
Christoph Gysin 3ba33321de Use macros for exit values 2015-11-28 23:50:10 +02:00
Mikkel Oscar Lyderik c477bbf345 Add warnings about invalid output commands
This handles some cases where sway will crash if an output command is
invalid/missing an argument.
2015-11-28 22:02:06 +01:00
S. Christoffer Eliesen 20cb390323 sway/main: Move wlc init to after args are handled.
First of all because it's not needed that early, and second of all
because there's a bug where calling `sway --get-socketpath` via `popen`
causes the child sway process to spin/hang instead of returning EOF.
(Specifically `(unset SWAYSOCK; swaymsg)` hangs.) This patch fixes that.

(Also note that this patch moves the "detailed review" comment, so I
guess this patch requires extra detailed review?)
2015-11-28 20:35:57 +01:00
Drew DeVault 1661edee28 Allow output config for output named *
Which will match any output.
2015-11-28 10:18:37 -05:00
Drew DeVault 2f192cceca Improve config file loading
This also makes it so that your i3 config is used before
/etc/sway/config.
2015-11-28 10:00:53 -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
S. Christoffer Eliesen db642fc8c5 commands: code formatting: Sort list of commands by alphabet. 2015-11-27 17:58:10 +01:00
Drew DeVault cbd7348704 Merge pull request #265 from sce/better_logging
debug_log: Improve container_log so that debug lines are aligned.
2015-11-27 09:56:07 -07:00
Drew DeVault cad2694a3c Merge pull request #264 from sce/fix_ws_next_name
workspace: Improve workspace_next_name.
2015-11-27 09:53:27 -07:00
S. Christoffer Eliesen c1d88acf72 debug_log: Improve container_log so that debug lines are aligned.
Makes the log easier to read, and the developers more happy (this one at
least).
2015-11-27 17:49:07 +01:00
S. Christoffer Eliesen 0a78af0acc workspace: Improve workspace_next_name.
This function looks for bound commands that start with `workspace` (ie.
the commands that change to a static workspace) and fetches the
workspace name.

However, if it's actually a list of commands, then the parsing will pick
up the delimiter ("," or ";") and also fail to recognize keywords
("next" etc).

This patch fixes that by properly separating with delimiters.
2015-11-27 17:30:05 +01:00
S. Christoffer Eliesen d9770cc243 cmd_floating: Support enable and disable commands too.
This is especially relevant in combination with `for_window`, e.g.:
`for_window [title="Terminal"] floating enable`.
2015-11-27 17:09:19 +01:00
Drew DeVault 27f03c705d Move IPC client into common, refactor IPC 2015-11-27 09:50:04 -05:00
Drew DeVault 53d353e6b4 Add "variant": "sway" to IPC version response 2015-11-26 16:49:36 -05:00
Drew DeVault 9a15371ba3 Parse command line args for swaymsg 2015-11-26 14:31:29 -05:00
Drew DeVault 206606b32c Merge pull request #261 from christophgysin/exec
Call swaybg without invoking a shell
2015-11-25 18:59:35 -05:00
Christoph Gysin e362f871d9 Call swaybg without invoking a shell
This makes escaping the arguments obsolete.

Also avoid dynamic memory allocation for the output id. It only supported ids up
to 99. Now we support up to 999, and take 4 bytes off the stack instead.
2015-11-25 23:19:11 +02:00
Christoph Gysin be3fae148b swaybg: implement scaling mode "fit" 2015-11-25 22:32:02 +02:00
Drew DeVault 9fb020d04c Merge pull request #251 from sce/criteria_1
criteria: Add. Learn for_window command.
2015-11-25 09:28:43 -05:00
S. Christoffer Eliesen 5483fe1883 criteria: Code formatting. 2015-11-25 14:59:07 +01:00
Christoph Gysin eeb7f5c036 config: print line number 2015-11-25 15:48:27 +02: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
Christoph Gysin a99aa92bc6 extensions: add missing include
This fixes a compiler warning:

../sway/extensions.c: In function ‘set_background’:
../sway/extensions.c:16:37: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
  struct background_config *config = malloc(sizeof(struct background_config));
                                     ^
../sway/extensions.c:16:37: warning: incompatible implicit declaration of built-in function ‘malloc’
../sway/extensions.c:16:37: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
2015-11-25 14:39:09 +02:00
S. Christoffer Eliesen e31a899841 layout: get_swayc_in_direction_under: Handle floating views. 2015-11-24 21:34:41 +01:00
S. Christoffer Eliesen b5ddad4bf6 layout: swap_container: Handle floating views. 2015-11-24 21:34:41 +01:00
S. Christoffer Eliesen ed1b0bffbc layout: replace_child: Handle floating views. 2015-11-24 21:34:41 +01:00
S. Christoffer Eliesen 8aef255d5f layout: add_sibling: Handle floating views properly.
This should fix #241.
2015-11-24 21:34:24 +01:00
S. Christoffer Eliesen a6c9f40b9a sway_binding_cmp_keys: Differentiate between modifier keys.
Compare modifiers as well as keys when number of modifiers+keys are the
same (so that e.g. mod1+x != mod4+x).
2015-11-24 19:26:43 +01:00
S. Christoffer Eliesen db92920cf9 handle_command: Skip commands that has a criteria string.
We can't handle them currently (the criteria needs to e.g. be passed to
each command handler which then needs to do the right thing), so it's
better to just do nothing than to create unexpected results (because the
command was executed on the wrong view).

(Before this patch any command list with a criteria string would simply
fail to parse, so this is at least a step in the right direction.)
2015-11-24 16:29:28 +01:00
S. Christoffer Eliesen b7e3d05ace stringop: Properly handle criteria strings.
A criteria string (e.g. '[class="something" title="something"]') is now
correctly treated as a single argument.
2015-11-24 16:12:37 +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
taiyu 9d50f88cef fix list sorting 2015-11-24 00:30:02 -08: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 9ce5d635f1 commands: Comment/doc for config_command. 2015-11-22 15:54:31 +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
Drew DeVault 2100d7bfef Fix #240 2015-11-19 20:04:03 -05:00
Drew DeVault 35fd139105 Add all documented scaling modes to config parser
Note that not all scaling modes are actually supported by swaybg yet.
2015-11-19 18:55:58 -05:00
Drew DeVault 5728307520 Add wallpapers to output command 2015-11-19 18:55:17 -05:00
Drew DeVault 79b277fe9b Parse output background config 2015-11-19 18:25:15 -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 01202568f9 Track pid of child process from exec
This will allow us to eventually open that process on the current view.
Requires support from @Cloudef.
2015-11-16 19:40:44 -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 cd161aa985 We somewhat more wlc_point now
Apparently I missed some

cc @Cloudef
2015-11-14 17:14:23 -05:00
Drew DeVault 95442dac8d We wlc_point now
cc @Cloudef
2015-11-14 11:30:29 -05:00
S. Christoffer Eliesen f64b7e71d4 ipc: Store socketname in SWAYSOCK. Fixes --get-socketpath.
After adding pid to the socket path the `--get-socketpath` command broke
because it doesn't know the pid of the running instance. Fix this by
setting and querying `SWAYSOCK`.

Also ignore `SWAYSOCK` upon normal startup if a socket exists at that
location (ie. from another sway instance), and don't overwrite `I3SOCK`
if it exists either.
2015-11-13 18:18:52 +01:00
Drew DeVault 1011957465 Merge branch 'master' of github.com:SirCmpwn/sway 2015-11-13 08:17:35 -05:00
Drew DeVault 38b18d460a Revert "Try ~/.i3/config earlier than /etc/sway/config"
This reverts commit f0ceb4e909.
2015-11-13 08:17:29 -05:00
Drew DeVault f3fc48f692 Merge pull request #225 from sce/logind_socket_path
ipc: Put socket into proper user runtime dir.
2015-11-13 08:15:14 -05:00
Drew DeVault f0ceb4e909 Try ~/.i3/config earlier than /etc/sway/config
And ~/.config/i3/config, of course.
2015-11-13 08:09:30 -05:00
S. Christoffer Eliesen 253204efb9 ipc: Put socket into proper user runtime dir. 2015-11-13 14:07:18 +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 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 250097d32b Fix gaps for views being incorrect 2015-11-12 08:02:39 -05:00
Drew DeVault 4397cff7bc Fix some IPC issues
Socket now includes pid in the filename (fixes nested sway sessions or
old sockets causing problems).

Fixed warnings on strict aliasing and cleaned up relevant code in
general.
2015-11-11 08:43:36 -05:00
Drew DeVault d729032ba2 Add file and line number to log in Debug build 2015-11-11 08:32:32 -05:00
Mikkel Oscar Lyderik d5b5d92b30 Include header declaring ipc_event_workpace(2) 2015-11-04 21:12:25 +01: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 eeec0fda8a commands: gaps: Re-arrange windows after changing default gaps. 2015-11-04 01:32:38 +01:00
S. Christoffer Eliesen 936f8c24e0 commands: gaps: Always apply default gaps config. 2015-11-04 01:32:37 +01:00
S. Christoffer Eliesen 5c1e20b6ff commands: gaps: Accept zero value. 2015-11-04 01:32:37 +01:00
S. Christoffer Eliesen 820681965d commands: gaps: Refactor, expected_syntax. 2015-11-04 01:32:37 +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 9c8394022e commands: Learn 'move <container|window> to output <direction|name>'. 2015-11-03 22:38:53 +01:00
taiyu 65d71d0a5e put ipc_event_workspace in update_focus 2015-11-02 11:28:51 -08: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
S. Christoffer Eliesen 3c250e78be layout: get_swayc_in_direction: Properly find adjacent outputs. 2015-10-29 16:20:48 +01:00
S. Christoffer Eliesen 5fa8f91655 commands: Learn 'focus output <direction|name>' 2015-10-28 20:06:48 +01:00