focus change fix for fullscreen, prevent containers from being created on floating windows

This commit is contained in:
taiyu 2015-08-20 18:42:36 -07:00
parent e2046e6aba
commit 2290db9bc3
4 changed files with 22 additions and 15 deletions

View file

@ -445,6 +445,9 @@ static bool _do_split(struct sway_config *config, int argc, char **argv, int lay
}
swayc_t *focused = get_focused_container(&root_container);
if (focused->is_floating) {
return true;
}
if (focused->type == C_WORKSPACE && focused->children->length <= 1) {
/* Case that focus is on an workspace with 0/1 children.change its layout */
sway_log(L_DEBUG, "changing workspace layout");
@ -508,6 +511,7 @@ static bool cmd_fullscreen(struct sway_config *config, int argc, char **argv) {
return false;
}
//get focused view and check current state.
swayc_t *container = get_focused_view(&root_container);
bool current = swayc_is_fullscreen(container);
wlc_view_set_state(container->handle, WLC_BIT_FULLSCREEN, !current);

View file

@ -135,7 +135,7 @@ swayc_t *new_workspace(swayc_t *output, const char *name) {
}
swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) {
if (!ASSERT_NONNULL(child)) {
if (!ASSERT_NONNULL(child) || child->is_floating) {
return NULL;
}
swayc_t *cont = new_swayc(C_CONTAINER, 0);

View file

@ -84,10 +84,13 @@ void set_focused_container(swayc_t *c) {
return;
}
sway_log(L_DEBUG, "Setting focus to %p:%ld", c, c->handle);
// Find previous focused view, and the new focused view, if they are the same return
swayc_t *focused = get_focused_view(&root_container);
swayc_t *workspace = active_workspace;
// Get workspace for c, get that workspaces current focused container.
// if that focsued container is fullscreen dont change focus
swayc_t *workspace = swayc_parent_by_type(c, C_WORKSPACE);
swayc_t *focused = get_focused_view(workspace);
if (swayc_is_fullscreen(focused)) {
return;
}
// update container focus from here to root, making necessary changes along
// the way
@ -101,13 +104,6 @@ void set_focused_container(swayc_t *c) {
p->is_focused = false;
}
// if the workspace is the same, and previous focus is fullscreen, dont
// change focus
sway_log(L_DEBUG,"%p==%p, f:%d", workspace, active_workspace, swayc_is_fullscreen(focused));
if (workspace == active_workspace && swayc_is_fullscreen(focused)) {
return;
}
// get new focused view and set focus to it.
p = get_focused_view(c);
if (p->type == C_VIEW && !(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
@ -137,6 +133,15 @@ void set_focused_container_for(swayc_t *a, swayc_t *c) {
return;
}
}
// Get workspace for c, get that workspaces current focused container.
// if that focsued container is fullscreen dont change focus
swayc_t *workspace = swayc_parent_by_type(c, C_WORKSPACE);
swayc_t *focused = get_focused_view(workspace);
if (swayc_is_fullscreen(focused)) {
return;
}
// Check if we changing a parent container that will see chnage
bool effective = true;
while (find != &root_container) {

View file

@ -420,9 +420,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
}
if (config->focus_follows_mouse && prev_handle != handle) {
// Dont change focus if fullscreen
swayc_t *focused = get_focused_view(view);
if (!swayc_is_fullscreen(focused) && !(pointer_state.l_held || pointer_state.r_held)) {
if (!(pointer_state.l_held || pointer_state.r_held)) {
set_focused_container(container_under_pointer());
}
}