Commit graph

475 commits

Author SHA1 Message Date
Ryan Dwyer 9fbe13b9be Implement floating_modifier and mouse operations for floating views
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-22 23:10:19 +10:00
Ryan Dwyer 8789ceea87 Fix pointer events for overlapping floating views
Fixes #2315.
2018-07-20 09:41:36 +10:00
Ryan Dwyer 54b00d351e Implement assign to output
Eg. assign [class="Firefox"] output foo
2018-07-19 22:36:38 +10:00
Ryan Dwyer dad3a8deee Fix crash when moving workspace to output 2018-07-19 16:52:02 +10:00
Ryan Dwyer 8ce7e3b44e
Merge branch 'master' into destroy-output-destroy-empty-workspaces 2018-07-18 09:32:03 +10:00
frsfnrrg b3014f7b16 Fix uninitialized pointer in view_unmap
Otherwise, sway crashes due to uninitialized pointer
dereference when AddressSanitizer is active.
2018-07-17 10:42:48 -04:00
Brian Ashworth 10fc7a5b49
Merge branch 'master' into default-floating-border 2018-07-16 22:12:29 -04:00
Ryan Dwyer 9cbff272cb Remove superfluous IPC urgent events
When an xwayland view is mapped, the IPC urgent event was being sent on
every surface commit.

I had intentionally ommitted the check because I figured an urgent
surface could update its urgent timestamp by sending urgent a second
time. But that's not how it works in xwayland's case, and it makes for
more complicated code.
2018-07-17 10:27:03 +10:00
Ryan Dwyer 75c699db62 Implement default_floating_border command and adjust CSD behaviour 2018-07-17 10:14:33 +10:00
Drew DeVault d6bd314dff
Merge pull request #2276 from RyanDwyer/urgency
Implement urgency base functionality
2018-07-16 15:39:08 -07:00
Ryan Dwyer e2f28c023c Focus view before running criteria when mapping 2018-07-16 22:27:11 +10:00
Ryan Dwyer fc2484095a Implement no_focus command 2018-07-16 22:18:12 +10:00
Ryan Dwyer af5f736277 Render containers as urgent if they have an urgent child 2018-07-16 18:22:27 +10: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 560627437b Make container_for_each_descendant_dfs descend into floating views 2018-07-16 12:45:20 +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
Ryan Dwyer 2032f85d94 Simplify transactions by utilising a dirty flag on containers
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-14 23:14:55 +10:00
emersion 9b16227ec3 Don't disable borders for xwayland floating views 2018-07-12 20:01:33 +01:00
emersion 60fdb71a1f Updates for swaywm/wlroots#1116 2018-07-11 18:37:17 -04:00
Ryan Dwyer f2d1cf3ceb Implement floating_minimum_size and floating_maximum_size 2018-07-11 22:16:48 +10:00
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
emersion ebcdce457a
Merge pull request #2223 from RyanDwyer/floating-move
Implement some floating move commands
2018-07-09 19:04:45 +01:00
Ryan Dwyer b0fc7e9850 Remove duplicate function declaration and add assertion 2018-07-09 23:41:00 +10:00
Ryan Dwyer ab8a86369c Implement some floating move commands
This implements the following for floating containers:

* move <direction> <amount>
* move [absolute] position <x> <y>
* move [absolute] position mouse
2018-07-09 23:38:29 +10:00
vilhalmer 4e7ef1dd39
No need to walk to workspace, recursive will 2018-07-09 08:26:39 -04:00
vilhalmer 47c20f8ea4
Regroup signal 2018-07-09 08:25:32 -04:00
vilhalmer ce626a0708
Replace empty workspace with moved workspace 2018-07-08 22:55:50 -04:00
vilhalmer 621d2666b1
Destroy empty workspace when destroying its output 2018-07-08 21:55:24 -04:00
Ryan Dwyer 0046eed969 Fix titles when container titles contain UTF-8 characters
The title and marks textures would have their height set from the
config's computed max font height, but the textures were not regenerated
when the config's max font height changed which made a gap appear.
Rather than making it regenerate the title textures every time the
config font height was changed, I've changed it to just make the
textures the height of the title itself and fill any gap when rendering.

