Hi,

thanks for the hint with kde. I haven't compiled it for kde.

Now I have and even included support for KDE's All Desktop feature. So this
patch now works for the QT and KDE plugin.

Thanks
Philipp


-- 
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,8 @@
        m_bSortColumnAscending,
        m_bAppendLineBreak,
        m_bFlashTaskbar,
+       m_bMainWinSticky,
+       m_bMsgWinSticky,
        m_bShowUserIcons;
 
   QString m_MsgAutopopupKey;
@@ -278,6 +281,7 @@
     unsigned short x = 0, unsigned short y = 0, unsigned short w = 0);
   void initMenu();
   bool show_user(ICQUser *);
+  void changeMainWinSticky(bool _bStick);
 
   virtual void resizeEvent (QResizeEvent *);
   virtual void moveEvent(QMoveEvent*);
@@ -383,6 +387,7 @@
                         const QString& filename, const QString& description);
   void sendChatRequest(const char* szId, unsigned long nPPID);
   void addUser(const char* szId, unsigned long nPPID);
+  void setMainWinSticky();
 
 signals:
   void changeDockStatus(unsigned short);
Index: src/support.h
===================================================================
--- src/support.h       (revision 0)
+++ src/support.h       (revision 0)
@@ -0,0 +1,23 @@
+#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:
+  static void changeWinSticky(WId win, bool _bStick);
+};
+
+#endif
+
Index: src/usereventdlg.h
===================================================================
--- src/usereventdlg.h  (revision 4440)
+++ src/usereventdlg.h  (working copy)
@@ -94,6 +94,7 @@
   void updateConvoLabel(UserEventCommon *tab);
   void updateTabLabel(ICQUser *u);
   void gotTyping(ICQUser *u, int);
+  void changeMsgWinSticky(bool _bStick);
 
 #ifdef USE_KDE
 #if KDE_VERSION >= 320
@@ -113,6 +114,9 @@
   void moveLeft();
   void moveRight();
 
+protected slots:
+  void setMsgWinSticky();
+
 signals:
   void signal_done();
 };
@@ -136,6 +140,7 @@
   bool FindUserInConvo(char *);
   void AddEventTag(unsigned long n)  { if (n) m_lnEventTag.push_back(n); }
   void gotTyping(unsigned short);
+  void changeMsgWinSticky(bool _bStick);
    
   enum type {
        UC_MESSAGE,
@@ -186,6 +191,7 @@
   void slot_usermenu() { gMainWindow->SetUserMenuUser(m_szId, m_nPPID); }
   void slot_security();
   void slot_setEncoding(int encodingMib);
+  void setMsgWinSticky();
 
 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,14 @@
 
   mainWidget = new QWidget(this);
   top_lay->addWidget(mainWidget);
+
+  // 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
+  }
 }
 
 void UserEventCommon::slot_connectsignal()
@@ -495,6 +504,16 @@
 #endif   // KDE_VERSION
 #endif // USE_KDE
 
+void UserEventTabDlg::setMsgWinSticky()
+{
+  CSupport::changeWinSticky(winId(), true);
+}
+
+void UserEventTabDlg::changeMsgWinSticky(bool _bStick)
+{
+  CSupport::changeWinSticky(winId(), _bStick);
+}
+
 // 
-----------------------------------------------------------------------------
 
 void UserEventCommon::slot_setEncoding(int encodingMib) {
@@ -600,6 +619,16 @@
   XFree(hints);
 }
 
