Skip to content

Commit

Permalink
Haiku bug #18172 workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
X547 committed Dec 25, 2022
1 parent 3042c2c commit 64ad060
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions HaikuSeat.cpp
Expand Up @@ -168,6 +168,23 @@ static uint32_t FromHaikuModifiers(uint32 haikuModifiers)
return wlModifiers;
}

bool IsHaikuSystemShortcut(BMessage *msg)
{
// Haiku bug #18172 workaround

const char* bytes = NULL;
if (msg->FindString("bytes", &bytes) < B_OK)
return false;

char key = bytes[0];
int32 rawKey = msg->GetInt32("key", 0);
uint32 modifiers = msg->GetInt32("modifiers", 0);

return
((key == B_TAB || rawKey == 0x11) && (modifiers & B_CONTROL_KEY) != 0) ||
(key == B_FUNCTION_KEY && rawKey == B_PRINT_KEY);
}

class SurfaceCursorHook: public HaikuSurface::Hook {
public:
BPoint fHotspot;
Expand Down
2 changes: 2 additions & 0 deletions HaikuSeat.h
Expand Up @@ -64,4 +64,6 @@ class HaikuSeat: public WlSeat {
};


bool IsHaikuSystemShortcut(BMessage *msg);

HaikuSeat *HaikuGetSeat(struct wl_client *wl_client);
4 changes: 4 additions & 0 deletions HaikuXdgPopup.cpp
@@ -1,6 +1,7 @@
#include "HaikuXdgPopup.h"
#include "HaikuXdgSurface.h"
#include "HaikuXdgPositioner.h"
#include "HaikuSeat.h"
#include "WaylandEnv.h"

#include "AppKitPtrs.h"
Expand Down Expand Up @@ -43,6 +44,9 @@ void WaylandPopupWindow::DispatchMessage(BMessage *msg, BHandler *target)
switch (msg->what) {
case B_KEY_DOWN:
case B_UNMAPPED_KEY_DOWN:
if (IsHaikuSystemShortcut(msg))
break;

// Do not use built-in shortcut handling.
target->MessageReceived(msg);
return;
Expand Down
3 changes: 3 additions & 0 deletions HaikuXdgToplevel.cpp
Expand Up @@ -88,6 +88,9 @@ void WaylandWindow::DispatchMessage(BMessage *msg, BHandler *target)
switch (msg->what) {
case B_KEY_DOWN:
case B_UNMAPPED_KEY_DOWN:
if (IsHaikuSystemShortcut(msg))
break;

// Do not use built-in shortcut handling.
target->MessageReceived(msg);
return;
Expand Down

0 comments on commit 64ad060

Please sign in to comment.