Also, the title_width and marks_width variables have been renamed to
make it more obvious that they are in output-buffer-local coordinates.

Fixes #1936.
2018-07-07 15:49:51 +10:00
emersion 9a9d9116be
Make view_update_* update live props as well 2018-07-06 19:33:10 +01:00
Dominique Martinet 9314c45c41 workspace_next_name: free targets later than these already found in order 2018-07-05 08:13:10 +09:00
Dominique Martinet 785ed4383b view_map: free criterias as the list it is 2018-07-05 08:13:10 +09:00
Dominique Martinet ffbe91c245 container_free: free formatted title 2018-07-05 08:13:10 +09:00
Ryan Dwyer fc826b921f Call view_set_tiled for mapping non-floating views
Fixes #2209.
2018-07-05 09:04:15 +10:00
Ryan Dwyer 4cb6c368a7 Fix boolean 2018-07-04 20:33:38 +10:00
Ryan Dwyer f156a25e64 Only call view_set_tiled when switching floating mode
Otherwise it repeatedly sets the view's border to the config's default.
2018-07-04 20:10:47 +10:00
Dominique Martinet c78ab67877 workspace_next_name: fix string length for ws_num >= 100
The check didn't include && ws_num < 100 so l would always be 1 or 2
Instead of fixing logic it's simpler to just call snprintf twice to get
length and use that.

Also change malloc failure check to sway_assert because both callers of
this function do not do null check and would segfault...

Found through static analysis.
2018-07-02 08:03:41 +09:00
Dominique Martinet 9c9ee3e4ef find prev/next output/workspace: add NULL check
These could be called with NULL if there is no focus

Found through static analysis.
2018-07-02 08:03:41 +09:00
Drew DeVault acd79e1505 Implement pid->workspace tracking
When you spawn a process with the exec command, sway now notes the
workspace you had focused and the pid of the child process, then assigns
that workspace to the child when its window appears.

Some of this is carried over from sway 0.15, but with some major
refactoring and centralization of state.
2018-07-01 09:58:18 -04:00
Dominique Martinet 9ea4cc13a0 sway views: add helpers to get view and layer from wlr_surface 2018-06-30 22:31:14 +09:00
Ryan Dwyer e396af853b Merge remote-tracking branch 'upstream/master' into atomic 2018-06-30 22:46:25 +10:00
Rostislav Pehlivanov f42bf0ad4a container_at_view: don't offset the view by the window geometry
Fixes floating window input offsets. As discussed on IRC with emersion,
this shouldn't have been done in the first place.
2018-06-30 11:11:06 +01:00
Rostislav Pehlivanov e0d0e8f840 Revert "Don't unmaximize floating views"
This reverts commit 97672295ed.
2018-06-30 11:10:47 +01:00
emersion 4de28bba68
Fix floating views not receiving frame events
That happened when they were in tabbed or stacked containers.

Fixes #2161
2018-06-30 09:49:51 +01:00
Ryan Dwyer e6829c5991 Move unsetting of view->surface into view_unmap 2018-06-27 17:54:57 +10:00
Ryan Dwyer 8773ed3970 Fix memleak in container_get_box
Rather than allocate a structure and expect callers to free it, take a
pointer to an existing struct as an argument.

