From 44cfa0b0ef64b0b6587e1613a9fc4d4c4820307a Mon Sep 17 00:00:00 2001 From: Arda Atci Date: Tue, 14 Feb 2023 23:24:51 +0300 Subject: [PATCH] randr_mon position fix --- src/win.c | 10 ++++++---- src/x.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/win.c b/src/win.c index 247bc16..1b4de29 100644 --- a/src/win.c +++ b/src/win.c @@ -476,13 +476,13 @@ static void init_animation(session_t *ps, struct managed_win *w) { win_update_monitor(ps->randr_nmonitors, ps->randr_monitor_regs, w); if (w->randr_monitor != -1) { auto e = pixman_region32_extents(&ps->randr_monitor_regs[w->randr_monitor]); - randr_mon_center_x = (e->x1 + e->x2) / 2, randr_mon_center_y = (e->y1 + e->y2) / 2; + randr_mon_center_x = (e->x2 - e->x1) / 2, randr_mon_center_y = (e->y2 + e->y1) / 2; } else { randr_mon_center_x = ps->root_width / 2, randr_mon_center_y = ps->root_height / 2; } } else { auto e = pixman_region32_extents(&ps->randr_monitor_regs[w->randr_monitor]); - randr_mon_center_x = (e->x1 + e->x2) / 2, randr_mon_center_y = (e->y1 + e->y2) / 2; + randr_mon_center_x = (e->x2 - e->x1) / 2, randr_mon_center_y = (e->y2 - e->y1) / 2; } static double *anim_x, *anim_y, *anim_w, *anim_h; enum open_window_animation animation; @@ -2758,8 +2758,9 @@ bool win_skip_fading(session_t *ps, struct managed_win *w) { void win_update_monitor(int nmons, region_t *mons, struct managed_win *mw) { for (int i = 0; i < nmons; i++) { auto e = pixman_region32_extents(&mons[i]); - if (e->x1 <= mw->g.x && e->y1 <= mw->g.y && - e->x2 >= mw->g.x + mw->widthb && e->y2 >= mw->g.y + mw->heightb) { + // if (e->x1 <= mw->g.x && e->y1 <= mw->g.y && + // e->x2 >= mw->g.x + mw->widthb && e->y2 >= mw->g.y + mw->heightb) { + if (e->x1 <= mw->g.x && e->x2 >= mw->g.x + mw->widthb) { mw->randr_monitor = i; log_debug("Window %#010x (%s), %dx%d+%dx%d, is entirely on the " "monitor %d (%dx%d+%dx%d)", @@ -2768,6 +2769,7 @@ void win_update_monitor(int nmons, region_t *mons, struct managed_win *mw) { return; } } + mw->randr_monitor = -1; log_debug("Window %#010x (%s), %dx%d+%dx%d, is not entirely on any monitor", mw->base.id, mw->name, mw->g.x, mw->g.y, mw->widthb, mw->heightb); } diff --git a/src/x.c b/src/x.c index ef60b7e..da37c4b 100644 --- a/src/x.c +++ b/src/x.c @@ -792,7 +792,7 @@ xcb_screen_t *x_screen_of_display(xcb_connection_t *c, int screen) { void x_update_randr_monitors(session_t *ps) { x_free_randr_info(ps); - if ((!ps->o.crop_shadow_to_monitor || !ps->o.animations) || !ps->randr_exists) { + if (!(ps->o.crop_shadow_to_monitor || ps->o.animations) || !ps->randr_exists) { return; }