LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Window.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef WINDOW_H
23 #define WINDOW_H
24 
25 #include "Common.h"
26 #include <WindowTypes.h>
27 
28 #include <stdint.h>
29 #include <string>
30 #include <glib.h>
31 
32 #include <QGraphicsObject>
33 #include <QSize>
34 
35 
37 class WindowManagerBase;
38 struct WindowProperties;
39 
44 #define QM_CONNECT(source, sSignal, tSlot) \
45  do { \
46  if (!connect(source, sSignal, tSlot)) { \
47  qFatal("Failed to connect signal %s::%s to this::%s", \
48  #source, sSignal, tSlot); \
49  } \
50  } while (0)
51 
56 #define QM_CONNECT_EX(target, source, sSignal, tSlot) \
57  do { \
58  if (target == NULL) qFatal("Cannot connect to NULL object"); \
59  if (!(target)->connect(source, sSignal, tSlot)) { \
60  qFatal("Failed to connect signal %s::%s to %s::%s", \
61  #source, sSignal, #target, tSlot); \
62  } \
63  } while (0)
64 
65 class Window : public QGraphicsObject
66 {
67  Q_OBJECT
68  Q_PROPERTY(bool grabMouse READ mouseGrabbed WRITE setMouseGrabbed)
69 public:
70 
71  Window(WindowType::Type type, const uint32_t bufWidth, const uint32_t bufHeight, bool hasAlpha=false);
72  Window(WindowType::Type type, const QPixmap& pix);
73  virtual ~Window();
74 
75  // QGraphicsItem::type
76  virtual int type() const { return m_type; } // has-base-impl
77 
78  // QGraphicsItem::boundingRect
79  virtual QRectF boundingRect() const { return m_visibleBounds; } // has-base-impl
80 
81  virtual bool mouseGrabbed() const; // has-base-impl
82  virtual void setMouseGrabbed(bool grabbed); // has-base-impl
83 
84  // QGraphicsItem::paint
85  virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); // has-base-impl
86 
87  virtual bool isIpcWindow() const { return false; } // has-base-impl
88 
89  void setName(const std::string& name);
90  std::string name() const;
91  virtual void setAppId(const std::string& id);
92  std::string appId() const;
93  void setProcessId(const std::string& id);
94  std::string processId() const;
95  void setLaunchingAppId(const std::string& id);
96  std::string launchingAppId() const;
97  void setLaunchingProcessId(const std::string& id);
98  std::string launchingProcessId() const;
100 
101  void setRemoved() { m_removed = true; }
102  bool removed() const { return m_removed; }
103 
105  bool disableKeepAlive() const { return m_disableKeepAlive; }
106 
107  virtual void setWindowProperties (const WindowProperties& attr) { }
108 
109  virtual void setVisibleDimensions(uint32_t width, uint32_t height); // has-base-impl
110  virtual QSize getVisibleDimensions() const; // has-base-impl
111 
112  virtual void resize(int w, int h); //has-base-impl
113 
114  virtual const QPixmap* acquireScreenPixmap() { return &m_screenPixmap; }
115 
116  inline int initialWidth() const { return m_initialWidth; }
117  inline int initialHeight() const { return m_initialHeight; }
118 
119 protected:
120 
121  virtual void lock() {}
122  virtual void unlock() {}
123 
125  std::string m_name;
126  std::string m_appId;
127  std::string m_processId;
128  std::string m_launchingAppId;
129  std::string m_launchingProcId;
131  bool m_removed;
133  uint32_t m_bufWidth;
134  uint32_t m_bufHeight;
138  QPixmap m_screenPixmap;
139 
140  friend class HostWindow;
141 
142  Window(const Window&);
143  Window& operator=(const Window&);
144 };
145 
146 #endif /* WINDOW_H */