aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
AgeCommit message (Collapse)Author
2018-09-23Implement support for input wildcardBrian Ashworth
2018-09-23Allow running commands on containers without focusing themRyan Dwyer
This adds a `con` argument to `execute_command` which allows you to specify the container to execute the command on. In most cases it leaves it as `NULL` which makes it use the focused node. We only set it when executing `for_window` criteria such as when a view maps. This means we don't send unnecessary IPC focus events, and fixes a crash when the criteria command is `move scratchpad` (because we can't give focus to a hidden scratchpad container). Each of the shell map handlers now check to see if the view has a workspace. It won't have a workspace if criteria has moved it to the scratchpad.
2018-09-20Merge pull request #2671 from emersion/output-execute-no-focusemersion
Fix segfault when executing command without focus
2018-09-19Fix segfault when executing command without focusemersion
2018-09-19Introduce create_output command (for developer use)Ryan Dwyer
Should help with testing hotplugging.
2018-09-11Introduce tiling_drag directiveRyan Dwyer
2018-09-05Implement type safe arguments and demote sway_containerRyan Dwyer
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-03Change _XOPEN_SOURCE defines to _POSIX_C_SOURCEsghctoma
2018-09-03Merge remote-tracking branch 'upstream/master' into fix-freebsd-buildsghctoma
2018-09-02Implement focus_on_window_activationRyan Dwyer
Depends on https://github.com/swaywm/wlroots/pull/1223
2018-09-01Implement deprecated new_window and new_float commandsRyan Dwyer
May as well make it as easy as possible for users who are coming from i3. This also changes the `border` command to accept a thickness when setting the border to normal. This makes it work the same way as the `default_border` command. Eg. `border normal 5`
2018-08-30Fix feature macros for FreeBSDsghctoma
On FreeBSD, snprintf and vsnprintf are visible only if _XOPEN_SOURCE >= 600.
2018-08-18commands: add nopIan Fan
2018-08-03Write to swaynag pipe fd directly on config errorsBrian Ashworth
2018-08-03Show swaynag on config errorsBrian Ashworth
2018-07-23Implement scratchpadRyan Dwyer
Implements the following commands: * move scratchpad * scratchpad show * [criteria] scratchpad show Also fixes these: * Fix memory leak when executing command with criteria (use `list_free(views)` instead of `free(views)`) * Fix crash when running `move to` with no further arguments
2018-07-22Implement floating_modifier and mouse operations for floating viewsRyan Dwyer
This implements the following: * `floating_modifier` configuration directive * Drag a floating window by its title bar * Hold mod + drag a floating window from anywhere * Resize a floating view by dragging the border * Resize a floating view by holding mod and right clicking anywhere on the view * Resize a floating view and keep aspect ratio by holding shift while resizing using either method * Mouse cursor turns into resize when hovering floating border or corner
2018-07-21Implement force_display_urgency_hintRyan Dwyer
The directive sets the timeout before an urgent view becomes normal again after switching to it from another workspace. Also: * When an xwayland surface removes the urgent hint while the timer is active, we now ignore the request. This happens as soon as the view receives focus, so it was effectively making the timer pointless. * The timeout is now only applied when switching to it from another workspace.
2018-07-19Defer the focus commandsRyan Dwyer
2018-07-17Implement default_floating_border command and adjust CSD behaviourRyan Dwyer
2018-07-16Merge pull request #2276 from RyanDwyer/urgencyDrew DeVault
Implement urgency base functionality
2018-07-16Implement no_focus commandRyan Dwyer
2018-07-16Implement urgency base functionalityRyan Dwyer
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-15Make focus part of transactionsRyan Dwyer
Rather than maintain copies of the entire focus stack, this PR transactionises the focus by introducing two new properties to the container state and using those when rendering. * `bool focused` means this container has actual focus. Only one container should have this equalling true in its current state. * `struct sway_container *focus_inactive_child` points to the immediate child that was most recently focused (eg. for tabbed and stacked containers).
2018-07-14Simplify transactions by utilising a dirty flag on containersRyan Dwyer
This PR changes the way we handle transactions to a more simple method. The new method is to mark containers as dirty from low level code (eg. arranging, or container_destroy, and eventually seat_set_focus), then call transaction_commit_dirty which picks up those containers and runs them through a transaction. The old methods of using transactions (arrange_and_commit, or creating one manually) are now no longer possible. The highest-level code (execute_command and view implementation handlers) will call transaction_commit_dirty, so most other code just needs to set containers as dirty. This is done by arranging, but can also be done by calling container_set_dirty.
2018-07-11Implement floating_minimum_size and floating_maximum_sizeRyan Dwyer
2018-07-09Update for swaywm/wlroots#1126emersion
2018-07-05cmd_results_to_json: return copied string and properly free the jsonDominique Martinet
The only user of this function would copy the string right away to get rid of the const flag anyway, and freeing a const string afterwards might work but is not meant to be done according to the json-c API.
2018-07-02config_commands_command: make alloc failure check more permanentDominique Martinet
policy is accessed again later Found through static analysis
2018-06-09Implement gaps (PR #2047)Nate Symer
2018-06-07Remove strip quoting and fix strncpy-overlapBrian Ashworth
2018-06-05Support runtime var expansion and set at runtimeBrian Ashworth
2018-06-02Address first round of review for generic blocksBrian Ashworth
2018-06-02Make command block implementation genericBrian Ashworth
2018-06-01Implement floatingRyan Dwyer
2018-06-01Implement `floating enable`Drew DeVault
2018-05-28Implement config parser for workspace_layoutBrian Ashworth
2018-05-28Support i3's legacy force_focus_wrapping commandBrian Ashworth
2018-05-27Implement focus_wrappingBrian Ashworth
2018-05-26Implement swap commandBrian Ashworth
2018-05-17Implement show_marksRyan Dwyer
2018-05-15Change unmark implemention to match i3'sRyan Dwyer
2018-05-15Implement marksRyan Dwyer
2018-05-14Revert "Revert "Merge pull request #1943 from RyanDwyer/criteria-improvements""Ryan Dwyer
This reverts commit 32a572cecfd0f6072a78ce0a381a2f8365f9010a. This reimplements the criteria overhaul in preparation for fixing a known bug.
2018-05-11Implement hide_edge_bordersBrian Ashworth
2018-05-05Implement title_formatRyan Dwyer
This implements the title_format command, with a new placeholder %shell which gets substituted with the view type (xwayland, xdg_shell_v6 or wl_shell). Example config: for_window [title=".*"] title_format %title (class=%class instance=%instance shell=%shell)
2018-05-03Fix alphabetization of command listDrew DeVault
2018-05-03Render titlesRyan Dwyer
2018-05-01Fix alphabetization of commands arrayDrew DeVault
2018-05-01Implement bordersRyan Dwyer
Implements rendering of borders. Title text is still to do. Implements the following configuration directives: * client.focused * client.focused_inactive * client.unfocused * client.urgent * border * default_border