Skip to content

Commit f92dcc1

Browse files
committed
KeyboardGrabber: use pointer instead of boolean, add destination win
re #287, #288
1 parent 5a4cdc7 commit f92dcc1

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/gui/keyboardgrab/KeyboardGrabber.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ class KeyboardGrabber
1010

1111
void grab(wxWindow* window);
1212
void ungrab();
13-
bool isGrabbed() const { return m_grabbed; }
13+
bool isGrabbed() const { return m_grab != nullptr; }
14+
wxWindow* getDestinationWindow() const { return m_destinationWindow; }
1415

1516
private:
16-
bool m_grabbed = false;
17+
void* m_grab = nullptr;
18+
wxWindow* m_destinationWindow = nullptr;
1719
};

src/gui/keyboardgrab/KeyboardGrabberGtk.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ void KeyboardGrabber::showPermissionDialog()
2020

2121
void KeyboardGrabber::grab(wxWindow* window)
2222
{
23-
if(m_grabbed)
23+
if(m_grab)
2424
return;
2525

2626
gdk_keyboard_grab(gtk_widget_get_window(window->GetHandle()), True, GDK_CURRENT_TIME);
2727

28-
m_grabbed = true;
28+
m_grab = (void*)0x1; // Grab active
2929
wxLogDebug("%s", __func__);
3030
}
3131

@@ -34,6 +34,6 @@ void KeyboardGrabber::ungrab()
3434
{
3535
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
3636

37-
m_grabbed = false;
37+
m_grab = nullptr;
3838
wxLogDebug("%s", __func__);
3939
}

src/gui/keyboardgrab/KeyboardGrabberNull.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ void KeyboardGrabber::showPermissionDialog()
1414

1515
void KeyboardGrabber::grab(wxWindow*)
1616
{
17-
m_grabbed = true;
17+
m_grab = (void*)0x1; // Grab active
1818
}
1919

2020

2121
void KeyboardGrabber::ungrab()
2222
{
23-
m_grabbed = false;
23+
m_grab = nullptr;
2424
}

0 commit comments

Comments
 (0)