aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-11-25 10:59:49 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2017-11-25 11:19:25 -0500
commitce1936bc65d01502e3a5f8681bb039cb95e82e0c (patch)
treefcdeb554df5aaf30aff7723171e0dfe0bf097420 /sway/desktop
parentRemove IPC_GET_PIXELS (diff)
downloadsway-ce1936bc65d01502e3a5f8681bb039cb95e82e0c.tar.gz
sway-ce1936bc65d01502e3a5f8681bb039cb95e82e0c.tar.zst
sway-ce1936bc65d01502e3a5f8681bb039cb95e82e0c.zip
Arrange windows on desktop
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/output.c15
-rw-r--r--sway/desktop/xdg_shell_v6.c20
2 files changed, 29 insertions, 6 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 9e0c18e4..033a4c44 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -8,6 +8,7 @@
8#include <wlr/render/matrix.h> 8#include <wlr/render/matrix.h>
9#include "log.h" 9#include "log.h"
10#include "sway/container.h" 10#include "sway/container.h"
11#include "sway/layout.h"
11#include "sway/output.h" 12#include "sway/output.h"
12#include "sway/server.h" 13#include "sway/server.h"
13#include "sway/view.h" 14#include "sway/view.h"
@@ -25,10 +26,9 @@ static void output_frame_view(swayc_t *view, void *data) {
25 return; 26 return;
26 } 27 }
27 // TODO 28 // TODO
28 // - Force sway's resolution
29 // - Deal with wlr_output_layout 29 // - Deal with wlr_output_layout
30 int width = surface->current->width; 30 int width = sway_view->swayc->width;
31 int height = surface->current->height; 31 int height = sway_view->swayc->height;
32 int render_width = width * wlr_output->scale; 32 int render_width = width * wlr_output->scale;
33 int render_height = height * wlr_output->scale; 33 int render_height = height * wlr_output->scale;
34 double ox = view->x, oy = view->y; 34 double ox = view->x, oy = view->y;
@@ -101,6 +101,12 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
101 soutput->last_frame = now; 101 soutput->last_frame = now;
102} 102}
103 103
104static void output_resolution_notify(struct wl_listener *listener, void *data) {
105 struct sway_output *soutput = wl_container_of(
106 listener, soutput, resolution);
107 arrange_windows(soutput->swayc, -1, -1);
108}
109
104void output_add_notify(struct wl_listener *listener, void *data) { 110void output_add_notify(struct wl_listener *listener, void *data) {
105 struct sway_server *server = wl_container_of(listener, server, output_add); 111 struct sway_server *server = wl_container_of(listener, server, output_add);
106 struct wlr_output *wlr_output = data; 112 struct wlr_output *wlr_output = data;
@@ -113,6 +119,9 @@ void output_add_notify(struct wl_listener *listener, void *data) {
113 119
114 output->frame.notify = output_frame_notify; 120 output->frame.notify = output_frame_notify;
115 wl_signal_add(&wlr_output->events.frame, &output->frame); 121 wl_signal_add(&wlr_output->events.frame, &output->frame);
122
123 output->resolution.notify = output_resolution_notify;
124 wl_signal_add(&wlr_output->events.resolution, &output->resolution);
116} 125}
117 126
118void output_remove_notify(struct wl_listener *listener, void *data) { 127void output_remove_notify(struct wl_listener *listener, void *data) {
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index e2a61ebf..8f1885c1 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -1,15 +1,21 @@
1#define _POSIX_C_SOURCE 199309L 1#define _POSIX_C_SOURCE 199309L
2#include <stdbool.h>
2#include <stdlib.h> 3#include <stdlib.h>
3#include <wayland-server.h> 4#include <wayland-server.h>
4#include <wlr/types/wlr_xdg_shell_v6.h> 5#include <wlr/types/wlr_xdg_shell_v6.h>
5#include "sway/container.h" 6#include "sway/container.h"
7#include "sway/layout.h"
6#include "sway/server.h" 8#include "sway/server.h"
7#include "sway/view.h" 9#include "sway/view.h"
8#include "log.h" 10#include "log.h"
9 11
12static bool assert_xdg(struct sway_view *view) {
13 return sway_assert(view->type == SWAY_XDG_SHELL_V6_VIEW,
14 "Expected xdg shell v6 view!");
15}
16
10static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { 17static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
11 if (!sway_assert(view->type == SWAY_XDG_SHELL_V6_VIEW, 18 if (!assert_xdg(view)) {
12 "xdg get_prop for non-xdg view!")) {
13 return NULL; 19 return NULL;
14 } 20 }
15 switch (prop) { 21 switch (prop) {
@@ -22,6 +28,12 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
22 } 28 }
23} 29}
24 30
31static void set_dimensions(struct sway_view *view, int width, int height) {
32 if (assert_xdg(view)) {
33 wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
34 }
35}
36
25void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { 37void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
26 struct sway_server *server = wl_container_of( 38 struct sway_server *server = wl_container_of(
27 listener, server, xdg_shell_v6_surface); 39 listener, server, xdg_shell_v6_surface);
@@ -48,13 +60,13 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
48 } 60 }
49 sway_view->type = SWAY_XDG_SHELL_V6_VIEW; 61 sway_view->type = SWAY_XDG_SHELL_V6_VIEW;
50 sway_view->iface.get_prop = get_prop; 62 sway_view->iface.get_prop = get_prop;
63 sway_view->iface.set_dimensions = set_dimensions;
51 sway_view->wlr_xdg_surface_v6 = xdg_surface; 64 sway_view->wlr_xdg_surface_v6 = xdg_surface;
52 sway_view->sway_xdg_surface_v6 = sway_surface; 65 sway_view->sway_xdg_surface_v6 = sway_surface;
53 sway_view->surface = xdg_surface->surface; 66 sway_view->surface = xdg_surface->surface;
54 sway_surface->view = sway_view; 67 sway_surface->view = sway_view;
55 68
56 // TODO: 69 // TODO:
57 // - Add to tree
58 // - Wire up listeners 70 // - Wire up listeners
59 // - Handle popups 71 // - Handle popups
60 // - Look up pid and open on appropriate workspace 72 // - Look up pid and open on appropriate workspace
@@ -67,4 +79,6 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
67 79
68 swayc_t *cont = new_view(parent, sway_view); 80 swayc_t *cont = new_view(parent, sway_view);
69 sway_view->swayc = cont; 81 sway_view->swayc = cont;
82
83 arrange_windows(cont->parent, -1, -1);
70} 84}