app-misc/xmind: bump version to 24.12.04124
[gentoo-zh.git] / app-text / goldendict / files / remove-X11.patch
blob9ca31ef98551cfbd328e222945423921fdfa8e25
1 diff --git a/goldendict.pro b/goldendict.pro
2 index 5ce531a1..4f7895c7 100644
3 --- a/goldendict.pro
4 +++ b/goldendict.pro
5 @@ -185,10 +185,6 @@ win32 {
8 unix:!mac {
9 - DEFINES += HAVE_X11
11 - lessThan(QT_MAJOR_VERSION, 6): QT += x11extras
13 CONFIG += link_pkgconfig
15 PKGCONFIG += vorbisfile \
16 @@ -201,9 +197,6 @@ unix:!mac {
17 libavcodec \
18 libswresample \
20 - !arm {
21 - LIBS += -lX11 -lXtst
22 - }
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
31 #else
33 //////////////////////////////////////////////////////////////////////////
35 +#ifdef HAVE_X11
36 #include <X11/keysym.h>
37 +#endif
39 void HotkeyWrapper::init()
41 +#ifdef HAVE_X11
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 );
50 +#endif
51 start();
54 void HotkeyWrapper::run() // Runs in a separate thread
56 +#ifdef HAVE_X11
57 if ( !XRecordEnableContext( dataDisplay, recordContext, recordEventCallback, (XPointer)this ) )
58 GD_DPRINTF( "Failed to enable record context\n" );
59 +#endif
63 +#ifdef HAVE_X11
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 );
71 +#endif
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 )
79 +#ifdef HAVE_X11
80 if ( !key )
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
86 return true;
87 +#else
88 + return false;
89 +#endif
92 +#ifdef HAVE_X11
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" );
100 +#endif
102 quint32 HotkeyWrapper::nativeKey( int key )
104 +#ifdef HAVE_X11
105 QString keySymName;
107 switch ( key ) {
108 @@ -817,10 +830,14 @@ quint32 HotkeyWrapper::nativeKey( int key )
109 #endif
110 Display * display = displayID;
111 return XKeysymToKeycode( display, XStringToKeysym( keySymName.toLatin1().data() ) );
112 +#else
113 + return 0;
114 +#endif
117 void HotkeyWrapper::unregister()
119 +#ifdef HAVE_X11
120 #if QT_VERSION < 0x060000
121 Display * displayID = QX11Info::display();
122 #else
123 @@ -841,6 +858,7 @@ void HotkeyWrapper::unregister()
124 while ( grabbedKeys.size() )
125 ungrabKey( grabbedKeys.begin() );
127 +#endif
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:
137 #else
139 +#ifdef HAVE_X11
140 static void recordEventCallback( XPointer, XRecordInterceptData * );
142 /// Called by recordEventCallback()
143 void handleRecordEvent( XRecordInterceptData * );
145 +#endif
146 void run(); // QThread
148 +#ifdef HAVE_X11
149 // We do one-time init of those, translating keysyms to keycodes
150 KeyCode lShiftCode, rShiftCode, lCtrlCode, rCtrlCode, lAltCode, rAltCode, cCode, insertCode, kpInsertCode, lMetaCode,
151 rMetaCode;
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 );
156 +#endif
158 signals:
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 ) ) ) );
168 -#else
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 ) ) );
177 +#else
178 + return false;
179 #endif
181 diff --git a/src/main.cc b/src/main.cc
182 index 9fda4c60..f3a8b35a 100644
183 --- a/src/main.cc
184 +++ b/src/main.cc
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
193 // XWayland.
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.
200 Qt::Window
201 #else
202 - Qt::Dialog
203 + Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint
204 #endif
207 @@ -557,7 +557,7 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus )
208 #endif
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
215 /// wants
216 @@ -919,7 +919,7 @@ void ScanPopup::pinButtonClicked( bool checked )
217 setAttribute( Qt::WA_MacAlwaysShowToolWindow );
218 #endif
220 - setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict" ) );
221 + setWindowTitle( tr( "%1 - %2" ).arg( elideInputWord(), "GoldenDict Popup" ) );
222 dictionaryBar.setMovable( true );
223 hideTimer.stop();