DefaultWindowBehaviour::MouseDown(): Reorganized the region checks. Instead of

checking the mouse button in every case, use separate switches for the
buttons. Makes things easier to read.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39616 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-11-24 21:31:05 +00:00
parent 7cf8907453
commit 4e5bf97339
+41 -39
View File
@@ -700,63 +700,65 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
} }
// translate the region into an action // translate the region into an action
bool leftButton = (buttons & B_PRIMARY_MOUSE_BUTTON) != 0;
bool rightButton = (buttons & B_SECONDARY_MOUSE_BUTTON) != 0;
uint32 flags = fWindow->Flags(); uint32 flags = fWindow->Flags();
switch (hitRegion) { if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) {
case REGION_NONE: // left mouse button
break; switch (hitRegion) {
case REGION_NONE:
case REGION_TAB:
// tab sliding in any case if either shift key is held down
// except sliding up-down by moving mouse left-right would look
// strange
if (leftButton && (modifiers & B_SHIFT_KEY) != 0
&& fWindow->Look() != kLeftTitledWindowLook) {
action = ACTION_SLIDE_TAB;
break; break;
}
// otherwise fall through -- same handling as for the border...
case REGION_BORDER: case REGION_TAB:
if (leftButton) // tab sliding in any case if either shift key is held down
// except sliding up-down by moving mouse left-right would
// look strange
if ((modifiers & B_SHIFT_KEY) != 0
&& fWindow->Look() != kLeftTitledWindowLook) {
action = ACTION_SLIDE_TAB;
break;
}
// otherwise fall through -- same handling as for the
// border...
case REGION_BORDER:
action = ACTION_DRAG; action = ACTION_DRAG;
else if (rightButton) break;
action = ACTION_RESIZE_BORDER;
break;
case REGION_CLOSE_BUTTON: case REGION_CLOSE_BUTTON:
if (leftButton) {
action = (flags & B_NOT_CLOSABLE) == 0 action = (flags & B_NOT_CLOSABLE) == 0
? ACTION_CLOSE : ACTION_DRAG; ? ACTION_CLOSE : ACTION_DRAG;
} else if (rightButton) break;
action = ACTION_RESIZE_BORDER;
break;
case REGION_ZOOM_BUTTON: case REGION_ZOOM_BUTTON:
if (leftButton) {
action = (flags & B_NOT_ZOOMABLE) == 0 action = (flags & B_NOT_ZOOMABLE) == 0
? ACTION_ZOOM : ACTION_DRAG; ? ACTION_ZOOM : ACTION_DRAG;
} else if (rightButton) break;
action = ACTION_RESIZE_BORDER;
break;
case REGION_MINIMIZE_BUTTON: case REGION_MINIMIZE_BUTTON:
if (leftButton) {
action = (flags & B_NOT_MINIMIZABLE) == 0 action = (flags & B_NOT_MINIMIZABLE) == 0
? ACTION_MINIMIZE : ACTION_DRAG; ? ACTION_MINIMIZE : ACTION_DRAG;
} else if (rightButton) break;
action = ACTION_RESIZE_BORDER;
break;
case REGION_RESIZE_CORNER: case REGION_RESIZE_CORNER:
if (leftButton) {
action = (flags & B_NOT_RESIZABLE) == 0 action = (flags & B_NOT_RESIZABLE) == 0
? ACTION_RESIZE : ACTION_DRAG; ? ACTION_RESIZE : ACTION_DRAG;
} else if (rightButton) break;
}
} else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
// right mouse button
switch (hitRegion) {
case REGION_NONE:
break;
case REGION_TAB:
case REGION_BORDER:
case REGION_CLOSE_BUTTON:
case REGION_ZOOM_BUTTON:
case REGION_MINIMIZE_BUTTON:
case REGION_RESIZE_CORNER:
action = ACTION_RESIZE_BORDER; action = ACTION_RESIZE_BORDER;
break; break;
}
} }
} }