From c1caf4bbc7019c00965cf9356bb078975063cb4a Mon Sep 17 00:00:00 2001 From: fwsmit Date: Sat, 26 Dec 2020 16:44:38 +0100 Subject: [PATCH] Set the right window position --- src/draw.c | 2 ++ src/output.c | 6 ++++++ src/wayland/wl.c | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/draw.c b/src/draw.c index bb70b1c..d83ab7e 100644 --- a/src/draw.c +++ b/src/draw.c @@ -752,6 +752,8 @@ static void calc_window_pos(int width, int height, int *ret_x, int *ret_y) *ret_y = scr->y + settings.geometry.y; } } + LOG_I("Screen size: %ix%i", scr->w, scr->h); + LOG_I("Return value: %ix%i", *ret_x, *ret_y); } void draw(void) diff --git a/src/output.c b/src/output.c index f261289..48f5490 100644 --- a/src/output.c +++ b/src/output.c @@ -52,6 +52,12 @@ const struct output output_wl = { const struct output* output_create(void) { + if (is_running_wayland()){ + LOG_I("System is running wayland"); + } + else{ + LOG_I("System is running X11"); + } return &output_wl; } /* vim: set ft=c tabstop=8 shiftwidth=8 expandtab textwidth=0: */ diff --git a/src/wayland/wl.c b/src/wayland/wl.c index 6eb4e7d..c6e29ce 100644 --- a/src/wayland/wl.c +++ b/src/wayland/wl.c @@ -22,6 +22,7 @@ #include "pool-buffer.h" #include "../log.h" +#include "../settings.h" struct window_wl { struct wl_surface *surface; @@ -426,10 +427,35 @@ static void send_frame() { // exists, we might need to resize if the list of notifications has changed // since the last time we drew. if (ctx.height != height) { + struct dimensions dim = ctx.cur_dim; + // Set window size zwlr_layer_surface_v1_set_size(ctx.layer_surface, - ctx.cur_dim.w, ctx.cur_dim.h); + dim.w, dim.h); + + uint32_t anchor = 0; + if (settings.geometry.negative_x){ + anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; + } + else{ + anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT; + } + + if (settings.geometry.negative_y){ + anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; + } + else{ + anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; + } + + // Put the window at the right position zwlr_layer_surface_v1_set_anchor(ctx.layer_surface, - ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT); + anchor); + zwlr_layer_surface_v1_set_margin(ctx.layer_surface, + abs(settings.geometry.y), // top + abs(settings.geometry.x), // right + abs(settings.geometry.y), // bottom + abs(settings.geometry.x));// left + wl_surface_commit(ctx.surface); // Now we're going to bail without drawing anything. This gives the @@ -562,9 +588,10 @@ cairo_t* wl_win_get_context(window winptr) { } const struct screen_info* wl_get_active_screen(void) { + // TODO Screen size detection static struct screen_info scr = { - .w = 1080, - .h = 1920, + .w = 1920, + .h = 1080, .x = 0, .y = 0, .id = 0,