|
|
@@ -666,10 +666,9 @@ Platform* Platform::create(Game* game)
|
|
|
|
|
|
XSetWindowAttributes winAttribs;
|
|
|
long eventMask;
|
|
|
- eventMask = ExposureMask | VisibilityChangeMask | StructureNotifyMask |
|
|
|
- KeyPressMask | KeyReleaseMask | PointerMotionMask |
|
|
|
- ButtonPressMask | ButtonReleaseMask |
|
|
|
- EnterWindowMask | LeaveWindowMask;
|
|
|
+ eventMask = ExposureMask | VisibilityChangeMask | StructureNotifyMask |
|
|
|
+ KeyPressMask | KeyReleaseMask | PointerMotionMask |
|
|
|
+ ButtonPressMask | ButtonReleaseMask | EnterWindowMask | LeaveWindowMask;
|
|
|
winAttribs.event_mask = eventMask;
|
|
|
winAttribs.border_pixel = 0;
|
|
|
winAttribs.bit_gravity = StaticGravity;
|
|
|
@@ -678,9 +677,7 @@ Platform* Platform::create(Game* game)
|
|
|
GLint winMask;
|
|
|
winMask = CWBorderPixel | CWBitGravity | CWEventMask| CWColormap;
|
|
|
|
|
|
- __window = XCreateWindow(__display, DefaultRootWindow(__display), __x, __y, __width, __height, 0,
|
|
|
- visualInfo->depth, InputOutput, visualInfo->visual, winMask,
|
|
|
- &winAttribs);
|
|
|
+ __window = XCreateWindow(__display, DefaultRootWindow(__display), __x, __y, __width, __height, 0, visualInfo->depth, InputOutput, visualInfo->visual, winMask, &winAttribs);
|
|
|
|
|
|
// Tell the window manager that it should send the delete window notification through ClientMessage
|
|
|
__atomWmDeleteWindow = XInternAtom(__display, "WM_DELETE_WINDOW", False);
|
|
|
@@ -1165,16 +1162,24 @@ int Platform::enterMessagePump()
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
- case DestroyNotify :
|
|
|
+
|
|
|
+ case Expose:
|
|
|
{
|
|
|
- cleanupX11();
|
|
|
- exit(0);
|
|
|
+ updateWindowSize();
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case Expose:
|
|
|
+ case ConfigureNotify:
|
|
|
{
|
|
|
updateWindowSize();
|
|
|
+ gameplay::Platform::resizeEventInternal(evt.xconfigure.width, evt.xconfigure.height);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case DestroyNotify :
|
|
|
+ {
|
|
|
+ cleanupX11();
|
|
|
+ exit(0);
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
@@ -1230,34 +1235,32 @@ int Platform::enterMessagePump()
|
|
|
case ButtonPress:
|
|
|
{
|
|
|
gameplay::Mouse::MouseEvent mouseEvt;
|
|
|
- switch (evt.xbutton.button)
|
|
|
+
|
|
|
+ if (evt.xbutton.button >= 1 && evt.xbutton.button <= 3)
|
|
|
{
|
|
|
- case 1:
|
|
|
+ if (evt.xbutton.button == 1)
|
|
|
mouseEvt = gameplay::Mouse::MOUSE_PRESS_LEFT_BUTTON;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
+ else if (evt.xbutton.button == 2)
|
|
|
mouseEvt = gameplay::Mouse::MOUSE_PRESS_MIDDLE_BUTTON;
|
|
|
- break;
|
|
|
- case 3:
|
|
|
+ else if (evt.xbutton.button == 3)
|
|
|
mouseEvt = gameplay::Mouse::MOUSE_PRESS_RIGHT_BUTTON;
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- case 5:
|
|
|
- int wheelDelta;
|
|
|
- if (evt.xbutton.button == Button4)
|
|
|
- wheelDelta = 1;
|
|
|
- else if (evt.xbutton.button == Button5)
|
|
|
- wheelDelta = -1;
|
|
|
- else
|
|
|
- wheelDelta = 0;
|
|
|
- gameplay::Platform::mouseEventInternal(gameplay::Mouse::MOUSE_WHEEL, evt.xbutton.x, evt.xbutton.y, wheelDelta);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+
|
|
|
+ if (!gameplay::Platform::mouseEventInternal(mouseEvt, evt.xbutton.x, evt.xbutton.y, 0))
|
|
|
+ {
|
|
|
+ gameplay::Platform::touchEventInternal(gameplay::Touch::TOUCH_PRESS, evt.xbutton.x, evt.xbutton.y, 0, true);
|
|
|
+ }
|
|
|
}
|
|
|
- if (!gameplay::Platform::mouseEventInternal(mouseEvt, evt.xbutton.x, evt.xbutton.y, 0))
|
|
|
+ else if (evt.xbutton.button >= 4 && evt.xbutton.button <= 5)
|
|
|
{
|
|
|
- gameplay::Platform::touchEventInternal(gameplay::Touch::TOUCH_PRESS, evt.xbutton.x, evt.xbutton.y, 0, true);
|
|
|
+ int wheelDelta;
|
|
|
+ if (evt.xbutton.button == 4)
|
|
|
+ wheelDelta = 1;
|
|
|
+ else if (evt.xbutton.button == 5)
|
|
|
+ wheelDelta = -1;
|
|
|
+ else
|
|
|
+ wheelDelta = 0;
|
|
|
+
|
|
|
+ gameplay::Platform::mouseEventInternal(gameplay::Mouse::MOUSE_WHEEL, evt.xbutton.x, evt.xbutton.y, wheelDelta);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -1265,23 +1268,20 @@ int Platform::enterMessagePump()
|
|
|
case ButtonRelease:
|
|
|
{
|
|
|
gameplay::Mouse::MouseEvent mouseEvt;
|
|
|
- switch (evt.xbutton.button)
|
|
|
+
|
|
|
+ if (evt.xbutton.button >= 1 && evt.xbutton.button <= 3)
|
|
|
{
|
|
|
- case 1:
|
|
|
+ if (evt.xbutton.button == 1)
|
|
|
mouseEvt = gameplay::Mouse::MOUSE_RELEASE_LEFT_BUTTON;
|
|
|
- break;
|
|
|
- case 2:
|
|
|
+ else if (evt.xbutton.button == 2)
|
|
|
mouseEvt = gameplay::Mouse::MOUSE_RELEASE_MIDDLE_BUTTON;
|
|
|
- break;
|
|
|
- case 3:
|
|
|
+ else if (evt.xbutton.button == 3)
|
|
|
mouseEvt = gameplay::Mouse::MOUSE_RELEASE_RIGHT_BUTTON;
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- if (!gameplay::Platform::mouseEventInternal(mouseEvt, evt.xbutton.x, evt.xbutton.y, 0))
|
|
|
- {
|
|
|
- gameplay::Platform::touchEventInternal(gameplay::Touch::TOUCH_RELEASE, evt.xbutton.x, evt.xbutton.y, 0, true);
|
|
|
+
|
|
|
+ if (!gameplay::Platform::mouseEventInternal(mouseEvt, evt.xbutton.x, evt.xbutton.y, 0))
|
|
|
+ {
|
|
|
+ gameplay::Platform::touchEventInternal(gameplay::Touch::TOUCH_RELEASE, evt.xbutton.x, evt.xbutton.y, 0, true);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
@@ -1316,12 +1316,6 @@ int Platform::enterMessagePump()
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
- case ConfigureNotify:
|
|
|
- {
|
|
|
- gameplay::Platform::resizeEventInternal(evt.xconfigure.width, evt.xconfigure.height);
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
default:
|
|
|
break;
|
|
|
}
|