summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-08-10 23:54:23 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-08-10 23:54:23 -0400
commit96d7ff1e19c1e6af47f21764ed613c5ebe53a557 (patch)
tree75566e3fb44600e63c1dbbec3f216425a57e70a6
parentPrevent passing WM keys, improve multihead support (diff)
downloadsway-96d7ff1e19c1e6af47f21764ed613c5ebe53a557.tar.gz
sway-96d7ff1e19c1e6af47f21764ed613c5ebe53a557.tar.zst
sway-96d7ff1e19c1e6af47f21764ed613c5ebe53a557.zip
Slightly better multihead support
-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
27 arrange_windows(&root_container, -1, -1); 27 arrange_windows(&root_container, -1, -1);
28} 28}
29 29
30void handle_output_focused(wlc_handle output, bool focus) {
31 swayc_t *c = get_swayc_for_handle(output, &root_container);
32 if (!c) return;
33 if (focus) {
34 unfocus_all(&root_container);
35 focus_view(c);
36 }
37}
38
30bool handle_view_created(wlc_handle view) { 39bool handle_view_created(wlc_handle view) {
31 add_view(view); 40 add_view(view);
32 return true; 41 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 @@
7bool handle_output_created(wlc_handle output); 7bool handle_output_created(wlc_handle output);
8void handle_output_destroyed(wlc_handle output); 8void handle_output_destroyed(wlc_handle output);
9void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to); 9void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to);
10void handle_output_focused(wlc_handle output, bool focus);
10 11
11bool handle_view_created(wlc_handle view); 12bool handle_view_created(wlc_handle view);
12void handle_view_destroyed(wlc_handle view); 13void 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) {
44 sway_log(L_DEBUG, "Arranging output at %d", x); 44 sway_log(L_DEBUG, "Arranging output at %d", x);
45 child->x = x; 45 child->x = x;
46 child->y = y; 46 child->y = y;
47 arrange_windows(child, child->width, child->height); 47 arrange_windows(child, -1, -1);
48 x += child->width; 48 x += child->width;
49 } 49 }
50 return; 50 return;
51 case C_OUTPUT:
52 container->width = width;
53 container->height = height;
54 x -= container->x;
55 y -= container->y;
56 break;
51 case C_VIEW: 57 case C_VIEW:
52 { 58 {
53 struct wlc_geometry geometry = { 59 struct wlc_geometry geometry = {
@@ -342,9 +348,8 @@ void add_output(wlc_handle output) {
342 add_child(container, workspace); 348 add_child(container, workspace);
343 sway_log(L_DEBUG, "Added workspace %s for output %d", workspace->name, output); 349 sway_log(L_DEBUG, "Added workspace %s for output %d", workspace->name, output);
344 350
345 workspace_switch(workspace);
346
347 if (root_container.focused == NULL) { 351 if (root_container.focused == NULL) {
352 workspace_switch(workspace);
348 unfocus_all(&root_container); 353 unfocus_all(&root_container);
349 focus_view(workspace); 354 focus_view(workspace);
350 } 355 }
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) {
17 .output = { 17 .output = {
18 .created = handle_output_created, 18 .created = handle_output_created,
19 .destroyed = handle_output_destroyed, 19 .destroyed = handle_output_destroyed,
20 .resolution = handle_output_resolution_change 20 .resolution = handle_output_resolution_change,
21 .focus = handle_output_focused
21 }, 22 },
22 .view = { 23 .view = {
23 .created = handle_view_created, 24 .created = handle_view_created,