This function is no longer called anywhere though.
2018-06-27 17:47:41 +10:00
Ryan Dwyer be86d3aba6 Remove transaction_add_damage
Instead, damage each container when applying the transaction.
2018-06-27 17:46:03 +10:00
Ryan Dwyer 61c1187685 Fix nitpicks 2018-06-27 17:23:44 +10:00
Ryan Dwyer a7b3f29292 Remove incorrect assertion and supporting code
Children can exist when destroying a container, such as when destroying
the last output. Sway is not terminating in that case.
2018-06-26 20:18:57 +10:00
Ryan Dwyer 93696b78ec Fix crash when closing output window from outer session
Emitting the close event needs to happen before
container_output_destroy, because container_output_destroy sets the
sway_output to NULL and sway_output is used in IPC.
2018-06-26 20:14:58 +10:00
Ryan Dwyer 834805f5e2 Fix crash when disconnecting output
We were freeing the sway_output immediately upon disconnect which left
a dangling pointer in the output's container. It then tried to use the
pointer when the container is freed.

We don't need to store the sway_output in an output's container which is
destroying, so the fix is to set the pointer to NULL and remove the use
in container_free.

Also added an arrange when the output is disconnected for good measure.
2018-06-26 19:40:42 +10:00
Ryan Dwyer 50190bc760 Rename view's free callback to destroy 2018-06-26 13:18:33 +10:00
Ryan Dwyer 7a922c65aa Damage output when a fullscreen view unmaps
Also moved the arranging into view_unmap to avoid excessive code
duplication.
2018-06-26 13:15:45 +10:00
Ryan Dwyer 9b15e81cff Fix potential crash when fullscreen view unmaps
It happened when a view is a grandchild or deeper of the workspace, is
fullscreen, and unmaps. The workspace would not be included in the
transaction and its pointer to the fullscreen view was left dangling.
2018-06-25 16:41:31 +10:00
Ryan Dwyer a3976e2659 Fix another crash when moving out of stacks or tabs 2018-06-24 23:07:52 +10:00
Ryan Dwyer b864ac0149 Fix crash when unmapping a view with reapable parents
container_destroy was calling container_reap_empty, which calls
container_destroy and so on. Eventually the original container_destroy
would return a NULL pointer to the caller which caused a crash.

