Hi,

thanks for the Help. Here is another version of my patch.

comments welcome,
thanks
Philip


-- 
A byte walks into a bar and orders a pint. Bartender asks him "What's wrong?"
Byte says "Parity error." Bartender nods and says "Yeah, I thought you looked
a bit off."
Index: src/mainwin.h
===================================================================
--- src/mainwin.h       (revision 4440)
+++ src/mainwin.h       (working copy)
@@ -26,6 +26,7 @@
 #include "licq_user.h"
 #include "licqdialog.h"
 #include "gui-defines.h"
+#include "support.h"
 
 #define MSN_PPID 0x4D534E5F
 
@@ -153,6 +154,10 @@
        m_bSortColumnAscending,
        m_bAppendLineBreak,
        m_bFlashTaskbar,
+#ifndef USE_KDE
+       m_bMainWinSticky,
+       m_bMsgWinSticky,
+#endif
        m_bShowUserIcons;
 
   QString m_MsgAutopopupKey;
@@ -383,6 +388,10 @@
                         const QString& filename, const QString& description);
   void sendChatRequest(const char* szId, unsigned long nPPID);
   void addUser(const char* szId, unsigned long nPPID);
+#ifndef USE_KDE
+  void setMainWinSticky();
+  void changeMainWinSticky(bool _bStick);
+#endif
 
 signals:
   void changeDockStatus(unsigned short);
