1 diff --git a/goldendict.pro b/goldendict.pro
2 index 5ce531a1..4f7895c7 100644
5 @@ -185,10 +185,6 @@ win32 {
11 - lessThan(QT_MAJOR_VERSION, 6): QT += x11extras
13 CONFIG += link_pkgconfig
15 PKGCONFIG += vorbisfile \
16 @@ -201,9 +197,6 @@ unix:!mac {
21 - LIBS += -lX11 -lXtst
24 # Install prefix: first try to use qmake's PREFIX variable,
25 # then $PREFIX from system environment, and if both fails,
26 diff --git a/src/hotkeywrapper.cc b/src/hotkeywrapper.cc
27 index 5efe49cd..16b038be 100644
28 --- a/src/hotkeywrapper.cc
29 +++ b/src/hotkeywrapper.cc
30 @@ -525,11 +525,13 @@ bool QHotkeyApplication::nativeEventFilter( const QByteArray & /*eventType*/, vo
33 //////////////////////////////////////////////////////////////////////////
36 #include <X11/keysym.h>
39 void HotkeyWrapper::init()
42 keyToUngrab = grabbedKeys.end();
44 #if QT_VERSION < 0x060000
45 @@ -591,17 +593,20 @@ void HotkeyWrapper::init()
46 XSync( display, False );
48 connect( this, &HotkeyWrapper::keyRecorded, this, &HotkeyWrapper::checkState, Qt::QueuedConnection );
54 void HotkeyWrapper::run() // Runs in a separate thread
57 if ( !XRecordEnableContext( dataDisplay, recordContext, recordEventCallback, (XPointer)this ) )
58 GD_DPRINTF( "Failed to enable record context\n" );
64 void HotkeyWrapper::recordEventCallback( XPointer ptr, XRecordInterceptData * data )
66 ( (HotkeyWrapper *)ptr )->handleRecordEvent( data );
67 @@ -648,6 +653,7 @@ void HotkeyWrapper::handleRecordEvent( XRecordInterceptData * data )
69 XRecordFreeData( data );
73 bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
75 @@ -657,6 +663,7 @@ bool HotkeyWrapper::setGlobalKey( QKeySequence const & seq, int handle )
77 bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modifier, int handle )
81 return false; // We don't monitor empty combinations
83 @@ -679,8 +686,12 @@ bool HotkeyWrapper::setGlobalKey( int key, int key2, Qt::KeyboardModifiers modif
84 grabKey( vk, mod ); // Make sure it doesn't get caught by other apps
93 bool HotkeyWrapper::isCopyToClipboardKey( quint32 keyCode, quint32 modifiers ) const
95 return modifiers == ControlMask && ( keyCode == cCode || keyCode == insertCode || keyCode == kpInsertCode );
96 @@ -796,9 +807,11 @@ void HotkeyWrapper::ungrabKey( GrabbedKeys::iterator i )
97 gdWarning( "Cannot ungrab the hotkey" );
102 quint32 HotkeyWrapper::nativeKey( int key )
108 @@ -817,10 +830,14 @@ quint32 HotkeyWrapper::nativeKey( int key )
110 Display * display = displayID;
111 return XKeysymToKeycode( display, XStringToKeysym( keySymName.toLatin1().data() ) );
117 void HotkeyWrapper::unregister()
120 #if QT_VERSION < 0x060000
121 Display * displayID = QX11Info::display();
123 @@ -841,6 +858,7 @@ void HotkeyWrapper::unregister()
124 while ( grabbedKeys.size() )
125 ungrabKey( grabbedKeys.begin() );
128 ( static_cast< QHotkeyApplication * >( qApp ) )->unregisterWrapper( this );
131 diff --git a/src/hotkeywrapper.hh b/src/hotkeywrapper.hh
132 index 718ef82a..e9a4651e 100644
133 --- a/src/hotkeywrapper.hh
134 +++ b/src/hotkeywrapper.hh
135 @@ -123,13 +123,15 @@ private:
140 static void recordEventCallback( XPointer, XRecordInterceptData * );
142 /// Called by recordEventCallback()
143 void handleRecordEvent( XRecordInterceptData * );
146 void run(); // QThread
149 // We do one-time init of those, translating keysyms to keycodes
150 KeyCode lShiftCode, rShiftCode, lCtrlCode, rCtrlCode, lAltCode, rAltCode, cCode, insertCode, kpInsertCode, lMetaCode,
152 @@ -160,6 +162,7 @@ private:
153 /// Ungrabs the given key. erasing it from grabbedKeys. The key's provided
154 /// as an interator inside the grabbedKeys set.
155 void ungrabKey( GrabbedKeys::iterator );
160 diff --git a/src/keyboardstate.cc b/src/keyboardstate.cc
161 index c201b85b..d13cd00c 100644
162 --- a/src/keyboardstate.cc
163 +++ b/src/keyboardstate.cc
164 @@ -40,7 +40,7 @@ bool KeyboardState::checkModifiersPressed( int mask )
165 return !( ( mask & Alt && !( keys & ( 1 << optionKeyBit ) ) ) || ( mask & Ctrl && !( keys & ( 1 << cmdKeyBit ) ) )
166 || ( mask & Shift && !( keys & ( 1 << shiftKeyBit ) ) )
167 || ( mask & Win && !( keys & ( 1 << controlKeyBit ) ) ) );
169 +#elif defined(HAVE_X11)
171 #if QT_VERSION < 0x060000
172 Display * displayID = QX11Info::display();
173 @@ -56,5 +56,7 @@ bool KeyboardState::checkModifiersPressed( int mask )
174 return !( ( mask & Alt && !( state.base_mods & Mod1Mask ) ) || ( mask & Ctrl && !( state.base_mods & ControlMask ) )
175 || ( mask & Shift && !( state.base_mods & ShiftMask ) )
176 || ( mask & Win && !( state.base_mods & Mod4Mask ) ) );
181 diff --git a/src/main.cc b/src/main.cc
182 index 9fda4c60..f3a8b35a 100644
185 @@ -307,7 +307,7 @@ void processCommandLine( QCoreApplication * app, GDOptions * result )
187 int main( int argc, char ** argv )
189 -#if defined( Q_OS_UNIX ) && !defined( Q_OS_MACOS )
190 +#if defined( Q_OS_UNIX ) && !defined( Q_OS_MACOS ) && defined(HAVE_X11)
191 // GoldenDict use lots of X11 functions and it currently cannot work
192 // natively on Wayland. This workaround will force GoldenDict to use
194 diff --git a/src/ui/scanpopup.cc b/src/ui/scanpopup.cc
195 index 026fc2b1..04b73ff8 100644
196 --- a/src/ui/scanpopup.cc
197 +++ b/src/ui/scanpopup.cc
198 @@ -40,7 +40,7 @@ static const Qt::WindowFlags pinnedWindowFlags =
199 /// Qt::Window allows to use the scan popup and the main window independently.
203 + Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint
207 @@ -557,7 +557,7 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus )
210 if ( ui.pinButton->isChecked() )
211 - setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict" ) );
212 + setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict Popup" ) );
214 /// Too large strings make window expand which is probably not what user
216 @@ -919,7 +919,7 @@ void ScanPopup::pinButtonClicked( bool checked )
217 setAttribute( Qt::WA_MacAlwaysShowToolWindow );
220 - setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict" ) );
221 + setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict Popup" ) );
222 dictionaryBar.setMovable( true );