X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=plugins%2Fresistance%2Fresistance.c;h=6dbdbe5e30063105f33025f2775a145a87202bd8;hb=122d55fbadea0409fbc902a1740e1c8ff3aecd88;hp=8d49363782f924ecd3f402cd3fbfe1b7d2e0ba52;hpb=34e819738b344a992a1dbfd6cdd165e0c8ddb3a9;p=chaz%2Fopenbox diff --git a/plugins/resistance/resistance.c b/plugins/resistance/resistance.c index 8d493637..6dbdbe5e 100644 --- a/plugins/resistance/resistance.c +++ b/plugins/resistance/resistance.c @@ -28,7 +28,7 @@ void plugin_setup_config() parse_register("resistance", parse_xml, NULL); } -static void resist_move(Client *c, int *x, int *y) +static void resist_move(ObClient *c, int *x, int *y) { GList *it; Rect *area; @@ -37,7 +37,7 @@ static void resist_move(Client *c, int *x, int *y) int al, at, ar, ab; /* screen area edges */ int cl, ct, cr, cb; /* current edges */ int w, h; /* current size */ - Client *snapx = NULL, *snapy = NULL; + ObClient *snapx = NULL, *snapy = NULL; w = c->frame->area.width; h = c->frame->area.height; @@ -55,7 +55,7 @@ static void resist_move(Client *c, int *x, int *y) /* snap to other clients */ if (resist_windows) for (it = stacking_list; it != NULL; it = it->next) { - Client *target; + ObClient *target; int tl, tt, tr, tb; /* 1 past the target's edges on each side */ if (!WINDOW_IS_CLIENT(it->data)) @@ -108,34 +108,39 @@ static void resist_move(Client *c, int *x, int *y) } /* get the screen boundaries */ - area = screen_area_xinerama(c->desktop, client_xinerama_area(c)); + for (i = 0; i < screen_num_monitors; ++i) { + area = screen_area_monitor(c->desktop, i); - al = area->x; - at = area->y; - ar = al + area->width - 1; - ab = at + area->height - 1; + if (!RECT_INTERSECTS_RECT(*area, c->frame->area)) + continue; - /* snap to screen edges */ - if (cl >= al && l < al && l >= al - resistance) - *x = al; - else if (cr <= ar && r > ar && r <= ar + resistance) - *x = ar - w + 1; - if (ct >= at && t < at && t >= at - resistance) - *y = at; - else if (cb <= ab && b > ab && b < ab + resistance) - *y = ab - h + 1; + al = area->x; + at = area->y; + ar = al + area->width - 1; + ab = at + area->height - 1; + + /* snap to screen edges */ + if (cl >= al && l < al && l >= al - resistance) + *x = al; + else if (cr <= ar && r > ar && r <= ar + resistance) + *x = ar - w + 1; + if (ct >= at && t < at && t >= at - resistance) + *y = at; + else if (cb <= ab && b > ab && b < ab + resistance) + *y = ab - h + 1; + } } -static void resist_size(Client *c, int *w, int *h, Corner corn) +static void resist_size(ObClient *c, int *w, int *h, ObCorner corn) { GList *it; - Client *target; /* target */ + ObClient *target; /* target */ int l, t, r, b; /* my left, top, right and bottom sides */ int dlt, drb; /* my destination left/top and right/bottom sides */ int tl, tt, tr, tb; /* target's left, top, right and bottom bottom sides */ Rect *area; int al, at, ar, ab; /* screen boundaries */ - Client *snapx = NULL, *snapy = NULL; + ObClient *snapx = NULL, *snapy = NULL; /* don't snap windows with size increments */ if (c->size_inc.width > 1 || c->size_inc.height > 1) @@ -172,15 +177,15 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* horizontal snapping */ if (t < tb && b > tt) { switch (corn) { - case Corner_TopLeft: - case Corner_BottomLeft: + case OB_CORNER_TOPLEFT: + case OB_CORNER_BOTTOMLEFT: dlt = l; drb = r + *w - c->frame->area.width; if (r < tl && drb >= tl && drb < tl + resistance) *w = tl - l, snapx = target; break; - case Corner_TopRight: - case Corner_BottomRight: + case OB_CORNER_TOPRIGHT: + case OB_CORNER_BOTTOMRIGHT: dlt = l - *w + c->frame->area.width; drb = r; if (l > tr && dlt <= tr && dlt > tr - resistance) @@ -194,15 +199,15 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* vertical snapping */ if (l < tr && r > tl) { switch (corn) { - case Corner_TopLeft: - case Corner_TopRight: + case OB_CORNER_TOPLEFT: + case OB_CORNER_TOPRIGHT: dlt = t; drb = b + *h - c->frame->area.height; if (b < tt && drb >= tt && drb < tt + resistance) *h = tt - t, snapy = target; break; - case Corner_BottomLeft: - case Corner_BottomRight: + case OB_CORNER_BOTTOMLEFT: + case OB_CORNER_BOTTOMRIGHT: dlt = t - *h + c->frame->area.height; drb = b; if (t > tb && dlt <= tb && dlt > tb - resistance) @@ -221,15 +226,15 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* horizontal snapping */ switch (corn) { - case Corner_TopLeft: - case Corner_BottomLeft: + case OB_CORNER_TOPLEFT: + case OB_CORNER_BOTTOMLEFT: dlt = l; drb = r + *w - c->frame->area.width; if (r <= ar && drb > ar && drb <= ar + resistance) *w = ar - l + 1; break; - case Corner_TopRight: - case Corner_BottomRight: + case OB_CORNER_TOPRIGHT: + case OB_CORNER_BOTTOMRIGHT: dlt = l - *w + c->frame->area.width; drb = r; if (l >= al && dlt < al && dlt >= al - resistance) @@ -239,15 +244,15 @@ static void resist_size(Client *c, int *w, int *h, Corner corn) /* vertical snapping */ switch (corn) { - case Corner_TopLeft: - case Corner_TopRight: + case OB_CORNER_TOPLEFT: + case OB_CORNER_TOPRIGHT: dlt = t; drb = b + *h - c->frame->area.height; if (b <= ab && drb > ab && drb <= ab + resistance) *h = ab - t + 1; break; - case Corner_BottomLeft: - case Corner_BottomRight: + case OB_CORNER_BOTTOMLEFT: + case OB_CORNER_BOTTOMRIGHT: dlt = t - *h + c->frame->area.height; drb = b; if (t >= at && dlt < at && dlt >= at - resistance)