mirror of
https://github.com/glfw/glfw.git
synced 2024-12-02 06:47:10 +00:00
Fix issue with merge
This commit is contained in:
parent
39dec1415b
commit
a4c3492a03
13
src/input.c
13
src/input.c
@ -728,19 +728,6 @@ GLFWAPI void glfwSetInputMode(GLFWwindow *handle, int mode, int value)
|
||||
return;
|
||||
}
|
||||
|
||||
case GLFW_RAW_MOUSE_MOTION:
|
||||
{
|
||||
if (!_glfw.platform.rawMouseMotionSupported())
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Raw mouse motion is not supported on this system");
|
||||
return;
|
||||
}
|
||||
|
||||
value = value ? GLFW_TRUE : GLFW_FALSE;
|
||||
if (window->rawMouseMotion == value)
|
||||
return;
|
||||
|
||||
case GLFW_RAW_MOUSE_MOTION:
|
||||
{
|
||||
if (!_glfw.platform.rawMouseMotionSupported())
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW event API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -1198,3 +1199,4 @@ GLFWAPI void glfwPostEmptyEvent(void)
|
||||
_GLFW_REQUIRE_INIT();
|
||||
_glfw.platform.postEmptyEvent();
|
||||
}
|
||||
|
||||
|
209
src/x11_window.c
209
src/x11_window.c
@ -158,8 +158,7 @@ static GLFWbool waitForVisibilityNotify(_GLFWwindow *window)
|
||||
static int getWindowState(_GLFWwindow* window)
|
||||
{
|
||||
int result = WithdrawnState;
|
||||
struct
|
||||
{
|
||||
struct {
|
||||
CARD32 state;
|
||||
Window icon;
|
||||
} *state = NULL;
|
||||
@ -420,7 +419,8 @@ static uint32_t decodeUTF8(const char **s)
|
||||
static const uint32_t offsets[] =
|
||||
{
|
||||
0x00000000u, 0x00003080u, 0x000e2080u,
|
||||
0x03c82080u, 0xfa082080u, 0x82082080u};
|
||||
0x03c82080u, 0xfa082080u, 0x82082080u
|
||||
};
|
||||
|
||||
do
|
||||
{
|
||||
@ -665,7 +665,8 @@ static GLFWbool createNativeWindow(_GLFWwindow *window,
|
||||
Atom protocols[] =
|
||||
{
|
||||
_glfw.x11.WM_DELETE_WINDOW,
|
||||
_glfw.x11.NET_WM_PING};
|
||||
_glfw.x11.NET_WM_PING
|
||||
};
|
||||
|
||||
XSetWMProtocols(_glfw.x11.display, window->x11.handle,
|
||||
protocols, sizeof(protocols) / sizeof(Atom));
|
||||
@ -1487,6 +1488,9 @@ static void processEvent(XEvent *event)
|
||||
if (event->xconfigure.width != window->x11.width ||
|
||||
event->xconfigure.height != window->x11.height)
|
||||
{
|
||||
window->x11.width = event->xconfigure.width;
|
||||
window->x11.height = event->xconfigure.height;
|
||||
|
||||
_glfwInputFramebufferSize(window,
|
||||
event->xconfigure.width,
|
||||
event->xconfigure.height);
|
||||
@ -1494,9 +1498,6 @@ static void processEvent(XEvent *event)
|
||||
_glfwInputWindowSize(window,
|
||||
event->xconfigure.width,
|
||||
event->xconfigure.height);
|
||||
|
||||
window->x11.width = event->xconfigure.width;
|
||||
window->x11.height = event->xconfigure.height;
|
||||
}
|
||||
|
||||
int xpos = event->xconfigure.x;
|
||||
@ -1524,9 +1525,10 @@ static void processEvent(XEvent *event)
|
||||
|
||||
if (xpos != window->x11.xpos || ypos != window->x11.ypos)
|
||||
{
|
||||
_glfwInputWindowPos(window, xpos, ypos);
|
||||
window->x11.xpos = xpos;
|
||||
window->x11.ypos = ypos;
|
||||
|
||||
_glfwInputWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -1613,188 +1615,7 @@ static void processEvent(XEvent *event)
|
||||
// The drag operation has finished by dropping on the window
|
||||
Time time = CurrentTime;
|
||||
|
||||
if (event->xbutton.button == Button1)
|
||||
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
|
||||
else if (event->xbutton.button == Button2)
|
||||
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS, mods);
|
||||
else if (event->xbutton.button == Button3)
|
||||
_glfwInputMouseClick(window, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
|
||||
|
||||
// Modern X provides scroll events as mouse button presses
|
||||
else if (event->xbutton.button == Button4)
|
||||
_glfwInputScroll(window, 0.0, 1.0);
|
||||
else if (event->xbutton.button == Button5)
|
||||
_glfwInputScroll(window, 0.0, -1.0);
|
||||
else if (event->xbutton.button == Button6)
|
||||
_glfwInputScroll(window, 1.0, 0.0);
|
||||
else if (event->xbutton.button == Button7)
|
||||
_glfwInputScroll(window, -1.0, 0.0);
|
||||
|
||||
else
|
||||
{
|
||||
// Additional buttons after 7 are treated as regular buttons
|
||||
// We subtract 4 to fill the gap left by scroll input above
|
||||
_glfwInputMouseClick(window,
|
||||
event->xbutton.button - Button1 - 4,
|
||||
GLFW_PRESS,
|
||||
mods);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case ButtonRelease:
|
||||
{
|
||||
const int mods = translateState(event->xbutton.state);
|
||||
|
||||
if (event->xbutton.button == Button1)
|
||||
{
|
||||
_glfwInputMouseClick(window,
|
||||
GLFW_MOUSE_BUTTON_LEFT,
|
||||
GLFW_RELEASE,
|
||||
mods);
|
||||
}
|
||||
else if (event->xbutton.button == Button2)
|
||||
{
|
||||
_glfwInputMouseClick(window,
|
||||
GLFW_MOUSE_BUTTON_MIDDLE,
|
||||
GLFW_RELEASE,
|
||||
mods);
|
||||
}
|
||||
else if (event->xbutton.button == Button3)
|
||||
{
|
||||
_glfwInputMouseClick(window,
|
||||
GLFW_MOUSE_BUTTON_RIGHT,
|
||||
GLFW_RELEASE,
|
||||
mods);
|
||||
}
|
||||
else if (event->xbutton.button > Button7)
|
||||
{
|
||||
// Additional buttons after 7 are treated as regular buttons
|
||||
// We subtract 4 to fill the gap left by scroll input above
|
||||
_glfwInputMouseClick(window,
|
||||
event->xbutton.button - Button1 - 4,
|
||||
GLFW_RELEASE,
|
||||
mods);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case EnterNotify:
|
||||
{
|
||||
// XEnterWindowEvent is XCrossingEvent
|
||||
const int x = event->xcrossing.x;
|
||||
const int y = event->xcrossing.y;
|
||||
|
||||
// HACK: This is a workaround for WMs (KWM, Fluxbox) that otherwise
|
||||
// ignore the defined cursor for hidden cursor mode
|
||||
if (window->cursorMode == GLFW_CURSOR_HIDDEN)
|
||||
updateCursorImage(window);
|
||||
|
||||
_glfwInputCursorEnter(window, GLFW_TRUE);
|
||||
_glfwInputCursorPos(window, x, y);
|
||||
|
||||
window->x11.lastCursorPosX = x;
|
||||
window->x11.lastCursorPosY = y;
|
||||
return;
|
||||
}
|
||||
|
||||
case LeaveNotify:
|
||||
{
|
||||
_glfwInputCursorEnter(window, GLFW_FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
case MotionNotify:
|
||||
{
|
||||
const int x = event->xmotion.x;
|
||||
const int y = event->xmotion.y;
|
||||
|
||||
if (x != window->x11.warpCursorPosX ||
|
||||
y != window->x11.warpCursorPosY)
|
||||
{
|
||||
// The cursor was moved by something other than GLFW
|
||||
|
||||
if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
||||
{
|
||||
if (_glfw.x11.disabledCursorWindow != window)
|
||||
return;
|
||||
if (window->rawMouseMotion)
|
||||
return;
|
||||
|
||||
const int dx = x - window->x11.lastCursorPosX;
|
||||
const int dy = y - window->x11.lastCursorPosY;
|
||||
|
||||
_glfwInputCursorPos(window,
|
||||
window->virtualCursorPosX + dx,
|
||||
window->virtualCursorPosY + dy);
|
||||
}
|
||||
else
|
||||
_glfwInputCursorPos(window, x, y);
|
||||
}
|
||||
|
||||
window->x11.lastCursorPosX = x;
|
||||
window->x11.lastCursorPosY = y;
|
||||
return;
|
||||
}
|
||||
|
||||
case ConfigureNotify:
|
||||
{
|
||||
if (event->xconfigure.width != window->x11.width ||
|
||||
event->xconfigure.height != window->x11.height)
|
||||
{
|
||||
window->x11.width = event->xconfigure.width;
|
||||
window->x11.height = event->xconfigure.height;
|
||||
|
||||
_glfwInputFramebufferSize(window,
|
||||
event->xconfigure.width,
|
||||
event->xconfigure.height);
|
||||
|
||||
_glfwInputWindowSize(window,
|
||||
event->xconfigure.width,
|
||||
event->xconfigure.height);
|
||||
}
|
||||
|
||||
int xpos = event->xconfigure.x;
|
||||
int ypos = event->xconfigure.y;
|
||||
|
||||
// NOTE: ConfigureNotify events from the server are in local
|
||||
// coordinates, so if we are reparented we need to translate
|
||||
// the position into root (screen) coordinates
|
||||
if (!event->xany.send_event && window->x11.parent != _glfw.x11.root)
|
||||
{
|
||||
_glfwGrabErrorHandlerX11();
|
||||
|
||||
Window dummy;
|
||||
XTranslateCoordinates(_glfw.x11.display,
|
||||
window->x11.parent,
|
||||
_glfw.x11.root,
|
||||
xpos, ypos,
|
||||
&xpos, &ypos,
|
||||
&dummy);
|
||||
|
||||
_glfwReleaseErrorHandlerX11();
|
||||
if (_glfw.x11.errorCode == BadWindow)
|
||||
return;
|
||||
}
|
||||
|
||||
if (xpos != window->x11.xpos || ypos != window->x11.ypos)
|
||||
{
|
||||
window->x11.xpos = xpos;
|
||||
window->x11.ypos = ypos;
|
||||
|
||||
_glfwInputWindowPos(window, xpos, ypos);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case ClientMessage:
|
||||
{
|
||||
// Custom client message, probably from the window manager
|
||||
|
||||
if (filtered)
|
||||
if (_glfw.x11.xdnd.version > _GLFW_XDND_VERSION)
|
||||
return;
|
||||
|
||||
if (_glfw.x11.xdnd.format)
|
||||
@ -2012,6 +1833,7 @@ static void processEvent(XEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -2129,6 +1951,7 @@ void _glfwCreateInputContextX11(_GLFWwindow *window)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -2570,7 +2393,8 @@ void _glfwMaximizeWindowX11(_GLFWwindow *window)
|
||||
Atom missing[2] =
|
||||
{
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_VERT,
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ};
|
||||
_glfw.x11.NET_WM_STATE_MAXIMIZED_HORZ
|
||||
};
|
||||
unsigned long missingCount = 2;
|
||||
|
||||
for (unsigned long i = 0; i < count; i++)
|
||||
@ -2961,7 +2785,6 @@ void _glfwPollEventsX11(void)
|
||||
|
||||
#if defined(GLFW_BUILD_LINUX_JOYSTICK)
|
||||
if (_glfw.joysticksInitialized)
|
||||
_glfwPollAllJoysticks();
|
||||
_glfwDetectJoystickConnectionLinux();
|
||||
#endif
|
||||
XPending(_glfw.x11.display);
|
||||
@ -3459,6 +3282,7 @@ VkResult _glfwCreateWindowSurfaceX11(VkInstance instance,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW native API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -3534,3 +3358,4 @@ GLFWAPI const char *glfwGetX11SelectionString(void)
|
||||
}
|
||||
|
||||
#endif // _GLFW_X11
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user