summaryrefslogtreecommitdiffstats
path: root/src/komposetask.h
blob: 710ca83fa865427aacd91faeb75b2b2e41905ca1 (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 <qobject.h>
#include <qrect.h>
#include <kwin.h>

class KWinModule;
class KomposeTaskVisualizer;

/**
@author Hans Oischinger
*/
class KomposeTask : public QObject
{
  Q_OBJECT
public:
  KomposeTask(WId win, KWinModule *kwinmod, QObject *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; }
  QString name() const { return windowInfo.name(); }
  QString visibleName() const { return windowInfo.visibleName(); }
  QString visibleNameWithState() const { return windowInfo.visibleNameWithState(); }
  QRect getGeometry() const { return windowInfo.geometry(); }
  QRect getFrameGeometry() const { return windowInfo.frameGeometry(); }

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

  KomposeTaskVisualizer* getVisualizer() { return visualizer; }

protected:
  void paintEvent ( QPaintEvent * );
  void mouseReleaseEvent ( QMouseEvent * 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