Index: src/support.h
===================================================================
--- src/support.h       (revision 0)
+++ src/support.h       (revision 0)
@@ -0,0 +1,28 @@
+#ifndef SUPPORT_H
+#define SUPPORT_H
+
+/* 
+ * Class for Support for LICQ Windows
+ *
+ * Currently used for Sticky Window Feature
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <qwindowdefs.h>
+
+class CSupport {
+
+public:
+       CSupport();
+       ~CSupport();
+
+#ifndef USE_KDE
+        static void changeWinSticky(WId win, bool _bStick);
+#endif //USE_KDE
+
+};
+#endif
Index: src/usereventdlg.h
===================================================================
--- src/usereventdlg.h  (revision 4440)
+++ src/usereventdlg.h  (working copy)
@@ -101,6 +101,10 @@
 #endif   // KDE_VERSION
 #endif // USE_KDE
   
+#ifndef USE_KDE
+  void changeMsgWinSticky(bool _bStick);
+#endif
+ 
 private:
   CETabWidget *tabw;
   CMainWindow *mainwin;
@@ -113,6 +117,12 @@
   void moveLeft();
   void moveRight();
 
+protected slots:
+#ifndef USE_KDE
+  void setMsgWinSticky();
+#endif
+
+
 signals:
   void signal_done();
 };
@@ -136,6 +146,9 @@
   bool FindUserInConvo(char *);
   void AddEventTag(unsigned long n)  { if (n) m_lnEventTag.push_back(n); }
   void gotTyping(unsigned short);
+#ifndef USE_KDE
+  void changeMsgWinSticky(bool _bStick);
+#endif
    
   enum type {
        UC_MESSAGE,
@@ -186,6 +199,9 @@
   void slot_usermenu() { gMainWindow->SetUserMenuUser(m_szId, m_nPPID); }
   void slot_security();
   void slot_setEncoding(int encodingMib);
+#ifndef USE_KDE
+  void setMsgWinSticky();
+#endif
 
 signals:
   void finished(const char *, unsigned long);
Index: src/usereventdlg.cpp
===================================================================
--- src/usereventdlg.cpp        (revision 4440)
+++ src/usereventdlg.cpp        (working copy)
@@ -89,6 +89,7 @@
 #include "xpm/chatChangeFg.xpm"
 #include "xpm/chatChangeBg.xpm"
 #include "xpm/smile.xpm"
+#include "support.h"
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
@@ -217,6 +218,16 @@
 
   mainWidget = new QWidget(this);
   top_lay->addWidget(mainWidget);
+
+#ifndef USE_KDE
+  // Check if we want the window sticky
+  if (!m->m_bTabbedChatting && m->m_bMsgWinSticky)
+  {
+     QTimer *timer = new QTimer( this );
+     connect( timer, SIGNAL(timeout()), this, SLOT(setMsgWinSticky()) );
+     timer->start( 100, TRUE ); // 100 milliseconds single-shot timer
+  }
+#endif
 }
 
 void UserEventCommon::slot_connectsignal()
@@ -495,6 +506,20 @@
 #endif   // KDE_VERSION
 #endif // USE_KDE
 
+#ifndef USE_KDE
+void UserEventTabDlg::setMsgWinSticky()
+{
+    CSupport* s = new CSupport();
+    return s->changeWinSticky(winId(), true);
+}
+
+void UserEventTabDlg::changeMsgWinSticky(bool _bStick)
+{
+    CSupport* s = new CSupport();
+    return s->changeWinSticky(winId(), _bStick);
+}
+#endif
+
 // 
-----------------------------------------------------------------------------
 
 void UserEventCommon::slot_setEncoding(int encodingMib) {
@@ -600,6 +625,20 @@
   XFree(hints);
 }
 
+#ifndef USE_KDE
+void UserEventCommon::setMsgWinSticky()
+{
+    CSupport* s = new CSupport();
+    return s->changeWinSticky(winId(), true);
+}
+
+void UserEventCommon::changeMsgWinSticky(bool _bStick)
+{
+    CSupport* s = new CSupport();
+    return s->changeWinSticky(winId(), _bStick);
+}
+#endif
+
 void UserEventCommon::slot_updatetime()
 {
   QDateTime t;
Index: src/optionsdlg.cpp
===================================================================
--- src/optionsdlg.cpp  (revision 4440)
+++ src/optionsdlg.cpp  (working copy)
@@ -242,6 +242,10 @@
   chkFlashTaskbar->setChecked(mainwin->m_bFlashTaskbar);
   chkAutoSendThroughServer->setChecked(mainwin->m_bAutoSendThroughServer);
   
chkEnableMainwinMouseMovement->setChecked(mainwin->m_bEnableMainwinMouseMovement);
+#ifndef USE_KDE
+  chkMainWinSticky->setChecked(mainwin->m_bMainWinSticky);
+  chkMsgWinSticky->setChecked(mainwin->m_bMsgWinSticky);
+#endif
   popEmail->setChecked(mainwin->m_bPopEmail);
   popPhone->setChecked(mainwin->m_bPopPhone);
   popFax->setChecked(mainwin->m_bPopFax);
@@ -537,6 +541,12 @@
   mainwin->m_bAutoSendThroughServer = chkAutoSendThroughServer->isChecked();
   mainwin->m_bEnableMainwinMouseMovement = 
chkEnableMainwinMouseMovement->isChecked();
 
+#ifndef USE_KDE
+  mainwin->m_bMainWinSticky = chkMainWinSticky->isChecked();
+  mainwin->changeMainWinSticky(chkMainWinSticky->isChecked());
+  mainwin->m_bMsgWinSticky = chkMsgWinSticky->isChecked();
+#endif
+
   mainwin->m_bPopEmail= popEmail->isChecked();
   mainwin->m_bPopPhone= popPhone->isChecked();
   mainwin->m_bPopFax= popFax->isChecked();
@@ -834,6 +844,14 @@
   chkSendTN = new QCheckBox(tr("Send typing notifications"), boxMainWin);
   QWhatsThis::add(chkSendTN, tr("Send a notification to the user so they can 
see when you are typing a message to them"));
 
+#ifndef USE_KDE
+  chkMainWinSticky = new QCheckBox(tr("Stick Main Window to all Desktops"), 
boxMainWin);
+  QWhatsThis::add(chkMainWinSticky, tr("Sets the sticky Bit of the Main window 
so it will stay with you on all desktops"));
+
+  chkMsgWinSticky = new QCheckBox(tr("Stick Message Window to all Desktops"), 
boxMainWin);
+  QWhatsThis::add(chkMsgWinSticky, tr("Sets the sticky Bit of every new 
Message window so it will stay with you on all desktops"));
+#endif
+
   l = new QVBoxLayout(l);
   boxLocale = new QGroupBox(1, Horizontal, tr("Localization"), w);
   lblDefaultEncoding = new QLabel(tr("Default Encoding:"), boxLocale);
Index: src/mainwin.cpp
===================================================================
--- src/mainwin.cpp     (revision 4440)
+++ src/mainwin.cpp     (working copy)
@@ -445,6 +445,10 @@
   licqConf.ReadBool("ChatAppendLinebreak", m_bAppendLineBreak, false);
   licqConf.ReadBool("FlashTaskbar", m_bFlashTaskbar, true);
   licqConf.ReadBool("ShowUserIcons", m_bShowUserIcons, true);
+#ifndef USE_KDE
+  licqConf.ReadBool("MainWinSticky", m_bMainWinSticky, false);
+  licqConf.ReadBool("MsgWinSticky", m_bMsgWinSticky, false);
+#endif
 
   licqConf.ReadStr("ReceiveMessageColor", szTemp, "red");
   m_colorRcv = QColor(szTemp);
@@ -817,6 +821,16 @@
           slot_protocolPlugin((*_ppit)->PPID());
     }
     FOR_EACH_PROTO_PLUGIN_END
+
+#ifndef USE_KDE
+   // Check if MainWin should be sticky
+   if (m_bMainWinSticky)
+   {
+       QTimer *timer = new QTimer( this );
+       connect( timer, SIGNAL(timeout()), this, SLOT(setMainWinSticky()));
+       timer->start( 100, TRUE ); // 100 milliseconds single-shot timer
+   }
+#endif
    
    // automatically logon if requested in conf file
    if (m_nAutoLogon > 0)
@@ -2898,9 +2912,18 @@
   {
     userEventTabDlg->addTab(e);
     userEventTabDlg->show();
+#ifndef USE_KDE
+    // Check if we want the window sticky
+    if (m_bMsgWinSticky)
+    {
+       QTimer *timer = new QTimer( userEventTabDlg );
+       connect( timer, SIGNAL(timeout()), userEventTabDlg, 
SLOT(setMsgWinSticky()));
+       timer->start( 100, TRUE ); // 100 milliseconds single-shot timer
+    }
+#endif // USE_KDE
   }
   else
-#endif
+#endif //QT_VERSION
     e->show();
 
   // there might be more than one send window open
@@ -3621,6 +3644,10 @@
   licqConf.WriteBool("EnableMainwinMouseMovement", 
m_bEnableMainwinMouseMovement);
   licqConf.WriteBool("FlashTaskbar", m_bFlashTaskbar);
   licqConf.WriteBool("ShowUserIcons", m_bShowUserIcons);
+#ifndef USE_KDE
+  licqConf.WriteBool("MainWinSticky", m_bMainWinSticky);
+  licqConf.WriteBool("MsgWinSticky", m_bMsgWinSticky);
+#endif
 
   licqConf.WriteNum("ChatMessageStyle", m_nMsgStyle);
   licqConf.WriteBool("ChatAppendLinebreak", m_bAppendLineBreak);
@@ -5077,4 +5104,20 @@
 
 // 
-----------------------------------------------------------------------------
 
+#ifndef USE_KDE
+void CMainWindow::setMainWinSticky()
+{
+    CSupport* s = new CSupport();
+    return s->changeWinSticky(winId(), true);
+}
+
+void CMainWindow::changeMainWinSticky(bool _bStick)
+{
+    CSupport* s = new CSupport();
+    return s->changeWinSticky(winId(), _bStick);
+}
+#endif
+
+// 
-----------------------------------------------------------------------------
+
 #include "mainwin.moc"
Index: src/support.cpp
===================================================================
--- src/support.cpp     (revision 0)
+++ src/support.cpp     (revision 0)
@@ -0,0 +1,80 @@
+/*
+ * Licq - A ICQ Client for Unix
+ *
+ * Copyright (C) 2003 Licq developers <licq-devel@lists.sourceforge.net>
+ *
+ * This program is licensed under the terms found in the LICENSE file.
+ *
+ * \file Support for LICQ Windows
+ */
+
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "support.h"
+
+#include "licq_log.h"
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+
+CSupport::CSupport()
+{
+}
+
+CSupport::~CSupport()
+{
+}
+
+#ifndef USE_KDE
+void CSupport::changeWinSticky(WId win, bool _bStick)
+{
+    // Philipp Kolmann: 2006-06-06
+    // Code from
+    // http://lists.trolltech.com/qt-interest/2006-01/thread00352-0.html
+    // provided by Bob Shaffer II [EMAIL PROTECTED]
+
+    gLog.Info("Setting Sticky state of window 0x%x to %d.\n",
+       (unsigned int) win, _bStick);
+
+    // connect to display
+    Display *display = XOpenDisplay("");
+
+    // root window receives these events
+    Window rootwinid = DefaultRootWindow(display);
+
+    // initialize necessary atoms
+    Atom StateAtom = XInternAtom(display, "_WIN_STATE", false);
+    Atom LayerAtom = XInternAtom(display, "_WIN_LAYER", false);
+
+    // construct and send (un)stick event
+    XEvent xev;
+    xev.type = ClientMessage;
+    xev.xclient.type = ClientMessage;
+    xev.xclient.window = win;
+    xev.xclient.message_type = StateAtom;
+    xev.xclient.format = 32;
+    xev.xclient.data.l[0] = (1<<0);
+    xev.xclient.data.l[1] = (_bStick?(1<<0):0);
+    XSendEvent(display, rootwinid, False, SubstructureRedirectMask |
+        SubstructureNotifyMask, &xev);
+
+    // construct and send layer setting event
+    // fyi: layers are 0=desktop 2=below 4=normal 6=above 8=dock 10=abovedock
+    xev.xclient.type = ClientMessage;
+    xev.xclient.window = win;
+    xev.xclient.message_type = LayerAtom;
+    xev.xclient.format = 32;
+    // Put it to 4=normal for now
+    xev.xclient.data.l[0] = 4;
+    XSendEvent(display, rootwinid, False, SubstructureRedirectMask |
+        SubstructureNotifyMask, &xev);
+
+    // close display
+    XCloseDisplay(display);
+}
+#endif //USE_KDE
Index: src/optionsdlg.h
===================================================================
--- src/optionsdlg.h    (revision 4440)
+++ src/optionsdlg.h    (working copy)
@@ -92,6 +92,9 @@
              *chkAlwaysShowONU, *chkScrollBar, *chkShowExtIcons,
              *chkSysBack, *chkSendFromClipboard, *chkMsgChatView, 
