You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdedocker/src/qtraylabel.h

162 lines
5.7 KiB

11 years ago
/*
* Copyright (C) 2004 Girish Ramakrishnan All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
// $Id: qtraylabel.h,v 1.21 2005/06/21 10:04:36 cs19713 Exp $
#ifndef _QTRAYLABEL_H
#define _QTRAYLABEL_H
#include <tqlabel.h>
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqpixmap.h>
#include <tqtimer.h>
#include <tqtextstream.h>
#include <tqsettings.h>
#include <tqevent.h>
#include <tqsize.h>
11 years ago
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <sys/types.h>
#include <unistd.h>
class TQMouseEvent;
class TQDragEnterEvent;
class TQPoint;
11 years ago
class TQTrayLabel : public TQLabel
11 years ago
{
Q_OBJECT
public:
TQTrayLabel(Window w, TQWidget* p = 0, const TQString& text = TQString::null);
TQTrayLabel(const TQStringList& argv, pid_t pid, TQWidget* parent = 0);
virtual ~TQTrayLabel();
11 years ago
// Accessors
Window dockedWindow(void) const { return mDockedWindow; }
int balloonTimeout(void) const { return mBalloonTimeout; }
bool isSkippingTaskbar(void) const { return mSkippingTaskbar; }
bool isWithdrawn(void) const { return mWithdrawn; }
bool isDockWhenMinimized(void) const { return mDockWhenMinimized; }
TQString appName(void) const { return mProgName[0]; }
virtual void setAppName(const TQString& prog) { mProgName[0] = prog; }
TQString appClass(void) const { return mClass; }
TQString appTitle(void) const { return mTitle; }
TQPixmap appIcon(void) const { return mAppIcon; }
11 years ago
// Pass on all events through this interface
bool x11EventFilter(XEvent * event);
// Session Management
virtual bool saveState(TQSettings& settings);
virtual bool restoreState(TQSettings& settings);
11 years ago
public slots:
void dock(void); // puts us in the system tray
void undock(void); // removes us from the system tray
void map(void); // maps the window that we are docking
void withdraw(void); // withdraws the window that we are docking
void toggleShow(void) // convenience slot
{ if (mWithdrawn) map(); else withdraw(); }
void close(void); // close the docked window
void setTrayIcon(const TQString& icon); // sets custom icon
11 years ago
// and some property setters
virtual void setSkipTaskbar(bool skip); // skip the taskbar
virtual void setBalloonTimeout(int msecs) { mBalloonTimeout = msecs; }
virtual void setDockWhenMinimized(bool dwm) { mDockWhenMinimized = dwm; }
protected slots:
void scanClients(void); // scans existing client connections
signals:
void clicked(const ButtonState&, const TQPoint&);
void docked(TQTrayLabel *); // emitted when we get docked
11 years ago
void docked(void); // emitted when we get docked
void undocked(TQTrayLabel *); // emitted when we get undocked
11 years ago
void undocked(void); // emitted when we get undock
// window are monitoring dies
void sysTrayDestroyed(void); // emitted when the system tray disappears
protected:
// reimplement these event handlers in subclass as needed
virtual void mouseReleaseEvent(TQMouseEvent *event);
virtual void dragEnterEvent(TQDragEnterEvent *event);
11 years ago
// the events that follow are events of the docked window (NOT TQTrayLabel)
11 years ago
virtual void updateIcon(void); // updates the icon
virtual void updateTitle(void); // sets the tooltip
virtual void balloonText(void); // balloons text
virtual void obscureEvent(void) { }
virtual void mapEvent(void) { }
virtual void focusLostEvent(void) { }
virtual void unmapEvent(void) { }
virtual void minimizeEvent(void);
virtual void destroyEvent(void);
// needs to return if we can unsubscribe for root
virtual bool canUnsubscribeFromRoot(void) { return true; }
// needs to return if we can dock a candidate window
virtual bool canDockWindow(Window) { return true; }
virtual void processDead(void) { }
void propertyChangeEvent(Atom);
void setDockedWindow(Window w); // set docked window to anything you want
private slots:
void realityCheck(void);
void showOnAllDesktops(void);
void toggleDockWhenMinimized(void)
{ mDockWhenMinimized = !mDockWhenMinimized; }
void skipTaskbar(void);
private:
// Helpers
void initialize(void);
void handleTitleChange(void);
void handleIconChange(void);
const char *me(void) const;
// Member variables
long mDesktop; // desktop on which the window is being shown
TQLabel *mBalloon; // tooltip text simulator
TQString mCustomIcon; // CustomIcon of the docked application
11 years ago
Window mDockedWindow; // the window which is being docked
int mBalloonTimeout;
bool mDocked, mWithdrawn, mSkippingTaskbar;
bool mDockWhenMinimized;
TQString mTitle, mClass; // Title and hint of mDockedWindow
TQPixmap mAppIcon; // The current app icon (may not be same as pixmap())
11 years ago
XSizeHints mSizeHint; // SizeHint of mDockedWindow
TQTimer mRealityMonitor; // Helps us sync up with reality
TQStringList mProgName; // The program whose window we are docking
11 years ago
pid_t mPid; // The PID of program whose window we are docking
Window mSysTray; // System tray window id
};
#endif // _QTRAYLABEL_H