aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/handlers.c9
-rw-r--r--sway/handlers.h1
-rw-r--r--sway/layout.c11
-rw-r--r--sway/main.c3
4 files changed, 20 insertions, 4 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index f183c418..d2d8c5a0 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -27,6 +27,15 @@ void handle_output_resolution_change(wlc_handle output, const struct wlc_size *f
arrange_windows(&root_container, -1, -1);
}
+void handle_output_focused(wlc_handle output, bool focus) {
+ swayc_t *c = get_swayc_for_handle(output, &root_container);
+ if (!c) return;
+ if (focus) {
+ unfocus_all(&root_container);
+ focus_view(c);
+ }
+}
+
bool handle_view_created(wlc_handle view) {
add_view(view);
return true;
diff --git a/sway/handlers.h b/sway/handlers.h
index 331be725..9792b6d7 100644
--- a/sway/handlers.h
+++ b/sway/handlers.h
@@ -7,6 +7,7 @@
bool handle_output_created(wlc_handle output);
void handle_output_destroyed(wlc_handle output);
void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to);
+void handle_output_focused(wlc_handle output, bool focus);
bool handle_view_created(wlc_handle view);
void handle_view_destroyed(wlc_handle view);
diff --git a/sway/layout.c b/sway/layout.c
index 08d1952c..ccf29f34 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -44,10 +44,16 @@ void arrange_windows(swayc_t *container, int width, int height) {
sway_log(L_DEBUG, "Arranging output at %d", x);
child->x = x;
child->y = y;
- arrange_windows(child, child->width, child->height);
+ arrange_windows(child, -1, -1);
x += child->width;
}
return;
+ case C_OUTPUT:
+ container->width = width;
+ container->height = height;
+ x -= container->x;
+ y -= container->y;
+ break;
case C_VIEW:
{
struct wlc_geometry geometry = {
@@ -342,9 +348,8 @@ void add_output(wlc_handle output) {
add_child(container, workspace);
sway_log(L_DEBUG, "Added workspace %s for output %d", workspace->name, output);
- workspace_switch(workspace);
-
if (root_container.focused == NULL) {
+ workspace_switch(workspace);
unfocus_all(&root_container);
focus_view(workspace);
}
diff --git a/sway/main.c b/sway/main.c
index af8c6ed1..f84451de 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -17,7 +17,8 @@ int main(int argc, char **argv) {
.output = {
.created = handle_output_created,
.destroyed = handle_output_destroyed,
- .resolution = handle_output_resolution_change
+ .resolution = handle_output_resolution_change,
+ .focus = handle_output_focused
},
.view = {
.created = handle_view_created,