mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Linux: Implement support for extra mouse buttons
This commit is contained in:
parent
c01bf65d3f
commit
fa6fa9a61a
2 changed files with 30 additions and 23 deletions
|
|
@ -411,7 +411,9 @@ namespace Keys
|
||||||
MiddleButton = 2,
|
MiddleButton = 2,
|
||||||
RightButton = 3,
|
RightButton = 3,
|
||||||
WheelUp = 4,
|
WheelUp = 4,
|
||||||
WheelDown = 5
|
WheelDown = 5,
|
||||||
|
BackButton = 6,
|
||||||
|
ForwardButton = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
static int AltMask = 0;
|
static int AltMask = 0;
|
||||||
|
|
@ -2518,6 +2520,7 @@ ModifierKeys XWindowSystem::getNativeRealtimeModifiers() const
|
||||||
|
|
||||||
XWindowSystemUtilities::ScopedXLock xLock;
|
XWindowSystemUtilities::ScopedXLock xLock;
|
||||||
|
|
||||||
|
// xQueryPointer doesn't emit masks for back/forward buttons.
|
||||||
if (X11Symbols::getInstance()->xQueryPointer (display,
|
if (X11Symbols::getInstance()->xQueryPointer (display,
|
||||||
X11Symbols::getInstance()->xRootWindow (display,
|
X11Symbols::getInstance()->xRootWindow (display,
|
||||||
X11Symbols::getInstance()->xDefaultScreen (display)),
|
X11Symbols::getInstance()->xDefaultScreen (display)),
|
||||||
|
|
@ -3077,26 +3080,24 @@ void XWindowSystem::setWindowType (::Window windowH, int styleFlags) const
|
||||||
|
|
||||||
void XWindowSystem::initialisePointerMap()
|
void XWindowSystem::initialisePointerMap()
|
||||||
{
|
{
|
||||||
auto numButtons = X11Symbols::getInstance()->xGetPointerMapping (display, nullptr, 0);
|
const auto numButtons = X11Symbols::getInstance()->xGetPointerMapping (display, nullptr, 0);
|
||||||
pointerMap[2] = pointerMap[3] = pointerMap[4] = Keys::NoButton;
|
std::fill_n (pointerMap, std::size (pointerMap), Keys::NoButton);
|
||||||
|
|
||||||
if (numButtons == 2)
|
constexpr unsigned char twoButtons[] { Keys::LeftButton, Keys::RightButton };
|
||||||
{
|
constexpr unsigned char moreButtons[] { Keys::LeftButton,
|
||||||
pointerMap[0] = Keys::LeftButton;
|
Keys::MiddleButton,
|
||||||
pointerMap[1] = Keys::RightButton;
|
Keys::RightButton,
|
||||||
}
|
Keys::WheelUp,
|
||||||
else if (numButtons >= 3)
|
Keys::WheelDown,
|
||||||
{
|
Keys::NoButton,
|
||||||
pointerMap[0] = Keys::LeftButton;
|
Keys::NoButton,
|
||||||
pointerMap[1] = Keys::MiddleButton;
|
Keys::BackButton,
|
||||||
pointerMap[2] = Keys::RightButton;
|
Keys::ForwardButton };
|
||||||
|
static_assert (std::size (moreButtons) >= std::size (decltype (pointerMap){}));
|
||||||
|
|
||||||
if (numButtons >= 5)
|
auto* sourceArray = numButtons == 2 ? twoButtons : moreButtons;
|
||||||
{
|
const auto numToCopy = jmin (numButtons, (int) std::size (pointerMap));
|
||||||
pointerMap[3] = Keys::WheelUp;
|
std::copy (sourceArray, sourceArray + numToCopy, pointerMap);
|
||||||
pointerMap[4] = Keys::WheelDown;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XWindowSystem::deleteIconPixmaps (::Window windowH) const
|
void XWindowSystem::deleteIconPixmaps (::Window windowH) const
|
||||||
|
|
@ -3620,6 +3621,9 @@ void XWindowSystem::handleButtonPressEvent (LinuxComponentPeer* peer, const XBut
|
||||||
case Keys::LeftButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::leftButtonModifier); break;
|
case Keys::LeftButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::leftButtonModifier); break;
|
||||||
case Keys::RightButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::rightButtonModifier); break;
|
case Keys::RightButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::rightButtonModifier); break;
|
||||||
case Keys::MiddleButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::middleButtonModifier); break;
|
case Keys::MiddleButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::middleButtonModifier); break;
|
||||||
|
case Keys::BackButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::backButtonModifier); break;
|
||||||
|
case Keys::ForwardButton: handleButtonPressEvent (peer, buttonPressEvent, ModifierKeys::forwardButtonModifier); break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3638,9 +3642,12 @@ void XWindowSystem::handleButtonReleaseEvent (LinuxComponentPeer* peer, const XB
|
||||||
{
|
{
|
||||||
switch (pointerMap[mapIndex])
|
switch (pointerMap[mapIndex])
|
||||||
{
|
{
|
||||||
case Keys::LeftButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::leftButtonModifier); break;
|
case Keys::LeftButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::leftButtonModifier); break;
|
||||||
case Keys::RightButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::rightButtonModifier); break;
|
case Keys::RightButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::rightButtonModifier); break;
|
||||||
case Keys::MiddleButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::middleButtonModifier); break;
|
case Keys::MiddleButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::middleButtonModifier); break;
|
||||||
|
case Keys::BackButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::backButtonModifier); break;
|
||||||
|
case Keys::ForwardButton: ModifierKeys::currentModifiers = ModifierKeys::getCurrentModifiers().withoutFlags (ModifierKeys::forwardButtonModifier); break;
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int shmCompletionEvent = 0;
|
int shmCompletionEvent = 0;
|
||||||
int pointerMap[5] = {};
|
unsigned char pointerMap[9]{};
|
||||||
String localClipboardContent;
|
String localClipboardContent;
|
||||||
|
|
||||||
Point<int> parentScreenPosition;
|
Point<int> parentScreenPosition;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue