mirror of
https://github.com/swaywm/sway.git
synced 2024-11-13 05:54:11 +01:00
refactored view visibility
- replace visibilty mask integers with an enum - set output's visibilty mask on creation - added update_visibility to manually update a containers visibility (e.g. when it moved to an invisible workspace)
This commit is contained in:
parent
1efda79bf2
commit
f22c937953
@ -56,6 +56,11 @@ struct sway_container {
|
|||||||
struct sway_container *focused;
|
struct sway_container *focused;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum view_visibility {
|
||||||
|
INVISIBLE = 1,
|
||||||
|
VISIBLE = 2
|
||||||
|
};
|
||||||
|
|
||||||
// Container Creation
|
// Container Creation
|
||||||
|
|
||||||
swayc_t *new_output(wlc_handle handle);
|
swayc_t *new_output(wlc_handle handle);
|
||||||
@ -106,4 +111,7 @@ void container_map(swayc_t *, void (*f)(swayc_t *, void *), void *);
|
|||||||
void set_view_visibility(swayc_t *view, void *data);
|
void set_view_visibility(swayc_t *view, void *data);
|
||||||
void reset_gaps(swayc_t *view, void *data);
|
void reset_gaps(swayc_t *view, void *data);
|
||||||
|
|
||||||
|
|
||||||
|
void update_visibility(swayc_t *container);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -520,16 +520,25 @@ void set_view_visibility(swayc_t *view, void *data) {
|
|||||||
if (!ASSERT_NONNULL(view)) {
|
if (!ASSERT_NONNULL(view)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t *p = data;
|
uint32_t mask = *(uint32_t *)data;
|
||||||
if (view->type == C_VIEW) {
|
if (view->type == C_VIEW) {
|
||||||
wlc_view_set_mask(view->handle, *p);
|
wlc_view_set_mask(view->handle, mask);
|
||||||
if (*p == 2) {
|
if (mask & VISIBLE) {
|
||||||
wlc_view_bring_to_front(view->handle);
|
wlc_view_bring_to_front(view->handle);
|
||||||
} else {
|
} else {
|
||||||
wlc_view_send_to_back(view->handle);
|
wlc_view_send_to_back(view->handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view->visible = (*p == 2);
|
view->visible = mask & VISIBLE;
|
||||||
|
sway_log(L_DEBUG, "Container %p is now %s", view, view->visible ? "visible" : "invisible");
|
||||||
|
}
|
||||||
|
|
||||||
|
void update_visibility(swayc_t *container) {
|
||||||
|
swayc_t *ws = swayc_active_workspace_for(container);
|
||||||
|
bool visible = ws->parent->focused == container;
|
||||||
|
uint32_t mask = visible ? VISIBLE : INVISIBLE;
|
||||||
|
sway_log(L_DEBUG, "Setting visibility of container %p to %s", container, visible ? "visible" : "invisible");
|
||||||
|
container_map(ws, set_view_visibility, &mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_gaps(swayc_t *view, void *data) {
|
void reset_gaps(swayc_t *view, void *data) {
|
||||||
|
@ -28,12 +28,11 @@ static void update_focus(swayc_t *c) {
|
|||||||
if (parent->focused) {
|
if (parent->focused) {
|
||||||
swayc_t *ws = parent->focused;
|
swayc_t *ws = parent->focused;
|
||||||
// hide visibility of old workspace
|
// hide visibility of old workspace
|
||||||
uint32_t mask = 1;
|
uint32_t mask = INVISIBLE;
|
||||||
container_map(ws, set_view_visibility, &mask);
|
container_map(ws, set_view_visibility, &mask);
|
||||||
// set visibility of new workspace
|
// set visibility of new workspace
|
||||||
mask = 2;
|
mask = VISIBLE;
|
||||||
container_map(c, set_view_visibility, &mask);
|
container_map(c, set_view_visibility, &mask);
|
||||||
wlc_output_set_mask(parent->handle, 2);
|
|
||||||
destroy_workspace(ws);
|
destroy_workspace(ws);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -45,8 +44,8 @@ static void update_focus(swayc_t *c) {
|
|||||||
// for example, stacked and tabbing change stuff.
|
// for example, stacked and tabbing change stuff.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
c->parent->focused = c;
|
||||||
}
|
}
|
||||||
c->parent->focused = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool move_focus(enum movement_direction direction) {
|
bool move_focus(enum movement_direction direction) {
|
||||||
|
@ -90,6 +90,9 @@ swayc_t *container_under_pointer(void) {
|
|||||||
static bool handle_output_created(wlc_handle output) {
|
static bool handle_output_created(wlc_handle output) {
|
||||||
swayc_t *op = new_output(output);
|
swayc_t *op = new_output(output);
|
||||||
|
|
||||||
|
// Visibilty mask to be able to make view invisible
|
||||||
|
wlc_output_set_mask(output, VISIBLE);
|
||||||
|
|
||||||
if (!op) {
|
if (!op) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user