Hi Guys, I want to make up a mod to be able to set the main window and the message window sticky (via options option).
I have dug into the code and came up with a patch, that does nearly what I want. The mainwindow is set sticky on start. But the message window is only set sticky when i open a second tab. I have looked into the code, but it seems i haven't found the proper place when to send the sticky info to the window-manager. Could someone have an eye on my diff and tell me where i am wrong. 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 4433) +++ src/mainwin.h (working copy) @@ -153,7 +153,9 @@ m_bSortColumnAscending, m_bAppendLineBreak, m_bFlashTaskbar, - m_bShowUserIcons; + m_bShowUserIcons, + m_bMainWinSticky, + m_bMsgWinSticky; QString m_MsgAutopopupKey; QString m_DefaultEncoding; @@ -383,6 +385,7 @@ const QString& filename, const QString& description); void sendChatRequest(const char* szId, unsigned long nPPID); void addUser(const char* szId, unsigned long nPPID); + void changeMainWinSticky(bool _bStick); signals: void changeDockStatus(unsigned short); Index: src/usereventdlg.h =================================================================== --- src/usereventdlg.h (revision 4433) +++ src/usereventdlg.h (working copy) @@ -100,6 +100,8 @@ virtual void setIcon(const QPixmap &icon); #endif // KDE_VERSION #endif // USE_KDE + + void UserEventTabDlg::changeMsgWinSticky(bool _bStick); private: CETabWidget *tabw; @@ -175,6 +177,7 @@ virtual void UserUpdated(CICQSignal *, char * = 0, unsigned long = 0) = 0; void SetGeneralInfo(ICQUser *); void FlashTaskbar(bool _bFlash); + void changeMsgWinSticky(bool _bStick); protected slots: void slot_connectsignal(); Index: src/usereventdlg.cpp =================================================================== --- src/usereventdlg.cpp (revision 4433) +++ src/usereventdlg.cpp (working copy) @@ -216,7 +216,14 @@ QTimer::singleShot(0, this, SLOT(slot_connectsignal())); mainWidget = new QWidget(this); + top_lay->addWidget(mainWidget); + + // Check if we want the window sticky + if (!m->m_bTabbedChatting && m->m_bMsgWinSticky) + { + changeMsgWinSticky(true); + } } void UserEventCommon::slot_connectsignal() @@ -236,6 +243,7 @@ connect(tabw, SIGNAL(currentChanged(QWidget *)), this, SLOT(slot_currentChanged(QWidget *))); #endif + } UserEventTabDlg::~UserEventTabDlg() @@ -495,6 +503,64 @@ #endif // KDE_VERSION #endif // USE_KDE +void UserEventTabDlg::changeMsgWinSticky(bool _bStick) +{ +#ifdef USE_KDE + // TODO: Set "All Desktops" + gLog.Info("Setting to All Desktops not supported currently\n"); + +#else + // Philipp Kolmann: + // Code from + // http://lists.trolltech.com/qt-interest/2006-01/thread00352-0.html + // provided by Bob Shaffer II [EMAIL PROTECTED] + + gLog.Info("Setting UserEventTabDlg Window Sticky state to %d.\n", _bStick); + + // connect to display + Display *display = XOpenDisplay(""); + // work with this window + Window win = winId(); + gLog.Info("UserEventTabDlg-WinID: 0x%x\n", (unsigned int) win); + + // 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 + +} + + // ----------------------------------------------------------------------------- void UserEventCommon::slot_setEncoding(int encodingMib) { @@ -600,6 +666,63 @@ XFree(hints); } +void UserEventCommon::changeMsgWinSticky(bool _bStick) +{ +#ifdef USE_KDE + // TODO: Set "All Desktops" + gLog.Info("Setting to All Desktops not supported currently\n"); + +#else + // Philipp Kolmann: + // Code from + // http://lists.trolltech.com/qt-interest/2006-01/thread00352-0.html + // provided by Bob Shaffer II [EMAIL PROTECTED] + gLog.Info("Setting UserEventCommon Window Sticky state to %d.\n", _bStick); + + // connect to display + Display *display = XOpenDisplay(""); + // work with this window + Window win = winId(); + + gLog.Info("WinId: 0x%x\n", (unsigned int) win); + + // 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; + int status = XSendEvent(display, rootwinid, False, SubstructureRedirectMask | + SubstructureNotifyMask, &xev); + +// gLog.Info("MsgWin Status: %n\d", status); + + // close display + XCloseDisplay(display); +#endif +} + void UserEventCommon::slot_updatetime() { QDateTime t; @@ -1763,8 +1886,10 @@ connect (mleSend, SIGNAL(signal_CtrlEnterPressed()), btnSend, SIGNAL(clicked())); connect(mleSend, SIGNAL(textChanged()), this, SLOT(slot_textChanged())); connect(this, SIGNAL(updateUser(CICQSignal*)), mainwin, SLOT(slot_updatedUser(CICQSignal*))); + } + UserSendCommon::~UserSendCommon() { } Index: src/optionsdlg.cpp =================================================================== --- src/optionsdlg.cpp (revision 4433) +++ 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,12 @@ 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); + 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 Msg Window to all Desktops"), boxMainWin); + QWhatsThis::add(chkMsgWinSticky, tr("Sets the sticky Bit of every new Msg window so it will stay with you on all desktops")); + 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 4433) +++ 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,12 @@ slot_protocolPlugin((*_ppit)->PPID()); } FOR_EACH_PROTO_PLUGIN_END + + // Check if MainWin should be sticky + if (m_bMainWinSticky) + { + changeMainWinSticky(true); + } // automatically logon if requested in conf file if (m_nAutoLogon > 0) @@ -2898,6 +2906,11 @@ { userEventTabDlg->addTab(e); userEventTabDlg->show(); + // Check if we want the window sticky + if (m_bMsgWinSticky) + { + userEventTabDlg->changeMsgWinSticky(true); + } } else #endif @@ -3621,6 +3634,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 +5092,63 @@ // ----------------------------------------------------------------------------- +void CMainWindow::changeMainWinSticky(bool _bStick) +{ +#ifdef USE_KDE + // TODO: Set "All Desktops" + gLog.Info("Setting to All Desktops not supported currently\n"); + +#else + // Philipp Kolmann: + // Code from + // http://lists.trolltech.com/qt-interest/2006-01/thread00352-0.html + // provided by Bob Shaffer II [EMAIL PROTECTED] + + gLog.Info("Setting Main Window Sticky state to %d.\n", _bStick); + + // connect to display + Display *display = XOpenDisplay(""); + // work with this window + Window win = winId(); + gLog.Info("MainWinId: 0x%x\n", (unsigned int) win); + + // 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 + +} + +// ----------------------------------------------------------------------------- + #include "mainwin.moc" Index: src/optionsdlg.h =================================================================== --- src/optionsdlg.h (revision 4433) +++ src/optionsdlg.h (working copy) @@ -92,7 +92,8 @@ *chkAlwaysShowONU, *chkScrollBar, *chkShowExtIcons, *chkSysBack, *chkSendFromClipboard, *chkMsgChatView, *chkAutoPosReplyWin, *chkFlashTaskbar, *chkAutoSendThroughServer, *chkTabbedChatting, - *chkEnableMainwinMouseMovement, *chkShowHistory, *chkSendTN; + *chkEnableMainwinMouseMovement, *chkShowHistory, *chkSendTN, + *chkMainWinSticky, *chkMsgWinSticky; QRadioButton *rdbDockDefault, *rdbDockThemed, *rdbDockSmall; QComboBox *cmbDockTheme, *cmbSortBy;
_______________________________________________ Licq-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/licq-devel