Commit Graph

197 Commits (10646eb0021403c1f1448339603b24c50da0e604)

Author SHA1 Message Date
Orestis Floros ed67eaca2c
Update EWMH properties on workspace move
Closes #3965
Fixes #4001
2020-04-10 04:40:11 +02:00
xzfc 1f0c628cde
clang-format: bring back ForeachMacros (#3948)
* clang-format: bring back ForeachMacros

ForeachMacros was disabled in 4211274fcd
due to the breakage of include/queue.h. The currently used version,
clang-format-6.0 doesn't break it.

* Add curly braces

Co-authored-by: Orestis Floros <orestisflo@gmail.com>
2020-02-19 11:31:09 +01:00
Albert Safin ff73ddeeee extract_workspace_names_from_bindings: handle optional flags
fixes #3527
2019-09-23 08:21:30 +00:00
Antoine 3b88e41dd8 move workspace to output: don’t create duplicatively numbered workspaces (#3746)
fixes #3745
2019-08-08 07:43:01 +02:00
Orestis Floros c9efa6dffe
Call all ewmh_update_* functions together when necessary
The testcase is changed because it was actually incorrect. Easy to
verify because:
> _NET_CURRENT_DESKTOP
> …
> The index of the current desktop. This is always an integer between 0
> and _NET_NUMBER_OF_DESKTOPS - 1.

Fixes #3696.
Also updates the viewports.

Finally, fixes an issue with _NET_CURRENT_DESKTOP not being updated
after a workspace rename. Example:
- workspaces 1, 2, 3
- rename workspace 1 to 5
- All workspaces changed their index but _NET_CURRENT_DESKTOP was not
updated
2019-05-03 16:19:11 +03:00
Orestis Floros d4e4cbfd25
workspace_move_to_output: Avoid operations when workspace already at destination
Closes #3635.
Probably the bug can still happen when a tree_close_internal happens
inside a workspace_show but modifying the code to avoid them seems to
not be worth it.
2019-03-22 10:47:49 +02:00
Orestis Floros 351d891f4c
get_output_for_con: Assert result != NULL
- The result from con_get_output was always not NULL because
con_get_output asserts so
- get_output_by_name should always be able to get an output from the
corresponding container
- workspace_move_to_output doesn't return bool anymore since it can't
fail
2019-03-22 03:10:00 +02:00
Orestis Floros d0ab51db85
workspace_move_to_output: Make stylistic changes 2019-03-22 03:09:27 +02:00
Orestis Floros 098b0e6976
create_workspace_on_output: send workspace init event
Fixes #3595
Like the issue mentions:
> instead of the newly created workspace (not referenced by variable
> here) the `"init"` event is fired with the current workspace (`ws`).

Plus, there was another issue where duplicate workspace init events
where being sent because of workspace_get().

304-ipc-workspace-init.t: Subtest "move workspace to output" fails with
current next.

Fixes #3631
No event was being sent here:
2d6e09a66a/src/randr.c (L487)

533-randr15.t: I confirmed that SKIP still works if the xrandr command
fails.
Added test fails with current next.
2019-02-23 12:00:55 +02:00
Albert Safin 64ab1f42b7 Preserve back_and_forth during restart
Add new key "previous_workspace_name" to the json dump of the root container.
2018-12-11 20:46:06 +07:00
Ingo Bürk 56bb806b52
Merge pull request #3397 from orestisf1993/randr-enable-disable
Fix bugs in enabling & disabling randr outputs
2018-11-10 21:56:34 +01:00
Ingo Bürk 0ed29f5678
Merge pull request #3448 from orestisf1993/sticky
Fix sticky focus when switching to workspace on different output
2018-10-23 15:31:57 +02:00
Orestis Floros e4d2b38552
Make comment style more consistent 2018-10-13 21:10:10 +03:00
Orestis Floros a65914f338
Fix missing prototypes
i3 will now compile with no warnings when -Wmissing-prototypes is used.
2018-10-13 21:10:10 +03:00
Orestis Floros b09090fa7d
Fix sticky focus when switching to workspace on different output
See the testcase for the exact steps to reproduce the problem.
2018-10-11 12:27:57 +03:00
Orestis Floros 4d21f4cfc2
init_ws_for_output: use workspace_move_to_output
This fixes a crash produced with the following config:
    # i3 config file (v4)
    workspace 1 output $screen1
    workspace 2 output $screen2

    exec --no-startup-id "i3-msg workspace 1, open && i3-msg workspace 2 && xrandr --output $screen2 --off && xrandr --output $screen1 --auto --output $screen2 --auto --right-of $screen1 "

Which results in:
ERROR: AddressSanitizer: heap-use-after-free on address …
READ of size 8 at 0x614000001f48 thread T0
    #0 0x5563df6e73a8 in init_ws_for_output i3/src/randr.c:468
    #1 0x5563df6ef3b4 in randr_query_outputs i3/src/randr.c:940
    #2 0x5563df68dbe1 in handle_screen_change i3/src/handlers.c:450

… is located 264 bytes inside of 448-byte region …
freed by thread T0 here:
    #1 0x5563df634b0a in con_free i3/src/con.c:96
    #2 0x5563df7151e6 in tree_close_internal i3/src/tree.c:344
    #3 0x5563df7280fe in workspace_show i3/src/workspace.c:499
    #4 0x5563df6e7315 in init_ws_for_output i3/src/randr.c:457
    #5 0x5563df6ef3b4 in randr_query_outputs i3/src/randr.c:940
    #6 0x5563df68dbe1 in handle_screen_change i3/src/handlers.c:450

Which is similar to #3228, #3248.
2018-09-12 16:46:47 +03:00
Orestis Floros f908403376
Simplify tree_close_internal
This commit makes multiple changes in tree_close_internal. I didn't
split them because they are not completely independent.

- Remove force_set_focus parameter
This parameter was always set to `false` throughout the code base except
for one case where it was set to `(con == focused)`, when killing a
floating con's parent (the one with type CT_FLOATING_CON). But this case
is not needed anymore since the special handling of CT_FLOATING_CONs in
con_next_focused was removed in #2941.
- Assume that con_next_focused does not returned a container of type
CT_DOCKAREA. This is reasonable since con_next_focused uses the
focus_head stack and has special handling of CT_DOCKAREA containers.
- Remove is_mapped
This variable was only used in the if block towards the end of
tree_close_internal. Ignoring the, now removed, dockarea code and the
use of force_set_focus this block performed only one useful action:
focus the `next` container when `con == focused`. `con == focused` was a
necessary and sufficient condition for the con_activate call:
if `con != focused` we could reach the inner if blocks because of the
other conditions but would never focus another container. If `con ==
focused` then all other conditions would be irrelevant.
- Remove special handling of floating containers
Since the `next` focused container is calculated through the parent for
floating containers, I moved this code to con_next_focused.
Also, because of the removal of force_set_focus, it appears that we can
call con_on_remove_child for floating containers as well.
2018-07-30 19:41:24 +03:00
Orestis Floros bce088679a
Allow multiple assignments of workspaces to outputs
Also makes get_assigned_output work with the primary output:
    workspace X output primary
will now work.

Fixes #555.
2018-07-12 17:07:01 +03:00
Orestis Floros d525eb80ae
Use get_assigned_output for numbers
This prohibits the usage of workspaces assigned to other outputs in
create_workspace_on_output.

Eg, with config:
    workspace 1 output fake-0
    workspace 2 output fake-0
and 2 screens workspace 2 would be used for the second screen even
though it is assigned to the first one.

Also introduces a test for workspace assignments that includes the case
described above and some tests that don't fail in the next branch.
2018-06-27 14:56:50 +03:00
Orestis Floros bc439de755
Introduce get_assigned_output
This also replaces code in create_workspace_on_output() that is
theoretically more efficient but:
1. It isn't a huge difference since it depends on the number of outputs,
that shouldn't be high.
2. get_assigned_output will be modified and used for #555, then its
logic should be followed in create_workspace_on_output() too.

Another note for create_workspace_on_output: if assigned is not NULL the
condition (assigned != output->con) should never be false, ie if there
is an assigned output to this name, it isn't the current one. This
happens because the current callers check for assignments before calling
create_workspace_on_output().
2018-06-27 14:56:31 +03:00
Oliver Graff e4a184e77e
Workspace renaming: Interpret outputs as nondirectional
Currently when renaming outputs, an output assignment of "left" will
cause the workspace to move left. Treat this assignment as a proper name
instead (even though it is unlikely an output will be named "left").

Move logic for determining output to move to out of
`workspace_move_to_output`

Add test for ignoring direcionality during rename.

Fixes #3208.
2018-04-04 13:37:59 -04:00
Orestis Floros 0b5799412a
Introduce get_existing_workspace_by_num 2018-03-28 15:18:43 +03:00
Orestis Floros 6a2728ba79
Introduce get_existing_workspace_by_name 2018-03-28 15:18:43 +03:00
Orestis Floros f46bb0396e workspace_show: remove redundant if 2018-03-24 15:15:02 +02:00
Orestis Floros 4097769105 _workspace_show -> workspace_show
a9b57a44a9 removed the extra parameter of
workspace_show.
2018-03-24 14:26:11 +02:00
Ingo Bürk 4b4fba0e74
Merge pull request #3087 from orestisf1993/focus_order
Fix focus order issues when encapsulating workspaces
2018-02-27 07:59:37 +01:00
Orestis Floros cb73fd5e31 Fix focus order issues when encapsulating workspaces
See new tests for an explanation of the problem.
2018-02-26 23:08:57 +02:00
Orestis Floros 60200b1d3c Don't raise floating windows when workspace is shown
From comment:
https://github.com/i3/i3/issues/2990#issuecomment-368345169

To easily reproduce:
1. Open 2 floating windows
2. Focus (with `focus_follows_mouse`) the one behind
3. Move the mouse to the other workspace
4. Move the mouse inside the previous workspace (without it even
touching a window)
2018-02-26 03:26:05 +02:00
Orestis Floros 0c2fbeedc2 Don't raise floating windows when focused because of focus_follows_mouse
Fixes #2990.
2018-01-14 15:45:33 +02:00
Orestis Floros d134745c4f Prevent access of freed workspace in _workspace_show
The bug triggers when _workspace_show calls tree_close_internal and
old == old_focus. Ie, when the old workspace was empty and needs to be
closed but then is accessed as output_push_sticky_windows's argument:
Breakpoint 1, output_push_sticky_windows (to_focus=0x55555589c8a0) at ../../i3/src/output.c:102
102	                    con_move_to_workspace(current, visible_ws, true, false, current != to_focus->parent);
(gdb) print con_exists(to_focus)
$1 = false

The access violation can also be prevented by checking if
con_exists(old_focus) but it shouldn't be necessary: the old_focus
container can only be killed when it is an empty workspace.

With --enable-sanitizers this causes i3 to exit but with
--disable-sanitizers the access violation doesn't reliably cause a crash
and the con_move_to_workspace call continues with:
(gdb) print current != to_focus->parent
$2 = 1

Since current->type is CT_FLOATING_CON and to_focus->type is
CT_WORKSPACE, in this specific case ignore_focus would always be true.
So, in this case, passing NULL instead of old_focus to
output_push_sticky_windows doesn't change the behaviour of i3.

Fixes #3075.
2017-12-10 21:37:43 +02:00
Vladimir Panteleev 30b1ab38b3
Introduce output_primary_name function
Currently simply returns output->name, but this will make it easier to
change how output names are stored in the following commits.

Also replace reading output->name with invocations of
output_primary_name. Code which writes output->name is unchanged. Done
using a mostly mechanical replacement of output->name to
output_primary_name(output).
2017-09-13 08:22:57 +00:00
Michael Stapelberg f354f53435 Ensure all *.[ch] files include config.h
Including config.h is necessary to get e.g. the _GNU_SOURCE define and
any other definitions that autoconf declares. Hence, config.h needs to
be included as the first header in each file.

This is done either via:
1. Including "common.h" (i3bar)
2. Including "libi3.h"
3. Including "all.h" (i3)
4. Including <config.h> directly

Also remove now-unused I3__FILE__, add copyright/license statement
where missing and switch include/all.h to #pragma once.
2016-10-23 21:09:24 +02:00
Ingo Bürk c71f6f8f7c Implement special value 'current' for output. (#2483)
This commit introduces the special 'current' value for outputs in both of

* move con to output current
* move workspace to output current

fixes #2357
2016-09-30 08:28:02 -07:00
Benedikt Heine e35aff5cb9 fix transition from named to numbered workspace 2016-08-24 11:11:50 +02:00
Benedikt Heine 5d6d974c66 remove goto statement
remove goto statement to similarize workspace_next and workspace_prev
2016-08-24 11:11:50 +02:00
Benedikt Heine d979748853 traverse numbered workspaces in correct order 2016-08-24 11:11:50 +02:00
Ingo Bürk a9d8184c73 Determine focused workspace correctly when moving workspace to output.
This patch correctly determines the previously focused workspace on the
target output when moving a workspace to another output. Before, we used
nodes_head for this, which will not actually return the previously focused
workspace, but just the first workspace on that output. Hence, we now use
focus_head instead.

This bug was introduced all the way back in 1e143fea when the feature of
moving workspaces to another output was first implemented.

fixes #2229
2016-02-25 19:12:09 +01:00
Ingo Bürk 328035fb7e Handle the EWMH atom _NET_WM_DESKTOP.
We already claim _NET_WM_DESKTOP support in _NET_SUPPORTED since around 2009,
but haven't actually done anything with it. However, especially pagers like
gnome-panel rely on this property to be updated and many tools, like GTK, want
to use the corresponding client messages to make a window sticky, move it
around etc.

This patch implements full support according to the EWMH spec. This means:

* We set the property on all windows when managing it.
* We keep the property updated on all windows at all times.
* We read and respect the property upon managing a window if it was set before
  mapping the window.
* We react to client messages for it.
* We remove the property on withdrawn windows.

Note that the special value 0xFFFFFFFF, according to the spec, means that the
window shall be shown on all workspaces. We do this by making it sticky and
float it. This shows it on all workspaces at least on the output it is on.

Furthermore, the spec gives us the freedom to ignore _NET_WM_DESKTOP when
managing a window if we have good reason to. In our case, we give window
swallowing a higher priority since the user would likely expect that and we
want to keep placeholder windows only around for as long as we have to.
However, we do prioritize this property over, for example, startup
notifications.

fixes #2153
fixes #1507
fixes #938
2016-01-18 12:13:36 +01:00
Ingo Bürk 0dd71674de Rename tree_close() to tree_close_internal().
It should be clear for callers of this function that this is an internal
function that skips certain validations which might be important. Therefore
we make it clear that this is an internal function by renaming it.

relates to #1761
2015-12-27 20:58:35 -05:00
hwangcc23 dd400ff74b Revise workspace next/prev
See the issue #1798 (http://github.com/i3/i3/issues/1798).

+workspace_next+ as-is cycles through either numbered or named workspaces,
but when it reaches the last numbered/named workspace, it only looks for
named workspaces. This commit changes it: look for named workspaces after
exhausting numbered ones, but also for numbered ones after exhausting
named ones.

Also add a test case 528-workspace-next-prev.t (numbered workspaces and named
workspaces on 2 outputs) for testing this.
2015-10-16 23:25:12 +08:00
Ingo Bürk 6cd6f43d09 Turn "char *" into "const char *" for all command parser functions. 2015-09-28 14:24:08 +02:00
Ingo Bürk 922afe1919 Keep a sticky window focused if it was the focused window on the source workspace.
fixes #1924
2015-09-24 22:10:17 +02:00
Michael Stapelberg 7de15b3815 clang-format
(When will I learn? I need to integrate clang-format into my editor.)
2015-09-14 10:22:43 +02:00
Michael Stapelberg 840ce51bfd Extract workspace names from bindings before reordering.
fixes #1889
2015-09-14 09:28:42 +02:00
Ingo Bürk 1c4c3f06fa Make sure sticky windows pop to the front if they get sticky while not being on a visible workspace.
This commit also reworks the way focusing sticky windows is prevented by not focusing them temporarily at all, but preventing the focus in the first place.
2015-09-13 20:40:20 +02:00
Ingo Bürk 2c338b6ae2 Handle _NET_WM_STATE_STICKY, but only for floating containers. If this atom is set, the floating window will always be automatically moved to the currently active workspace of the output that it is on. This is the equivalent of a sticky note stuck to the monitor.
We will respect this atom upon managing a window as well as when we receive a request that changes the sticky state.

fixes #1455
2015-09-13 20:40:20 +02:00
shdown bc52fae15c libi3: change scalloc() signature to match calloc() 2015-08-03 12:50:13 +03:00
Michael Stapelberg 21d4b2319f Properly clear the urgency hint when set by i3.
fixes #1825
2015-08-02 20:50:14 +02:00
Ingo Bürk 94a09b3cac Added missing newlines in log statements. 2015-06-30 20:48:35 +02:00
Ingo Bürk 52c72e9007 Remove redundant and broken check for '\0'.
fixes #1742
2015-06-09 22:14:56 +02:00