Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove focus workaround #5529

Merged
merged 1 commit into from
Jul 21, 2023
Merged

Remove focus workaround #5529

merged 1 commit into from
Jul 21, 2023

Conversation

slyshot
Copy link
Contributor

@slyshot slyshot commented Jun 18, 2023

The way cmd_move_direction currently preserves focus is by saving it beforehand, and applying it after. As far as I can tell, the only reason this is required is because move_to_output_directed has unexpected behavior in the case of moving multiple windows otherwise. Since it uses workspace_show in an unusual way(That is, with focus on the other workspace), it ends up focusing on one of the internal windows of the container, instead of the container itself.

I kept workspace_show because the comment before it seems to indicate that it does some important work, even though it doesn't update focus correctly in this case. I'd like this to be looked at from a more experienced eye to tell me whether I'm essentially undoing that work using con_focus, or if the workspace_show is necessary there versus some alternative method of getting those things done. I'll come back on that if nobody else does for a while.

This pull request is a precursor to #5521, since that needs to change focus in tree_move to work as expected.

Copy link
Member

@orestisfl orestisfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please check if this re-introduces #3518?

@orestisfl orestisfl added the waiting Waiting for feedback/changes from the author of the issue/PR. Make sure to notify us with a comment. label Jul 15, 2023
@slyshot
Copy link
Contributor Author

slyshot commented Jul 16, 2023

Testing it, it does not. If I recall correctly, when I was making this, If I left this

i3/src/move.c

Lines 241 to 243 in 6db5af5

con_focus(con);
focused = old_ws;
workspace_show(ws);

without adding the second con_focus afterwards, it did reintroduce that, which is why I added it. My memories a little fuzzy about this, but I think it was because ws_show would descend focus, but never get to focused because the code set it to old_ws. Thanks.

@orestisfl orestisfl removed the waiting Waiting for feedback/changes from the author of the issue/PR. Make sure to notify us with a comment. label Jul 21, 2023
@orestisfl orestisfl self-requested a review July 21, 2023 11:40
Copy link
Member

@orestisfl orestisfl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you. I've quickly tested that indeed focus is not disturbed in any case by applying this patch:

diff --git a/src/commands.c b/src/commands.c
index 009e98bf..53185855 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -1578,6 +1578,7 @@ void cmd_move_direction(I3_CMD, const char *direction_str, long amount, const ch
     owindow *current;
     HANDLE_EMPTY_MATCH;
 
+    Con *initially_focused = focused;
     direction_t direction = parse_direction(direction_str);
 
     const bool is_ppt = mode && strcmp(mode, "ppt") == 0;
@@ -1611,6 +1612,10 @@ void cmd_move_direction(I3_CMD, const char *direction_str, long amount, const ch
         }
     }
 
+    if (focused != initially_focused && con_exists(initially_focused)) {
+        ELOG("GREPME: focus moved\n");
+    }
+
     // XXX: default reply for now, make this a better reply
     ysuccess(true);
 }

and then running the test suite.

@orestisfl orestisfl merged commit 6fe98f7 into i3:next Jul 21, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants