* check mouse coords in right space.
[blender.git] / source / blender / editors / interface / interface_ops.c
index c68ea719a13f9442508a249c9be88b04c5414844..d96deefa39edf566a8e7e98162c1c893a40b33be 100644 (file)
@@ -2590,28 +2590,42 @@ static uiBut *ui_but_find_signal(ARegion *ar, uiActivateBut *data, uiBlock **rbl
        return NULL;
 }
 
+static int inside_region(ARegion *ar, int x, int y)
+{
+       if(BLI_in_rcti(&ar->winrct, x, y)) {
+               /* XXX still can be zero */
+               if(ar->v2d.mask.xmin!=ar->v2d.mask.xmax) {
+                       /* mask is in different coord space - take that in account */
+                       return BLI_in_rcti(&ar->v2d.mask, x-ar->winrct.xmin, y-ar->winrct.ymin);
+               }
+               return 1;
+       }
+       return 0;
+}
+
 static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y, uiBlock **rblock)
 {
        uiBlock *block, *blockover= NULL;
        uiBut *but, *butover= NULL;
        int mx, my;
 
-       for(block=ar->uiblocks.first; block; block=block->next) {
-               mx= x;
-               my= y;
-               ui_window_to_block(ar, block, &mx, &my);
-
-               for(but=block->buttons.first; but; but= but->next) {
-                       /* give precedence to already activated buttons */
-                       if(ui_but_contains_pt(but, mx, my)) {
-                               if(!butover || (!butover->activate && but->activate)) {
-                                       butover= but;
-                                       blockover= block;
+       if(inside_region(ar, x, y)) {
+               for(block=ar->uiblocks.first; block; block=block->next) {
+                       mx= x;
+                       my= y;
+                       ui_window_to_block(ar, block, &mx, &my);
+
+                       for(but=block->buttons.first; but; but= but->next) {
+                               /* give precedence to already activated buttons */
+                               if(ui_but_contains_pt(but, mx, my)) {
+                                       if(!butover || (!butover->activate && but->activate)) {
+                                               butover= but;
+                                               blockover= block;
+                                       }
                                }
                        }
                }
        }
-
        if(rblock)
                *rblock= blockover;