patch: for "old" unix, fixed compile problems (missing xi2 stuff), and refactored header tests (thanks to Jim Hague)
This commit is contained in:
parent
fb377bbc78
commit
6dcefaf353
|
@ -173,34 +173,35 @@ if (UNIX)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
# add include dir for bsd (posix uses /usr/include/)
|
# add include dir for bsd (posix uses /usr/include/)
|
||||||
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
|
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
|
||||||
|
|
||||||
set(XKBlib "X11/XKBlib.h")
|
set(XKBlib "X11/Xlib.h;X11/XKBlib.h")
|
||||||
check_include_files("${XKBlib};X11/extensions/Xrandr.h" HAVE_X11_EXTENSIONS_XRANDR_H)
|
check_symbol_exists("XRRNotifyEvent" "${XKBlib};X11/extensions/Xrandr.h" HAVE_X11_EXTENSIONS_XRANDR_H)
|
||||||
check_include_files("${XKBlib};X11/extensions/dpms.h" HAVE_X11_EXTENSIONS_DPMS_H)
|
|
||||||
check_include_files("X11/extensions/Xinerama.h" HAVE_X11_EXTENSIONS_XINERAMA_H)
|
check_include_files("${XKBlib};X11/extensions/dpms.h" HAVE_X11_EXTENSIONS_DPMS_H)
|
||||||
check_include_files("${XKBlib};X11/extensions/XKBstr.h" HAVE_X11_EXTENSIONS_XKBSTR_H)
|
check_include_files("X11/extensions/Xinerama.h" HAVE_X11_EXTENSIONS_XINERAMA_H)
|
||||||
check_include_files("X11/extensions/XKB.h" HAVE_XKB_EXTENSION)
|
check_include_files("${XKBlib};X11/extensions/XKBstr.h" HAVE_X11_EXTENSIONS_XKBSTR_H)
|
||||||
check_include_files("X11/extensions/XTest.h" HAVE_X11_EXTENSIONS_XTEST_H)
|
check_include_files("X11/extensions/XKB.h" HAVE_XKB_EXTENSION)
|
||||||
check_include_files(${XKBlib} HAVE_X11_XKBLIB_H)
|
check_include_files("X11/extensions/XTest.h" HAVE_X11_EXTENSIONS_XTEST_H)
|
||||||
check_include_files("X11/extensions/XInput2.h" HAVE_XI2)
|
check_include_files("${XKBlib}" HAVE_X11_XKBLIB_H)
|
||||||
|
check_include_files("X11/extensions/XInput2.h" HAVE_XI2)
|
||||||
if (HAVE_X11_EXTENSIONS_DPMS_H)
|
|
||||||
|
if (HAVE_X11_EXTENSIONS_DPMS_H)
|
||||||
# Assume that function prototypes declared, when include exists.
|
# Assume that function prototypes declared, when include exists.
|
||||||
set(HAVE_DPMS_PROTOTYPES 1)
|
set(HAVE_DPMS_PROTOTYPES 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT HAVE_X11_XKBLIB_H)
|
if (NOT HAVE_X11_XKBLIB_H)
|
||||||
message(FATAL_ERROR "Missing header: " ${XKBlib})
|
message(FATAL_ERROR "Missing header: " ${XKBlib})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_library_exists("SM;ICE" IceConnectionNumber "" HAVE_ICE)
|
check_library_exists("SM;ICE" IceConnectionNumber "" HAVE_ICE)
|
||||||
check_library_exists("X11;Xext" DPMSQueryExtension "" HAVE_Xext)
|
check_library_exists("Xext;X11" DPMSQueryExtension "" HAVE_Xext)
|
||||||
check_library_exists("X11;Xext;Xtst" XTestQueryExtension "" HAVE_Xtst)
|
check_library_exists("Xtst;Xext;X11" XTestQueryExtension "" HAVE_Xtst)
|
||||||
check_library_exists("Xinerama" XineramaQueryExtension "" HAVE_Xinerama)
|
check_library_exists("Xinerama" XineramaQueryExtension "" HAVE_Xinerama)
|
||||||
check_library_exists("Xi" XISelectEvents "" HAVE_Xi)
|
check_library_exists("Xi" XISelectEvents "" HAVE_Xi)
|
||||||
check_library_exists("Xrandr" XRRQueryExtension "" HAVE_Xrandr)
|
check_library_exists("Xrandr" XRRQueryExtension "" HAVE_Xrandr)
|
||||||
|
|
||||||
if (HAVE_ICE)
|
if (HAVE_ICE)
|
||||||
|
|
||||||
|
@ -211,13 +212,13 @@ if (UNIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (HAVE_Xtst)
|
if (HAVE_Xtst)
|
||||||
|
|
||||||
# Xtxt depends on X11.
|
# Xtxt depends on X11.
|
||||||
set(HAVE_X11)
|
set(HAVE_X11)
|
||||||
list(APPEND libs X11 Xtst)
|
list(APPEND libs Xtst X11)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
message(FATAL_ERROR "Missing library: Xtst")
|
message(FATAL_ERROR "Missing library: Xtst")
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
@ -227,13 +228,14 @@ if (UNIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (HAVE_Xinerama)
|
if (HAVE_Xinerama)
|
||||||
list(APPEND libs Xinerama)
|
list(APPEND libs Xinerama)
|
||||||
else (HAVE_Xinerama)
|
else (HAVE_Xinerama)
|
||||||
if (HAVE_X11_EXTENSIONS_XINERAMA_H)
|
if (HAVE_X11_EXTENSIONS_XINERAMA_H)
|
||||||
message(FATAL_ERROR "Missing library: Xinerama")
|
set(HAVE_X11_EXTENSIONS_XINERAMA_H 0)
|
||||||
endif()
|
message(WARNING "Old Xinerama implementation detected, disabled")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (HAVE_Xrandr)
|
if (HAVE_Xrandr)
|
||||||
list(APPEND libs Xrandr)
|
list(APPEND libs Xrandr)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -153,13 +153,15 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, bool d
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
// start watching for events on other windows
|
// start watching for events on other windows
|
||||||
selectEvents(m_root);
|
selectEvents(m_root);
|
||||||
m_xi2detected = detectXI2();
|
m_xi2detected = detectXI2();
|
||||||
|
|
||||||
if (m_xi2detected) {
|
if (m_xi2detected) {
|
||||||
selectXIRawMotion();
|
#ifdef HAVE_XI2
|
||||||
} else
|
selectXIRawMotion();
|
||||||
{
|
#endif
|
||||||
// start watching for events on other windows
|
} else
|
||||||
|
{
|
||||||
|
// start watching for events on other windows
|
||||||
selectEvents(m_root);
|
selectEvents(m_root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1226,13 +1228,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||||
else if (xevent->type == KeyRelease &&
|
else if (xevent->type == KeyRelease &&
|
||||||
xevent->xkey.keycode == m_lastKeycode) {
|
xevent->xkey.keycode == m_lastKeycode) {
|
||||||
m_lastKeycode = 0;
|
m_lastKeycode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// now filter the event
|
// now filter the event
|
||||||
if (XFilterEvent(xevent, None)) {
|
if (XFilterEvent(xevent, DefaultRootWindow(m_display))) {
|
||||||
if (xevent->type == KeyPress) {
|
if (xevent->type == KeyPress) {
|
||||||
// add filtered presses to the filtered list
|
// add filtered presses to the filtered list
|
||||||
m_filtered.insert(m_lastKeycode);
|
m_filtered.insert(m_lastKeycode);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1249,12 +1251,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||||
// let screen saver have a go
|
// let screen saver have a go
|
||||||
if (m_screensaver->handleXEvent(xevent)) {
|
if (m_screensaver->handleXEvent(xevent)) {
|
||||||
// screen saver handled it
|
// screen saver handled it
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_xi2detected) {
|
#ifdef HAVE_XI2
|
||||||
// Process RawMotion
|
if (m_xi2detected) {
|
||||||
XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie;
|
// Process RawMotion
|
||||||
|
XGenericEventCookie *cookie = (XGenericEventCookie*)&xevent->xcookie;
|
||||||
if (XGetEventData(m_display, cookie) &&
|
if (XGetEventData(m_display, cookie) &&
|
||||||
cookie->type == GenericEvent &&
|
cookie->type == GenericEvent &&
|
||||||
cookie->extension == xi_opcode) {
|
cookie->extension == xi_opcode) {
|
||||||
|
@ -1279,12 +1282,13 @@ CXWindowsScreen::handleSystemEvent(const CEvent& event, void*)
|
||||||
XFreeEventData(m_display, cookie);
|
XFreeEventData(m_display, cookie);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XFreeEventData(m_display, cookie);
|
XFreeEventData(m_display, cookie);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// handle the event ourself
|
|
||||||
switch (xevent->type) {
|
// handle the event ourself
|
||||||
|
switch (xevent->type) {
|
||||||
case CreateNotify:
|
case CreateNotify:
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
// select events on new window
|
// select events on new window
|
||||||
|
@ -2061,16 +2065,17 @@ CXWindowsScreen::CHotKeyItem::operator<(const CHotKeyItem& x) const
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
CXWindowsScreen::detectXI2()
|
CXWindowsScreen::detectXI2()
|
||||||
{
|
{
|
||||||
int event, error;
|
int event, error;
|
||||||
return XQueryExtension(m_display,
|
return XQueryExtension(m_display,
|
||||||
"XInputExtension", &xi_opcode, &event, &error);
|
"XInputExtension", &xi_opcode, &event, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
#ifdef HAVE_XI2
|
||||||
CXWindowsScreen::selectXIRawMotion()
|
void
|
||||||
{
|
CXWindowsScreen::selectXIRawMotion()
|
||||||
|
{
|
||||||
XIEventMask mask;
|
XIEventMask mask;
|
||||||
|
|
||||||
mask.deviceid = XIAllDevices;
|
mask.deviceid = XIAllDevices;
|
||||||
|
@ -2080,6 +2085,7 @@ CXWindowsScreen::selectXIRawMotion()
|
||||||
memset(mask.mask, 0, 2);
|
memset(mask.mask, 0, 2);
|
||||||
XISetMask(mask.mask, XI_RawKeyRelease);
|
XISetMask(mask.mask, XI_RawKeyRelease);
|
||||||
XISetMask(mask.mask, XI_RawMotion);
|
XISetMask(mask.mask, XI_RawMotion);
|
||||||
XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
|
XISelectEvents(m_display, DefaultRootWindow(m_display), &mask, 1);
|
||||||
free(mask.mask);
|
free(mask.mask);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -137,13 +137,15 @@ private:
|
||||||
bool onHotKey(XKeyEvent&, bool isRepeat);
|
bool onHotKey(XKeyEvent&, bool isRepeat);
|
||||||
void onMousePress(const XButtonEvent&);
|
void onMousePress(const XButtonEvent&);
|
||||||
void onMouseRelease(const XButtonEvent&);
|
void onMouseRelease(const XButtonEvent&);
|
||||||
void onMouseMove(const XMotionEvent&);
|
void onMouseMove(const XMotionEvent&);
|
||||||
|
|
||||||
bool detectXI2();
|
bool detectXI2();
|
||||||
void selectXIRawMotion();
|
#ifdef HAVE_XI2
|
||||||
void selectEvents(Window) const;
|
void selectXIRawMotion();
|
||||||
void doSelectEvents(Window) const;
|
#endif
|
||||||
|
void selectEvents(Window) const;
|
||||||
|
void doSelectEvents(Window) const;
|
||||||
|
|
||||||
KeyID mapKeyFromX(XKeyEvent*) const;
|
KeyID mapKeyFromX(XKeyEvent*) const;
|
||||||
ButtonID mapButtonFromX(const XButtonEvent*) const;
|
ButtonID mapButtonFromX(const XButtonEvent*) const;
|
||||||
unsigned int mapButtonToX(ButtonID id) const;
|
unsigned int mapButtonToX(ButtonID id) const;
|
||||||
|
|
|
@ -1476,14 +1476,16 @@ CXWindowsUtil::mapKeySymToKeyID(KeySym k)
|
||||||
case XK_ISO_Left_Tab:
|
case XK_ISO_Left_Tab:
|
||||||
return kKeyLeftTab;
|
return kKeyLeftTab;
|
||||||
|
|
||||||
case XK_ISO_Level3_Shift:
|
case XK_ISO_Level3_Shift:
|
||||||
return kKeyAltGr;
|
return kKeyAltGr;
|
||||||
|
|
||||||
case XK_ISO_Level5_Shift:
|
#ifdef XK_ISO_Level5_Shift
|
||||||
return XK_ISO_Level5_Shift; //FIXME: there is no "usual" key for this...
|
case XK_ISO_Level5_Shift:
|
||||||
|
return XK_ISO_Level5_Shift; //FIXME: there is no "usual" key for this...
|
||||||
case XK_ISO_Next_Group:
|
#endif
|
||||||
return kKeyNextGroup;
|
|
||||||
|
case XK_ISO_Next_Group:
|
||||||
|
return kKeyNextGroup;
|
||||||
|
|
||||||
case XK_ISO_Prev_Group:
|
case XK_ISO_Prev_Group:
|
||||||
return kKeyPrevGroup;
|
return kKeyPrevGroup;
|
||||||
|
@ -1579,14 +1581,16 @@ CXWindowsUtil::getModifierBitForKeySym(KeySym keysym)
|
||||||
return kKeyModifierBitSuper;
|
return kKeyModifierBitSuper;
|
||||||
|
|
||||||
case XK_Mode_switch:
|
case XK_Mode_switch:
|
||||||
case XK_ISO_Level3_Shift:
|
case XK_ISO_Level3_Shift:
|
||||||
return kKeyModifierBitAltGr;
|
return kKeyModifierBitAltGr;
|
||||||
|
|
||||||
case XK_ISO_Level5_Shift:
|
#ifdef XK_ISO_Level5_Shift
|
||||||
return kKeyModifierBitLevel5Lock;
|
case XK_ISO_Level5_Shift:
|
||||||
|
return kKeyModifierBitLevel5Lock;
|
||||||
case XK_Caps_Lock:
|
#endif
|
||||||
return kKeyModifierBitCapsLock;
|
|
||||||
|
case XK_Caps_Lock:
|
||||||
|
return kKeyModifierBitCapsLock;
|
||||||
|
|
||||||
case XK_Num_Lock:
|
case XK_Num_Lock:
|
||||||
return kKeyModifierBitNumLock;
|
return kKeyModifierBitNumLock;
|
||||||
|
|
Loading…
Reference in New Issue