*chkAutoPosReplyWin,
             *chkFlashTaskbar, *chkAutoSendThroughServer, *chkTabbedChatting,
+#ifndef USE_KDE
+            *chkMainWinSticky, *chkMsgWinSticky,
+#endif
              *chkEnableMainwinMouseMovement, *chkShowHistory, *chkSendTN;
    QRadioButton *rdbDockDefault, *rdbDockThemed, *rdbDockSmall;
    QComboBox *cmbDockTheme, *cmbSortBy;
Index: src/Makefile.am
===================================================================
--- src/Makefile.am     (revision 4440)
+++ src/Makefile.am     (working copy)
@@ -21,7 +21,7 @@
        mmlistview.h mmsenddlg.h userinfodlg.h usereventdlg.h keyrequestdlg.h \
        jfcstyle.h usercodec.h reqauthdlg.h licqdialog.h userselectdlg.h \
        editfilelistdlg.h emoticon.h catdlg.h phonedlg.h ownermanagerdlg.h \
-       gpgkeyselect.h gpgkeymanager.h licqkimiface.h kimiface.h
+       gpgkeyselect.h gpgkeymanager.h licqkimiface.h kimiface.h support.h
 
 licq_gui = adduserdlg.cpp authuserdlg.cpp awaymsgdlg.cpp \
        refusedlg.cpp chatdlg.cpp editgrp.cpp editfile.cpp eventdesc.cpp \