+void UserEventCommon::setMsgWinSticky()
+{
+  CSupport::changeWinSticky(winId(), true);
+}
+
+void UserEventCommon::changeMsgWinSticky(bool _bStick)
+{
+  CSupport::changeWinSticky(winId(), _bStick);
+}
+
 void UserEventCommon::slot_updatetime()
 {
   QDateTime t;
Index: src/optionsdlg.cpp
===================================================================
--- src/optionsdlg.cpp  (revision 4440)
+++ src/optionsdlg.cpp  (working copy)
@@ -242,6 +242,8 @@
   chkFlashTaskbar->setChecked(mainwin->m_bFlashTaskbar);
   chkAutoSendThroughServer->setChecked(mainwin->m_bAutoSendThroughServer);
   
chkEnableMainwinMouseMovement->setChecked(mainwin->m_bEnableMainwinMouseMovement);
+  chkMainWinSticky->setChecked(mainwin->m_bMainWinSticky);
+  chkMsgWinSticky->setChecked(mainwin->m_bMsgWinSticky);
   popEmail->setChecked(mainwin->m_bPopEmail);
   popPhone->setChecked(mainwin->m_bPopPhone);
   popFax->setChecked(mainwin->m_bPopFax);
@@ -537,6 +539,10 @@
   mainwin->m_bAutoSendThroughServer = chkAutoSendThroughServer->isChecked();
   mainwin->m_bEnableMainwinMouseMovement = 
chkEnableMainwinMouseMovement->isChecked();
 
+  mainwin->m_bMainWinSticky = chkMainWinSticky->isChecked();
+  mainwin->changeMainWinSticky(chkMainWinSticky->isChecked());
+  mainwin->m_bMsgWinSticky = chkMsgWinSticky->isChecked();
+
   mainwin->m_bPopEmail= popEmail->isChecked();
   mainwin->m_bPopPhone= popPhone->isChecked();
   mainwin->m_bPopFax= popFax->isChecked();
@@ -834,6 +840,20 @@
   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"));
 
+  chkMainWinSticky = new QCheckBox(tr("Stick Main Window to all Desktops"), 
boxMainWin);
+#ifdef USE_KDE
+  QWhatsThis::add(chkMainWinSticky, tr("Makes the Main window visible on all 
desktops"));
+#else
+  QWhatsThis::add(chkMainWinSticky, tr("Sets the sticky Bit of the Main window 
so it will stay with you on all desktops"));
+#endif
+
+  chkMsgWinSticky = new QCheckBox(tr("Stick Message Window to all Desktops"), 
boxMainWin);
+#ifdef USE_KDE
+  QWhatsThis::add(chkMainWinSticky, tr("Makes the Message window visible on 
all desktops"));
+#else
+  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,8 @@
   licqConf.ReadBool("ChatAppendLinebreak", m_bAppendLineBreak, false);
   licqConf.ReadBool("FlashTaskbar", m_bFlashTaskbar, true);
   licqConf.ReadBool("ShowUserIcons", m_bShowUserIcons, true);
+  licqConf.ReadBool("MainWinSticky", m_bMainWinSticky, false);
+  licqConf.ReadBool("MsgWinSticky", m_bMsgWinSticky, false);
 
   licqConf.ReadStr("ReceiveMessageColor", szTemp, "red");
   m_colorRcv = QColor(szTemp);
@@ -817,6 +819,14 @@
           slot_protocolPlugin((*_ppit)->PPID());
     }
     FOR_EACH_PROTO_PLUGIN_END
+
+   // 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
+   }
    
    // automatically logon if requested in conf file
    if (m_nAutoLogon > 0)
@@ -2898,6 +2908,13 @@
   {
     userEventTabDlg->addTab(e);
     userEventTabDlg->show();
+    // 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
+    }
   }
   else
 #endif
@@ -3621,6 +3638,8 @@
   licqConf.WriteBool("EnableMainwinMouseMovement", 
m_bEnableMainwinMouseMovement);
   licqConf.WriteBool("FlashTaskbar", m_bFlashTaskbar);
   licqConf.WriteBool("ShowUserIcons", m_bShowUserIcons);
+  licqConf.WriteBool("MainWinSticky", m_bMainWinSticky);
+  licqConf.WriteBool("MsgWinSticky", m_bMsgWinSticky);
 
   licqConf.WriteNum("ChatMessageStyle", m_nMsgStyle);
   licqConf.WriteBool("ChatAppendLinebreak", m_bAppendLineBreak);
@@ -5077,4 +5096,16 @@
 
 // 
-----------------------------------------------------------------------------
 
+void CMainWindow::setMainWinSticky()
+{
+  CSupport::changeWinSticky(winId(), true);
+}
+
+void CMainWindow::changeMainWinSticky(bool _bStick)
+{
+  CSupport::changeWinSticky(winId(), _bStick);
+}
+
+// 
-----------------------------------------------------------------------------
+
 #include "mainwin.moc"
Index: src/support.cpp
===================================================================
--- src/support.cpp     (revision 0)
+++ src/support.cpp     (revision 0)
@@ -0,0 +1,74 @@
+/*
+ * 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"
+#ifdef USE_KDE
+#include <kwin.h>
+#else
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#endif
+
+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);
+
+#ifdef USE_KDE
+  KWin::setOnAllDesktops(win, _bStick);
+#else
+  // 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,7 @@
              *chkAlwaysShowONU, *chkScrollBar, *chkShowExtIcons,
              *chkSysBack, *chkSendFromClipboard, *chkMsgChatView, 
*chkAutoPosReplyWin,
             *chkFlashTaskbar, *chkAutoSendThroughServer, *chkTabbedChatting,
+            *chkMainWinSticky, *chkMsgWinSticky,
              *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 \

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Licq-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/licq-devel

Reply via email to