handle_view_state_request
This commit is contained in:
parent
d64bff69bb
commit
c024f06631
|
@ -10,16 +10,19 @@ extern swayc_t root_container;
|
||||||
void init_layout(void);
|
void init_layout(void);
|
||||||
|
|
||||||
void add_child(swayc_t *parent, swayc_t *child);
|
void add_child(swayc_t *parent, swayc_t *child);
|
||||||
//Returns parent container wihch needs to be rearranged.
|
//Returns parent container which needs to be rearranged.
|
||||||
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
||||||
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
||||||
swayc_t *remove_child(swayc_t *parent, swayc_t *child);
|
swayc_t *remove_child(swayc_t *parent, swayc_t *child);
|
||||||
|
|
||||||
|
//Layout
|
||||||
|
void arrange_windows(swayc_t *container, int width, int height);
|
||||||
|
|
||||||
|
//Focus
|
||||||
void unfocus_all(swayc_t *container);
|
void unfocus_all(swayc_t *container);
|
||||||
void focus_view(swayc_t *view);
|
void focus_view(swayc_t *view);
|
||||||
void arrange_windows(swayc_t *container, int width, int height);
|
void focus_view_for(swayc_t *ancestor, swayc_t *container);
|
||||||
swayc_t *get_focused_container(swayc_t *parent);
|
swayc_t *get_focused_container(swayc_t *parent);
|
||||||
|
|
||||||
swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent);
|
swayc_t *get_swayc_for_handle(wlc_handle handle, swayc_t *parent);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -10,7 +10,7 @@ typedef enum {
|
||||||
|
|
||||||
void init_log(int verbosity);
|
void init_log(int verbosity);
|
||||||
void sway_log_colors(int mode);
|
void sway_log_colors(int mode);
|
||||||
void sway_log(int verbosity, char* format, ...);
|
void sway_log(int verbosity, char* format, ...) __attribute__((format(printf,2,3)));
|
||||||
void sway_abort(char* format, ...);
|
void sway_abort(char* format, ...)__attribute__((format(printf,1,2)));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -130,6 +130,38 @@ static void handle_view_geometry_request(wlc_handle view, const struct wlc_geome
|
||||||
// deny that shit
|
// deny that shit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_view_state_request(wlc_handle view, enum wlc_view_state_bit state, bool toggle) {
|
||||||
|
switch(state) {
|
||||||
|
case WLC_BIT_FULLSCREEN:
|
||||||
|
{
|
||||||
|
//I3 just lets it become fullscreen
|
||||||
|
wlc_view_set_state(view,state,toggle);
|
||||||
|
swayc_t *c = get_swayc_for_handle(view, &root_container);
|
||||||
|
sway_log(L_DEBUG, "setting view %ld %s, fullscreen %d",view,c->name,toggle);
|
||||||
|
if (c) {
|
||||||
|
arrange_windows(c->parent, -1, -1);
|
||||||
|
//Set it as focused window for that workspace if its going
|
||||||
|
//fullscreen
|
||||||
|
if (toggle) {
|
||||||
|
swayc_t *ws = c;
|
||||||
|
while (ws->type != C_WORKSPACE) {
|
||||||
|
ws = ws->parent;
|
||||||
|
}
|
||||||
|
//Set ws focus to c
|
||||||
|
focus_view_for(ws, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WLC_BIT_MAXIMIZED:
|
||||||
|
case WLC_BIT_RESIZING:
|
||||||
|
case WLC_BIT_MOVING:
|
||||||
|
case WLC_BIT_ACTIVATED:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
|
static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers
|
||||||
*modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) {
|
*modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) {
|
||||||
|
@ -239,7 +271,8 @@ struct wlc_interface interface = {
|
||||||
.destroyed = handle_view_destroyed,
|
.destroyed = handle_view_destroyed,
|
||||||
.focus = handle_view_focus,
|
.focus = handle_view_focus,
|
||||||
.request = {
|
.request = {
|
||||||
.geometry = handle_view_geometry_request
|
.geometry = handle_view_geometry_request,
|
||||||
|
.state = handle_view_state_request
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
.keyboard = {
|
.keyboard = {
|
||||||
|
@ -250,6 +283,6 @@ struct wlc_interface interface = {
|
||||||
.button = handle_pointer_button
|
.button = handle_pointer_button
|
||||||
},
|
},
|
||||||
.compositor = {
|
.compositor = {
|
||||||
.ready = handle_wlc_ready
|
.ready = handle_wlc_ready
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -238,15 +238,17 @@ void unfocus_all(swayc_t *container) {
|
||||||
|
|
||||||
void focus_view(swayc_t *view) {
|
void focus_view(swayc_t *view) {
|
||||||
sway_log(L_DEBUG, "Setting focus for %p", view);
|
sway_log(L_DEBUG, "Setting focus for %p", view);
|
||||||
while (view != &root_container) {
|
swayc_t *c = view;
|
||||||
view->parent->focused = view;
|
//Set focus from root to view
|
||||||
view = view->parent;
|
while (c != &root_container) {
|
||||||
|
c->parent->focused = c;
|
||||||
|
c = c->parent;
|
||||||
}
|
}
|
||||||
|
//Set output
|
||||||
|
wlc_output_focus(c->focused->handle);
|
||||||
|
//get focus for views focused window
|
||||||
while (view && view->type != C_VIEW) {
|
while (view && view->type != C_VIEW) {
|
||||||
view = view->focused;
|
view = view->focused;
|
||||||
if (view && view->type == C_OUTPUT) {
|
|
||||||
wlc_output_focus(view->handle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (view) {
|
if (view) {
|
||||||
wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true);
|
wlc_view_set_state(view->handle, WLC_BIT_ACTIVATED, true);
|
||||||
|
@ -254,3 +256,20 @@ void focus_view(swayc_t *view) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void focus_view_for(swayc_t *top, swayc_t *view) {
|
||||||
|
swayc_t *find = view;
|
||||||
|
//Make sure top is a ancestor of view
|
||||||
|
while (find != top) {
|
||||||
|
if (find == &root_container) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
find = find->parent;
|
||||||
|
}
|
||||||
|
//Set focus for top to go to view
|
||||||
|
while (view != top) {
|
||||||
|
view->parent->focused = view;
|
||||||
|
view = view->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue