summaryrefslogtreecommitdiffstats
path: root/src/komposetask.h
blob: a85d1a5ce21df7c83b2f63e34f4b020978ea9e1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/***************************************************************************
 *   Copyright (C) 2004 by Hans Oischinger                                 *
 *   hans.oischinger@kde-mail.net                                                 *
 *                                                                         *
 *   This program 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 program 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 program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef KOMPOSETASK_H
#define KOMPOSETASK_H

#include <tqobject.h>
#include <tqrect.h>
#include <kwin.h>

class KWinModule;
class KomposeTaskVisualizer;

/**
@author Hans Oischinger
*/
class KomposeTask : public TQObject
{
  Q_OBJECT
public:
  KomposeTask(WId win, KWinModule *kwinmod, TQObject *parent = 0, const char *name = 0);

  ~KomposeTask();

public:
  // state
  bool isMaximized() const;
  bool isIconified() const;
  bool isShaded() const;
  bool isOnTop() const;
  int onDesktop() const;
  bool isOnCurrentDesktop() const;
  bool isOnAllDesktops() const;
  bool isAlwaysOnTop() const;
  bool isActive() const;
  bool isModified() const;
  bool isValid() const { return windowInfo.valid(); }

  WId window() const { return windowID; }
  WId wmFrame() const { return wmframeID; }
  TQString name() const { return windowInfo.name(); }
  TQString visibleName() const { return windowInfo.visibleName(); }
  TQString visibleNameWithState() const { return windowInfo.visibleNameWithState(); }
  TQRect getGeometry() const { return windowInfo.geometry(); }
  TQRect getFrameGeometry() const { return windowInfo.frameGeometry(); }

  TQPixmap getIcon( int size );
  double getAspectRatio();
  int getHeightForWidth( int w ) const;
  int getWidthForHeight( int h ) const;

  KomposeTaskVisualizer* getVisualizer() { return visualizer; }

protected:
  void paintEvent ( TQPaintEvent * );
  void mouseReleaseEvent ( TQMouseEvent * e );
  void findWmFrame();

signals:
  void stateChanged();
  void x11ConfigureNotify();
  void x11DamageNotify();
  void closed();

public slots:
  void maximize();
  void restore();
  void iconify();
  void close();
  void raise();
  void lower();
  void activate();
  //   void activateOrRaise();
  void minimizeOrRestore();

  void toDesktop(int desk);
  void toCurrentDesktop();
  void setAlwaysOnTop(bool stay);
  void toggleAlwaysOnTop();
  void setShaded(bool shade);
  void toggleShaded();

  void refresh();
  void slotX11ConfigureNotify();
  void slotX11DamageNotify();
  void slotActivated();
  void slotUpdateScreenshot();

protected slots:
  void unBlockDamageEvents() { blockDamageEvents = false; }

private:
  KWinModule* kwinmodule;
  WId windowID;
  WId wmframeID;
  KWin::WindowInfo windowInfo;

  bool blockDamageEvents;
  KomposeTaskVisualizer* visualizer;
};

#endif