diff options
author | ross <ross@f5eea0f0-44ea-0310-b729-df5b855dafe5> | 2007-09-20 10:27:29 +0000 |
---|---|---|
committer | ross <ross@f5eea0f0-44ea-0310-b729-df5b855dafe5> | 2007-09-20 10:27:29 +0000 |
commit | 6c4b041c1d775e7aaaaa0e7293311aa6a18ade51 (patch) | |
tree | 3c4bb2b6f92afdee85f3b4aad6d141b01cfa4cbd | |
parent | c81442ff2e9221eabc3543d67a59041a900cb95b (diff) |
* xresponse.c:
Fix overlap detection (thanks Mika Yrjölä)
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | xresponse.c | 18 |
2 files changed, 19 insertions, 4 deletions
@@ -1,6 +1,11 @@ 2007-09-20 Ross Burton <ross@openedhand.com> * xresponse.c: + Fix overlap detection (thanks Mika Yrjölä) + +2007-09-20 Ross Burton <ross@openedhand.com> + + * xresponse.c: Use XRectangle instead of a custom Rectangle struct, and fix a warning in XChangeProperty. diff --git a/xresponse.c b/xresponse.c index ff85323..65f0b60 100644 --- a/xresponse.c +++ b/xresponse.c @@ -272,6 +272,19 @@ drag_event(Display *dpy, int x, int y, int button_state) return start; } +/** + * Returns TRUE if the two rectangles overlap, FALSE otherwise. + */ +static int +overlap (XRectangle r1, XRectangle r2) +{ + return + r1.x <= (r2.x + r2.width) && + (r1.x + r1.width) >= r2.x && + r1.y <= (r2.y + r2.height) && + (r1.y + r1.height) >= r2.y; +} + /** * Waits for a damage 'response' to above click */ @@ -295,10 +308,7 @@ wait_response(Display *dpy) { XDamageNotifyEvent *dev = (XDamageNotifyEvent*)&e; - if (dev->area.x >= InterestedDamageRect.x - && dev->area.width <= InterestedDamageRect.width - && dev->area.y >= InterestedDamageRect.y - && dev->area.height <= InterestedDamageRect.height) + if (overlap (dev->area, InterestedDamageRect)) { log_action(dev->timestamp, 0, "Got damage event %dx%d+%d+%d\n", dev->area.width, dev->area.height, |