@@ -34,7 +34,7 @@
        mmsenddlg.cpp userinfodlg.cpp usereventdlg.cpp keyrequestdlg.cpp \
        jfcstyle.cpp usercodec.cpp reqauthdlg.cpp licqdialog.cpp 
userselectdlg.cpp \
        editfilelistdlg.cpp emoticon.cpp catdlg.cpp phonedlg.cpp \
-       ownermanagerdlg.cpp gpgkeyselect.cpp gpgkeymanager.cpp 
+       ownermanagerdlg.cpp gpgkeyselect.cpp gpgkeymanager.cpp support.cpp
 
 licq_qt_gui_la_SOURCES = $(licq_gui)
 licq_kde_gui_la_SOURCES = $(licq_gui) wrap_kde_malloc.cpp \
Index: qt-gui.pro
===================================================================
--- qt-gui.pro  (revision 4440)
+++ qt-gui.pro  (working copy)
@@ -51,6 +51,7 @@
            src/sigman.h \
            src/skin.h \
            src/skinbrowser.h \
+           src/support.h \
            src/userbox.h \
            src/usercodec.h \
            src/usereventdlg.h \
@@ -100,6 +101,7 @@
            src/sigman.cpp \
            src/skin.cpp \
            src/skinbrowser.cpp \
+           src/support.cpp \
            src/userbox.cpp \
            src/usercodec.cpp \
            src/usereventdlg.cpp \
_______________________________________________
Licq-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/licq-devel

Reply via email to