diff --git a/src/atom.h b/src/atom.h index 0a086e1..6f4eae6 100644 --- a/src/atom.h +++ b/src/atom.h @@ -23,8 +23,7 @@ WM_CLIENT_MACHINE, \ _NET_ACTIVE_WINDOW, \ _COMPTON_SHADOW, \ - _NET_WM_WINDOW_TYPE, \ - _NET_CURRENT_MON_CENTER + _NET_WM_WINDOW_TYPE #define ATOM_LIST2 \ _NET_WM_WINDOW_TYPE_DESKTOP, \ diff --git a/src/event.c b/src/event.c index 121d0a9..bdcc17b 100644 --- a/src/event.c +++ b/src/event.c @@ -452,14 +452,6 @@ static inline void ev_property_notify(session_t *ps, xcb_property_notify_event_t } if (ps->root == ev->window) { - if (ev->atom == ps->atoms->a_NET_CURRENT_MON_CENTER) { - winprop_t prop = x_get_prop(ps->c, ps->root, ps->atoms->a_NET_CURRENT_MON_CENTER, 2L, XCB_ATOM_CARDINAL, 32); - if (prop.nitems == 2) { - ps->selmon_center_x = prop.p32[0]; - ps->selmon_center_y = prop.p32[1]; - } - free_winprop(&prop); - } if (ps->o.use_ewmh_active_win && ps->atoms->a_NET_ACTIVE_WINDOW == ev->atom) { // to update focus diff --git a/src/picom.c b/src/picom.c index f00fb06..febe1f2 100644 --- a/src/picom.c +++ b/src/picom.c @@ -2441,15 +2441,6 @@ static session_t *session_init(int argc, char **argv, Display *dpy, write_pid(ps); - // When picom starts, fetch monitor positions first. Because it won't fetch the data unless property changes. - if (!ps->selmon_center_x && !ps->selmon_center_y) { - winprop_t prop = x_get_prop(ps->c, ps->root, ps->atoms->a_NET_CURRENT_MON_CENTER, 2L, XCB_ATOM_CARDINAL, 32); - if (prop.nitems == 2) { - ps->selmon_center_x = prop.p32[0]; - ps->selmon_center_y = prop.p32[1]; - } - free_winprop(&prop); - } ev_init(&ps->animation_timer, animation_timer_callback); if (fork && stderr_logger) { diff --git a/src/win.c b/src/win.c index 6f46ea3..130c445 100644 --- a/src/win.c +++ b/src/win.c @@ -471,6 +471,14 @@ static void win_update_properties(session_t *ps, struct managed_win *w) { static void init_animation(session_t *ps, struct managed_win *w) { CLEAR_MASK(w->animation_is_tag) + static int32_t randr_mon_center_x, randr_mon_center_y; + if (w->randr_monitor == -1) { + win_update_monitor(ps->randr_nmonitors, ps->randr_monitor_regs, w); + 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; + } static double *anim_x, *anim_y, *anim_w, *anim_h; enum open_window_animation animation; if (ps->o.wintype_option[w->window_type].animation != OPEN_WINDOW_ANIMATION_INVALID @@ -485,6 +493,7 @@ static void init_animation(session_t *ps, struct managed_win *w) { animation = ps->o.animation_for_transient_window; } + anim_x = &w->animation_center_x, anim_y = &w->animation_center_y; anim_w = &w->animation_w, anim_h = &w->animation_h; @@ -531,9 +540,9 @@ static void init_animation(session_t *ps, struct managed_win *w) { sqrt(ps->root_width * ps->root_width + ps->root_height * ps->root_height); // Set animation - *anim_x = ps->selmon_center_x + radius * cos(angle); - *anim_y = ps->selmon_center_y + radius * sin(angle); - *anim_w = 0; + *anim_x = randr_mon_center_x + radius * cos(angle); + *anim_y = randr_mon_center_y + radius * sin(angle); + *anim_w = 0; *anim_h = 0; break; case OPEN_WINDOW_ANIMATION_SLIDE_UP: // Slide up the image, without changing its location @@ -567,7 +576,7 @@ static void init_animation(session_t *ps, struct managed_win *w) { *anim_h = w->pending_g.height; break; case OPEN_WINDOW_ANIMATION_SLIDE_IN_CENTER: - *anim_x = ps->selmon_center_x; + *anim_x = randr_mon_center_x; *anim_y = w->g.y + w->pending_g.height * 0.5; *anim_w = w->pending_g.width; *anim_h = w->pending_g.height; @@ -579,7 +588,7 @@ static void init_animation(session_t *ps, struct managed_win *w) { w->animation_dest_h = w->pending_g.height; break; case OPEN_WINDOW_ANIMATION_SLIDE_OUT_CENTER: - w->animation_dest_center_x = ps->selmon_center_x; + w->animation_dest_center_x = randr_mon_center_x; w->animation_dest_center_y = w->pending_g.y; w->animation_dest_w = w->pending_g.width; w->animation_dest_h = w->pending_g.height; @@ -596,8 +605,8 @@ static void init_animation(session_t *ps, struct managed_win *w) { *anim_h = 0; break; case OPEN_WINDOW_ANIMATION_MINIMIZE: - *anim_x = ps->selmon_center_x; - *anim_y = ps->selmon_center_y; + *anim_x = randr_mon_center_x; + *anim_y = randr_mon_center_y; *anim_w = 0; *anim_h = 0; break;