Tweak how swaylock surfaces are handled

Fixes #875
This commit is contained in:
Drew DeVault 2016-09-01 08:34:52 -04:00
parent 416417a54c
commit 38ca94e0ed
2 changed files with 11 additions and 18 deletions

View File

@ -119,27 +119,21 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou
if (!swayc_is_child_of(view, workspace)) { if (!swayc_is_child_of(view, workspace)) {
move_container_to(view, workspace); move_container_to(view, workspace);
} }
// make the view floating so it doesn't rearrange other // make the view floating so it doesn't rearrange other siblings.
// siblings.
if (!view->is_floating) { if (!view->is_floating) {
// Remove view from its current location
destroy_container(remove_child(view)); destroy_container(remove_child(view));
// and move it into workspace floating
add_floating(workspace, view); add_floating(workspace, view);
} }
wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true); wlc_view_set_state(view->handle, WLC_BIT_FULLSCREEN, true);
workspace->fullscreen = view; wlc_view_bring_to_front(view->handle);
ipc_event_window(view, "fullscreen_mode"); wlc_view_focus(view->handle);
desktop_shell.is_locked = true; desktop_shell.is_locked = true;
// reset input state
input_init(); input_init();
// set focus if the lockscreen is spawned on the currently arrange_windows(workspace, -1, -1);
// active output
swayc_t *focus_output = swayc_active_output(); swayc_t *focus_output = swayc_active_output();
if (focus_output == output) { if (focus_output == output) {
set_focused_container(view); set_focused_container(view);
} }
arrange_windows(workspace, -1, -1);
list_add(desktop_shell.lock_surfaces, surface); list_add(desktop_shell.lock_surfaces, surface);
wl_resource_set_destructor(surface, lock_surface_destructor); wl_resource_set_destructor(surface, lock_surface_destructor);
} else { } else {

View File

@ -3,6 +3,7 @@
#include "sway/workspace.h" #include "sway/workspace.h"
#include "sway/layout.h" #include "sway/layout.h"
#include "sway/config.h" #include "sway/config.h"
#include "sway/extensions.h"
#include "sway/input_state.h" #include "sway/input_state.h"
#include "sway/ipc-server.h" #include "sway/ipc-server.h"
#include "sway/border.h" #include "sway/border.h"
@ -88,7 +89,6 @@ swayc_t *get_focused_container(swayc_t *parent) {
if (!parent) { if (!parent) {
return swayc_active_workspace(); return swayc_active_workspace();
} }
// get focused container
while (!parent->is_focused && parent->focused) { while (!parent->is_focused && parent->focused) {
parent = parent->focused; parent = parent->focused;
} }
@ -132,24 +132,24 @@ bool set_focused_container(swayc_t *c) {
p->is_focused = false; p->is_focused = false;
} }
// get new focused view and set focus to it.
if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) { if (!(wlc_view_get_type(p->handle) & WLC_BIT_POPUP)) {
// unactivate previous focus
if (focused->type == C_VIEW) { if (focused->type == C_VIEW) {
wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false); wlc_view_set_state(focused->handle, WLC_BIT_ACTIVATED, false);
} }
update_container_border(focused); update_container_border(focused);
// activate current focus
if (c->type == C_VIEW) { if (c->type == C_VIEW) {
wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true); wlc_view_set_state(c->handle, WLC_BIT_ACTIVATED, true);
} }
// set focus if (!desktop_shell.is_locked) {
wlc_view_focus(c->handle); // If the system is locked, we do everything _but_ actually setting
// focus. This includes making our internals think that this view is
// focused.
wlc_view_focus(c->handle);
}
if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) { if (c->parent->layout != L_TABBED && c->parent->layout != L_STACKED) {
update_container_border(c); update_container_border(c);
} }
// rearrange if parent container is tabbed/stacked
swayc_t *parent = swayc_tabbed_stacked_ancestor(c); swayc_t *parent = swayc_tabbed_stacked_ancestor(c);
if (parent != NULL) { if (parent != NULL) {
arrange_backgrounds(); arrange_backgrounds();
@ -174,7 +174,6 @@ bool set_focused_container_for(swayc_t *a, swayc_t *c) {
return false; return false;
} }
swayc_t *find = c; swayc_t *find = c;
// Ensure that a is an ancestor of c
while (find != a && (find = find->parent)) { while (find != a && (find = find->parent)) {
if (find == &root_container) { if (find == &root_container) {
return false; return false;