LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WindowServerLuna.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2008-2013 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 WINDOWSERVERLUNA_H
23 #define WINDOWSERVERLUNA_H
24 
25 #include "Common.h"
26 
27 #include "WindowServer.h"
28 #include "HostWindow.h"
29 
30 #include <QPropertyAnimation>
31 #include <QParallelAnimationGroup>
32 #include <QSequentialAnimationGroup>
33 #include <QGraphicsItem>
34 #include <QGraphicsObject>
35 #include <QTimer>
36 #include <QQueue>
37 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
38 #include <QWeakPointer>
39 #else
40 #include <QPointer>
41 #endif
42 
43 #include "QmlAlertWindow.h"
44 #include "VariantAnimation.h"
45 
46 class WindowManagerBase;
49 
50 class QDeclarativeEngine;
51 
53 {
54  Q_OBJECT
55 
56 public:
57 
59  virtual ~WindowServerLuna();
60 
61  virtual void prepareAddWindow(Window* win);
62  virtual void addWindow(Window* win);
63  virtual void addWindowTimedOut(Window* win);
64  virtual void removeWindow(Window* win);
65  virtual void focusWindow(Window* win);
66  virtual void unfocusWindow(Window* win);
67  virtual void windowUpdated(Window* win);
68  virtual void startDrag(int x, int y, void* imgRef, const std::string& lpid);
69  virtual void endDrag(int x, int y, const std::string& lpid, bool handled);
70 
71  virtual void applyLaunchFeedback(int centerX, int centerY);
72  virtual void appLaunchPreventedUnderLowMemory();
73 
74  WindowManagerBase* overlayWindowManager() const { return m_overlayMgr; }
75  WindowManagerBase* cardWindowManager() const { return m_cardMgr; }
76  WindowManagerBase* dashboardWindowManager() const { return m_dashboardMgr; }
77  WindowManagerBase* menuWindowManager() const { return m_menuMgr; }
78  WindowManagerBase* topLevelWindowManager() const { return m_topLevelMgr; }
79  WindowManagerBase* emergencyModeWindowManager() const { return m_emergencyModeMgr; }
81  WindowManagerBase* dockModeMenuManager() const { return m_dockModeMenuMgr; }
82  WindowManagerBase* dockModeManager() const { return m_dockModeMgr; }
83 
85 
86  virtual bool okToResizeUi(bool ignorePendingRequests=false);
87  void resizeWindowManagers(int width, int height);
88  virtual QDeclarativeEngine* declarativeEngine() { return m_qmlEngine; }
89 
90  virtual QRectF mapRectToRoot(const QGraphicsItem* item, const QRectF& rect) const;
91 
92 Q_SIGNALS:
93 
94  void signalWallpaperImageChanged(QPixmap* wallpaper, bool fullScreen, int rotationAngle);
97 
98 private Q_SLOTS:
99  void slotWallPaperChanged(const char* filePath);
100  void slotDisplayStateChange(int state);
101  void slotScreenLockStatusChanged(bool locked);
102  void slotDockAnimationFinished();
103  void slotDockModeEnable(bool enabled);
104  void slotPuckConnected(bool connected);
105  void slotFullEraseDevice();
106  void slotShowFullEraseWindow();
107  void slotMemoryStateChanged(bool critical);
108  void slotAppLaunchPreventedUnderLowMemory();
109  void slotBrickModeFailed();
110  void slotFirstCardRun();
111 
112 private:
113 
114  WindowManagerBase* windowManagerForWindowType(int type) const;
115 
116  bool sysmgrEventFilters(QEvent* event);
117 
118  void initDockModeAnimations();
119  void setupDockModeAnimations();
120  void cleanupDockModeAnimations();
121  void dockModeUiTransition(bool enter);
122  void animateDockMode(bool in);
123  void reorderWindowManagersForDockMode(bool enabled);
124 
125  bool triggerFullEraseCountdown();
126  void cancelFullEraseCountdown();
127  static bool cbFullEraseCallback(LSHandle*, LSMessage*, void*);
128 
129  bool processSystemShortcut( QEvent* event );
130 
131  QPixmap* takeScreenShot();
132 
133  void generateWallpaperImages();
134  void updateWallpaperForRotation(OrientationEvent::Orientation newOrient);
135  void drawBackground ( QPainter * painter, const QRectF & rect );
136 
137  void createMemoryAlertWindow();
138  void createMsmEntryFailedAlertWindow();
139  void createDismissCardWindow();
140 
141  WindowManagerBase* m_overlayMgr;
142  WindowManagerBase* m_cardMgr;
143  WindowManagerBase* m_dashboardMgr;
144  WindowManagerBase* m_menuMgr;
145  WindowManagerBase* m_topLevelMgr;
146  WindowManagerBase* m_emergencyModeMgr;
147  WindowManagerBase* m_dockModeMenuMgr;
148  WindowManagerBase* m_dockModeMgr;
149 
150  QDeclarativeEngine* m_qmlEngine;
151 
152  QString m_wallpaperFileName;
153  QPixmap m_normalWallpaperImage, m_rotatedWallpaperImage;
154  QPixmap* m_currWallpaperImg;
155  bool m_drawWallpaper;
156  bool m_wallpaperFullScreen;
157 
158  QBrush m_oldBrush;
159  bool m_restoreBrush;
160  QPixmap *m_screenShot, *m_dockImage;
161  QGraphicsPixmapObject *m_screenShotObject, *m_dockImageObject;
162  QPropertyAnimation m_screenFade, m_dockFade;
163  QPropertyAnimation m_screenScale, m_dockScale;
164  QParallelAnimationGroup m_screenGroup, m_dockGroup;
165  QSequentialAnimationGroup m_dockSequence, m_dockModeAnimation;
166 
167  struct PowerVolumeKeyComboState {
168  bool powerKeyPress;
169  bool volDownKeyPress;
170  bool volUpKeyPress;
171 
172  PowerVolumeKeyComboState()
173  : powerKeyPress(false)
174  , volDownKeyPress(false)
175  , volUpKeyPress(false) {
176  }
177 
178  bool fullEraseComboDown() const {
179  return powerKeyPress && volUpKeyPress;
180  }
181 
182  bool msmEntryComboDown() const {
183  return powerKeyPress && volDownKeyPress;
184  }
185 
186  bool comboDown() const {
187  return fullEraseComboDown() || msmEntryComboDown();
188  }
189 
190  void reset() {
191  powerKeyPress = volDownKeyPress = volUpKeyPress = false;
192  }
193  };
194 
195  PowerVolumeKeyComboState m_powerVolumeKeyComboState;
196  FullEraseConfirmationWindow* m_fullEraseConfirmationWindow;
197  bool m_fullErasePending;
198 
199  bool m_dashboardOpenInDockMode;
200  bool m_inDockModeTransition;
201  bool m_dockModeTransitionDirection;
202 
203 #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
204  QWeakPointer<QmlAlertWindow> m_memoryAlert;
205  QWeakPointer<QmlAlertWindow> m_msmEntryFailedAlert;
206  QWeakPointer<QmlAlertWindow> m_dismissCardDialog;
207 #else
208  QPointer<QmlAlertWindow> m_memoryAlert;
209  QPointer<QmlAlertWindow> m_msmEntryFailedAlert;
210  QPointer<QmlAlertWindow> m_dismissCardDialog;
211 #endif
212 
213 };
214 
215 #endif /* WINDOWSERVERLUNA_H */