/[svn]/qsampler/trunk/src/qsampler.cpp
ViewVC logotype

Diff of /qsampler/trunk/src/qsampler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2839 by capela, Tue Aug 25 18:36:55 2015 UTC revision 3421 by capela, Sat Feb 17 19:45:17 2018 UTC
# Line 1  Line 1 
1  // qsampler.cpp  // qsampler.cpp
2  //  //
3  /****************************************************************************  /****************************************************************************
4     Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved.     Copyright (C) 2004-2018, rncbc aka Rui Nuno Capela. All rights reserved.
5     Copyright (C) 2007, 2008 Christian Schoenebeck     Copyright (C) 2007,2008,2015 Christian Schoenebeck
6    
7     This program is free software; you can redistribute it and/or     This program is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License     modify it under the terms of the GNU General Public License
# Line 33  Line 33 
33  #include <QDir>  #include <QDir>
34  #endif  #endif
35    
36  #define CONFIG_QUOTE1(x) #x  #ifndef CONFIG_PREFIX
37  #define CONFIG_QUOTED(x) CONFIG_QUOTE1(x)  #define CONFIG_PREFIX   "/usr/local"
38    #endif
39    
40  #if defined(DATADIR)  #ifndef CONFIG_DATADIR
41  #define CONFIG_DATADIR CONFIG_QUOTED(DATADIR)  #define CONFIG_DATADIR  CONFIG_PREFIX "/share"
 #else  
 #define CONFIG_DATADIR CONFIG_PREFIX "/share"  
42  #endif  #endif
43    
44  #if WIN32  #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
45  #define RELATIVE_LOCALE_DIR "/share/locale"  #define RELATIVE_LOCALE_DIR "/share/locale"
46  #elif defined(__APPLE__)  #elif defined(__APPLE__)
47  #define RELATIVE_LOCALE_DIR "/../Resources"  #define RELATIVE_LOCALE_DIR "/../Resources"
# Line 169  public: Line 168  public:
168                  }                  }
169          #ifdef CONFIG_X11          #ifdef CONFIG_X11
170          #ifdef CONFIG_XUNIQUE          #ifdef CONFIG_XUNIQUE
171                  // Instance uniqueness initialization...                  m_pDisplay = NULL;
172                  m_pDisplay = QX11Info::display();                  m_aUnique = 0;
173                  m_aUnique  = XInternAtom(m_pDisplay, QSAMPLER_XUNIQUE, false);                  m_wOwner = 0;
                 XGrabServer(m_pDisplay);  
                 m_wOwner = XGetSelectionOwner(m_pDisplay, m_aUnique);  
                 XUngrabServer(m_pDisplay);  
174          #if QT_VERSION >= 0x050100          #if QT_VERSION >= 0x050100
175                  m_pXcbEventFilter = new qsamplerXcbEventFilter(this);                  m_pXcbEventFilter = new qsamplerXcbEventFilter(this);
176                  installNativeEventFilter(m_pXcbEventFilter);                  installNativeEventFilter(m_pXcbEventFilter);
177                    if (QX11Info::isPlatformX11()) {
178            #endif
179                            // Instance uniqueness initialization...
180                            m_pDisplay = QX11Info::display();
181                            m_aUnique  = XInternAtom(m_pDisplay, QSAMPLER_XUNIQUE, false);
182                            XGrabServer(m_pDisplay);
183                            m_wOwner = XGetSelectionOwner(m_pDisplay, m_aUnique);
184                            XUngrabServer(m_pDisplay);
185            #if QT_VERSION >= 0x050100
186                    }
187          #endif          #endif
188          #endif  // CONFIG_XUNIQUE          #endif  // CONFIG_XUNIQUE
189          #endif  // CONFIG_X11          #endif  // CONFIG_X11
# Line 204  public: Line 210  public:
210                  m_pWidget = pWidget;                  m_pWidget = pWidget;
211          #ifdef CONFIG_X11          #ifdef CONFIG_X11
212          #ifdef CONFIG_XUNIQUE          #ifdef CONFIG_XUNIQUE
                 XGrabServer(m_pDisplay);  
213                  m_wOwner = m_pWidget->winId();                  m_wOwner = m_pWidget->winId();
214                  XSetSelectionOwner(m_pDisplay, m_aUnique, m_wOwner, CurrentTime);                  if (m_pDisplay && m_wOwner) {
215                  XUngrabServer(m_pDisplay);                          XGrabServer(m_pDisplay);
216                            XSetSelectionOwner(m_pDisplay, m_aUnique, m_wOwner, CurrentTime);
217                            XUngrabServer(m_pDisplay);
218                    }
219          #endif  // CONFIG_XUNIQUE          #endif  // CONFIG_XUNIQUE
220          #endif  // CONFIG_X11          #endif  // CONFIG_X11
221          }          }
# Line 220  public: Line 228  public:
228          {          {
229          #ifdef CONFIG_X11          #ifdef CONFIG_X11
230          #ifdef CONFIG_XUNIQUE          #ifdef CONFIG_XUNIQUE
231                  if (m_wOwner != None) {                  if (m_pDisplay && m_wOwner != None) {
232                          // First, notify any freedesktop.org WM                          // First, notify any freedesktop.org WM
233                          // that we're about to show the main widget...                          // that we're about to show the main widget...
234                          Screen *pScreen = XDefaultScreenOfDisplay(m_pDisplay);                          Screen *pScreen = XDefaultScreenOfDisplay(m_pDisplay);
# Line 265  public: Line 273  public:
273  #ifdef CONFIG_XUNIQUE  #ifdef CONFIG_XUNIQUE
274          void x11PropertyNotify(Window w)          void x11PropertyNotify(Window w)
275          {          {
276                  if (m_pWidget && m_wOwner == w) {                  if (m_pDisplay && m_pWidget && m_wOwner == w) {
277                          // Always check whether our property-flag is still around...                          // Always check whether our property-flag is still around...
278                          Atom aType;                          Atom aType;
279                          int iFormat = 0;                          int iFormat = 0;
# Line 506  int main ( int argc, char **argv ) Line 514  int main ( int argc, char **argv )
514    
515    
516  // end of qsampler.cpp  // end of qsampler.cpp
517    

Legend:
Removed from v.2839  
changed lines
  Added in v.3421

  ViewVC Help
Powered by ViewVC