This also fixes an arrange on the wrong container when moving views in
and out of stacks.
2018-06-24 15:50:53 +10:00
Ryan Dwyer 38398e2d77 Implement atomic layout updates for tree operations
This implements atomic layout updates for when views map, reparent or
unmap.
2018-06-23 16:24:11 +10:00
Ryan Dwyer 1c89f32533 Preserve buffers during transactions
* Also fix parts of the rendering where it was rendering the pending
state instead of current.
2018-06-18 20:42:12 +10:00
Ryan Dwyer 9e96cfd310 Merge remote-tracking branch 'upstream/master' into atomic 2018-06-11 11:03:43 +10:00
Drew DeVault 867fb6aedb
Merge pull request #2124 from emersion/drag-icons
Render drag icons
2018-06-09 10:50:34 -07:00
Nate Symer 6a910b9ba5 Implement gaps (PR #2047) 2018-06-09 09:34:56 -04:00
emersion cfd02918c0
Render drag icons 2018-06-09 13:26:03 +01:00
Ryan Dwyer bb66e6d578 Refactor everything that needs to arrange windows
* The arrange_foo functions are now replaced with arrange_and_commit, or
with manually created transactions and arrange_windows x2.
* The arrange functions are now only called from the highest level
functions rather than from both high level and low level functions.
* Due to the previous point, view_set_fullscreen_raw and
view_set_fullscreen are both merged into one function again.
* Floating and fullscreen are now working with transactions.
2018-06-09 10:11:25 +10:00
Ryan Dwyer f9e6d703d2 Make main properties be the pending state 2018-06-09 10:08:43 +10:00
Ryan Dwyer 59c9488701 WIP: Atomic layout updates ground work 2018-06-09 10:08:43 +10:00
Brian Ashworth e2b2fb0a0e Switch restore workspaces to a nested for-loop 2018-06-08 13:08:00 -04:00
Brian Ashworth 5c9a917df9 Restore workspaces to outputs based on priority 2018-06-08 13:08:00 -04:00
emersion 07bee8cffe
Merge pull request #2084 from RedSoxFan/runtime-var-expansion
Runtime variable expansion
2018-06-07 19:29:26 +01:00
Brian Ashworth e072fbc6d9 Switch output storing from list_t to wl_list 2018-06-06 20:11:24 -04:00
Brian Ashworth a0bbe67076 Address emersions comments on output re-enabling 2018-06-06 20:11:24 -04:00
Brian Ashworth a1b5b93d29 Store sway_outputs so that they can be reenabled 2018-06-06 20:11:24 -04:00
Brian Ashworth 82b3b587dd Remove tab/stack check for focusing after a split 2018-06-06 19:38:38 -04:00
Brian Ashworth e7261e2917 Fix focusing after splitting tabs/stacks 2018-06-06 16:41:19 -04:00
Brian Ashworth 067fe9d047 Support runtime var expansion and set at runtime 2018-06-05 10:08:00 -04:00
Brian Ashworth 9aaac8b8c8 Fix movement crashes/issues 2018-06-05 01:13:27 -04:00
Ryan Dwyer d02e9aa4bc Fix initial workspace orientation on a rotated output 2018-06-03 23:39:09 +10:00
emersion 8e3d19aad2
Merge pull request #2096 from kupospelov/fix-title-update
Fix view title update order
2018-06-03 09:20:57 +01:00
Ryan Dwyer 8289e30308 Fix potential crash when destroying workspace
`_container_destroy` emits a destroy event, and any listener for this
event should have access to the full container, not a half destroyed
one.

`_container_destroy` also destroys the swayc, so we have to grab a
reference to the sway_workspace so we can free it afterwards.

This also fixes a memory leak where the floating container wasn't freed.

Fixes #2092.
2018-06-03 10:28:24 +10:00
Konstantin Pospelov e6baac4297 Fix view title update order
This commit fixes the function call order to make sure that the title
texture is updated using the relevant global font size.
2018-06-03 00:32:18 +03:00
Ryan Dwyer 3f1cfd547e Fix top border when a view is initially floating
Fixes #2085.
2018-06-02 11:45:16 +10:00
Ryan Dwyer a2c1cb9072 Fix mpv damage issue when unfullscreening into floating 2018-06-01 23:14:58 +10:00
Ryan Dwyer f24087d104 Fix fullscreen position 2018-06-01 23:14:58 +10:00
Ryan Dwyer 97672295ed Don't unmaximize floating views 2018-06-01 23:14:58 +10:00
Ryan Dwyer 40af5d81a1 Fix getting adjacent output 2018-06-01 23:14:58 +10:00
Ryan Dwyer d4ed204d4d Remove container_self_or_parent_floating 2018-06-01 23:14:58 +10:00
Ryan Dwyer 70f5d6fcf3 Rename container_set_geometry_from_view 2018-06-01 23:14:58 +10:00
Ryan Dwyer e4e912ea91 Store swayc coordinates as layout-local 2018-06-01 23:14:58 +10:00
Ryan Dwyer 02de2a6f65 Rename set_maximized functions to set_tiled 2018-06-01 23:14:58 +10:00
Ryan Dwyer dc83b158e1 Fix issues with sticky containers and workspaces
* Attach sticky containers to new workspaces when switching
* Fire the close event *before* we start destroying the workspace to
prevent a crash

Because the sticky container now follows the visible workspace, this
simplifies the rendering and container_at logic.
2018-06-01 23:14:58 +10:00
Ryan Dwyer 13a4b0512e Fix unfullscreening a floating view 2018-06-01 23:14:58 +10:00
Ryan Dwyer aaba7642b3 Replace is_floating boolean with function 2018-06-01 23:14:58 +10: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 f3ab895916 Implement floating enable 2018-06-01 23:14:58 +10:00
emersion c47d6cb1c4
Merge pull request #2081 from RedSoxFan/fix-2077
Send reparent events in container_split
2018-06-01 10:36:47 +01:00
Brian Ashworth 8237d944d4 Fix move perpendicular segfault 2018-06-01 01:12:10 -04:00
Brian Ashworth cca587b21f Send reparent events in container_split 2018-05-31 23:47:21 -04:00
Brian Ashworth e13c94f2dd Fix typo 2018-05-31 12:07:54 -04:00
Brian Ashworth 633bee9019 Fix moving out of tab/stack when only child 2018-05-31 11:51:00 -04:00
Brian Ashworth 3b90b55666 Notify of subtree change 2018-05-29 11:27:04 -04:00
Brian Ashworth 103a302fa4 Fix moving out of a tabbed/stacked workspace 2018-05-29 11:21:55 -04:00
Brian Ashworth a66fd74a54 Fix breaking out of tabs/stacks 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
emersion 1071785f56
Merge pull request #2060 from RedSoxFan/focus-wrapping
Implement focus_wrapping
2018-05-28 10:30:11 +01:00
emersion 015878e5db
Merge pull request #2058 from RyanDwyer/refactor-parse-title-format
Refactor parse_title_format
2018-05-28 09:18:07 +01:00
Brian Ashworth 46da1dc32b Implement focus_wrapping 2018-05-27 23:20:21 -04:00
Ryan Dwyer 7c7d24600b Fix ancestor typos 2018-05-28 12:45:42 +10:00
Ryan Dwyer 9df1432f56 Refactor parse_title_format
Don't read properties until needed, and do it with less lines of code.
2018-05-28 12:03:43 +10:00
Brian Ashworth fd137c4f05 Send workspace::move in container_output_destroy 2018-05-27 12:27:18 -04:00
emersion 9c0cc98d07
Don't move empty workspaces when output is destroyed 2018-05-27 16:58:31 +01:00
Ryan Dwyer 8fda41dab5
Merge branch 'master' into cmd-swap 2018-05-28 00:14:22 +10:00
Ryan Dwyer d3dd7e5bae Rename view_get_type to view_get_shell 2018-05-27 22:02:00 +10:00
Ryan Dwyer 51865c00c8 Add %app_id to title_format 2018-05-27 09:50:38 +10:00
Brian Ashworth 569f4e0e4c Implement swap command 2018-05-26 11:05:02 -04:00
Drew DeVault ab74c95d56
Merge pull request #2036 from RyanDwyer/workspace-switch-on-map
Switch workspace if required when mapping a view
2018-05-25 08:47:08 -04:00
Drew DeVault daf328d054
Merge pull request #2033 from RyanDwyer/arrange-after-flatten
Arrange views after flattening the parent
2018-05-25 08:43:57 -04:00
Drew DeVault a268a0c2ae
Merge pull request #2034 from RyanDwyer/cleanup-container-titles
Clean up container title functions
2018-05-25 08:41:01 -04:00
Ryan Dwyer f32a002401 Switch workspace if required when mapping a view
If a view is created on a workspace that wasn't visible, switch to it.

Fixes #1879.
2018-05-25 22:28:01 +10:00
Ryan Dwyer e496cc99f8 Fix focus bug when moving between outputs
When moving focus left or right to an adjacent output, only select the
first or last child in the new workspace if the workspace's layout is
horizontalish. If it's a verticalish layout, use the last focused
container.
2018-05-25 21:39:48 +10:00
Ryan Dwyer db38b9bbf3 Clean up container title functions
* Add and use lenient_strcat and lenient_strncat functions
* Rename `concatenate_child_titles` function as that's no longer what it
does
* Rename `container_notify_child_title_changed` because we only need to
notify that the tree structure has changed, not titles
* Don't notify parents when a child changes its title
* Update ancestor titles when changing a container's layout
	* Eg. create nested tabs and change the inner container to stacking
* No need to store tree presentation in both container->name and
formatted_title
2018-05-25 21:07:59 +10:00
Ryan Dwyer 320703fdca Arrange views after flattening the parent
Fixes #2029.
2018-05-25 16:42:55 +10:00
Ryan Dwyer c9630975da Fix crash in move workspace to output command
Fixes #2026.
2018-05-24 23:01:17 +10:00
Ryan Dwyer cdbae9a5e9 Fix nested tabs
Fixes #2023.
2018-05-24 17:38:31 +10:00
Ryan Dwyer 5354988317 Implement clicking stacked title bars 2018-05-22 08:43:00 +10:00
Ryan Dwyer f6c3682c05 Use constants for titlebar dimensions 2018-05-22 08:27:42 +10:00
Ryan Dwyer 664169fbf1 Implement stacked layout 2018-05-22 08:27:24 +10:00
Brian Ashworth 0273c6438c Fix hide_edge_borders smart for tabs and stacks 2018-05-21 13:18:18 -04:00
Ryan Dwyer 5ab4930185 Fix tab border issues 2018-05-21 20:16:56 +10:00
Ryan Dwyer 4672cb7ccf Use class or app_id in tree representation 2018-05-21 20:16:56 +10:00
Ryan Dwyer efc07fb3d4 Don't track damage for views on inactive tabs 2018-05-21 20:16:56 +10:00
Ryan Dwyer bd79584f65 Add assertion in container_at_view 2018-05-21 20:16:56 +10:00
Ryan Dwyer c08f9bf257 Implement tabbed layout 2018-05-21 20:16:56 +10:00
Ryan Dwyer c4ea2b51f6 Fix hide_edge_borders constraints
When checking if a border is on the edge, the check should be done
against the workspace rather than the output.
2018-05-21 13:59:01 +10:00
Ryan Dwyer 9fd28aea8c Rebuild textures if needed when moving a container
When moving a container to an output which has a different scale than
the previous, rebuild the title and marks textures at the new scale.

Fixes #1999.
2018-05-19 23:33:36 +10:00
Ryan Dwyer ebb0d051db Fix many border opacity issues 2018-05-17 08:29:14 +10:00
Ryan Dwyer 69ac7f73e7 Destroy marks textures when view destroyed 2018-05-17 08:29:14 +10:00
Ryan Dwyer b351d0a64a Set textures to null when destroying 2018-05-17 08:29:14 +10:00
Ryan Dwyer 5384fdcbc6 Don't show marks which start with an underscore 2018-05-17 08:29:14 +10:00
Ryan Dwyer 0e2cc0af30 Implement show_marks 2018-05-17 08:29:14 +10:00
Ryan Dwyer fc96f004d2 Don't steal focus when a view changes its title
Fixes #1989
2018-05-16 20:29:04 +10:00
Ryan Dwyer 22d38600d0 Implement marks 2018-05-15 11:18:27 +10:00
Brian Ashworth 9ba0dca7ba
Merge branch 'master' into fix-1975 2018-05-14 09:06:23 -04:00
emersion 95a10dd4f3
Kill wl_shell 2018-05-14 13:26:10 +01:00
Brian Ashworth 3488fbc859 Fix y and height for a hidden top normal border 2018-05-14 01:46:53 -04:00
Brian Ashworth 34b864fb17
Merge branch 'master' into fix-1975 2018-05-14 00:28:21 -04:00
Brian Ashworth 6ff7c52736 Fix titles and detect edges for hide_edge_borders 2018-05-14 00:20:34 -04:00
Ryan Dwyer 92b8497a0b Fix crash when launching programs from dmenu 2018-05-14 11:48:15 +10:00
Ryan Dwyer bffcb496cc Revert "Revert "Merge pull request #1953 from RyanDwyer/criteria-focused""
This reverts commit ac0e62584f.

This reimplements the criteria __focused__ commit in preparation for
fixing a known bug.
2018-05-14 11:38:09 +10:00