Qt 4.8
qwidget_wince.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifdef Q_WS_WINCE
43 
44 #include "qguifunctions_wince.h"
45 
47 
48 const QString qt_reg_winclass(QWidget *w); // defined in qapplication_win.cpp
49 extern "C" LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM);
50 
51 //#define TABLET_DEBUG
52 #define PACKETDATA (PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE \
53  | PK_ORIENTATION | PK_CURSOR | PK_Z)
54 #define PACKETMODE 0
55 
56 typedef HCTX (API *PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL);
57 typedef BOOL (API *PtrWTClose)(HCTX);
58 typedef UINT (API *PtrWTInfo)(UINT, UINT, LPVOID);
59 typedef BOOL (API *PtrWTEnable)(HCTX, BOOL);
60 typedef BOOL (API *PtrWTOverlap)(HCTX, BOOL);
61 typedef int (API *PtrWTPacketsGet)(HCTX, int, LPVOID);
62 typedef BOOL (API *PtrWTGet)(HCTX, LPLOGCONTEXT);
63 typedef int (API *PtrWTQueueSizeGet)(HCTX);
64 typedef BOOL (API *PtrWTQueueSizeSet)(HCTX, int);
65 
66 #ifndef QT_NO_TABLETEVENT
67 static void qt_tablet_init_wce();
68 static void qt_tablet_cleanup_wce();
69 
70 static void qt_tablet_init_wce() {
71  static bool firstTime = true;
72  if (!firstTime)
73  return;
74  firstTime = false;
75  qt_tablet_widget = new QWidget(0);
77  qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget"));
78  LOGCONTEXT lcMine;
80  struct tagAXIS tpOri[3];
82  // make sure we have WinTab
83  if (!ptrWTInfo(0, 0, NULL)) {
84 #ifdef TABLET_DEBUG
85  qWarning("QWidget: Wintab services not available");
86 #endif
87  return;
88  }
89 
90  // some tablets don't support tilt, check if it is possible,
91  qt_tablet_tilt_support = ptrWTInfo(WTI_DEVICES, DVC_ORIENTATION, &tpOri);
93  // check for azimuth and altitude
94  qt_tablet_tilt_support = tpOri[0].axResolution && tpOri[1].axResolution;
95  }
96  // build our context from the default context
97  ptrWTInfo(WTI_DEFSYSCTX, 0, &lcMine);
98  // Go for the raw coordinates, the tablet event will return good stuff
99  lcMine.lcOptions |= CXO_MESSAGES | CXO_CSRMESSAGES;
100  lcMine.lcPktData = PACKETDATA;
101  lcMine.lcPktMode = PACKETMODE;
102  lcMine.lcMoveMask = PACKETDATA;
103  lcMine.lcOutOrgX = 0;
104  lcMine.lcOutExtX = lcMine.lcInExtX;
105  lcMine.lcOutOrgY = 0;
106  lcMine.lcOutExtY = -lcMine.lcInExtY;
107  qt_tablet_context = ptrWTOpen(qt_tablet_widget->winId(), &lcMine, true);
108 #ifdef TABLET_DEBUG
109  qDebug("Tablet is %p", qt_tablet_context);
110 #endif
111  if (!qt_tablet_context) {
112 #ifdef TABLET_DEBUG
113  qWarning("QWidget: Failed to open the tablet");
114 #endif
115  return;
116  }
117  // Set the size of the Packet Queue to the correct size...
118  int currSize = ptrWTQueueSizeGet(qt_tablet_context);
120  // Ideally one might want to use a smaller
121  // multiple, but for now, since we managed to destroy
122  // the existing Q with the previous call, set it back
123  // to the other size, which should work. If not,
124  // there will be trouble.
125  if (!ptrWTQueueSizeSet(qt_tablet_context, currSize)) {
126  Q_ASSERT_X(0, "Qt::Internal", "There is no packet queue for"
127  " the tablet. The tablet will not work");
128  }
129  }
130  }
131 }
132 
133 static void qt_tablet_cleanup_wce() {
134  if (ptrWTClose)
136  delete qt_tablet_widget;
137  qt_tablet_widget = 0;
138 }
139 #endif // QT_NO_TABLETEVENT
140 
141 
142 // The internal qWinRequestConfig, defined in qapplication_win.cpp, stores move,
143 // resize and setGeometry requests for a widget that is already
144 // processing a config event. The purpose is to avoid recursion.
145 //
146 void qWinRequestConfig(WId, int, int, int, int, int);
147 
148 void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow) {
149  Q_Q(QWidget);
150  static int sw = -1, sh = -1;
151 
152  Qt::WindowType type = q->windowType();
153  Qt::WindowFlags flags = data.window_flags;
154 
155  bool topLevel = (flags & Qt::Window);
156  bool popup = (type == Qt::Popup);
157  bool dialog = (type == Qt::Dialog
158  || type == Qt::Sheet
159  || (flags & Qt::MSWindowsFixedSizeDialogHint));
160  bool desktop = (type == Qt::Desktop);
161  bool tool = (type == Qt::Tool || type == Qt::Drawer);
162 
163  HINSTANCE appinst = qWinAppInst();
164  HWND parentw, destroyw = 0;
165  WId id;
166 
167  QString windowClassName = qt_reg_winclass(q);
168 
169  if (!window) // always initialize
170  initializeWindow = true;
171 
172  if (popup)
173  flags |= Qt::WindowStaysOnTopHint; // a popup stays on top
174 
176  flags |= Qt::WindowSystemMenuHint;
177  flags |= Qt::WindowTitleHint;
178  flags &= ~Qt::FramelessWindowHint;
179  }
180 
181  if (sw < 0) { // get the (primary) screen size
182  sw = GetSystemMetrics(SM_CXSCREEN);
183  sh = GetSystemMetrics(SM_CYSCREEN);
184  }
185 
186  if (desktop) { // desktop widget
187  popup = false; // force this flags off
188  data.crect.setRect(0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
189  }
190 
191  parentw = q->parentWidget() ? q->parentWidget()->effectiveWinId() : 0;
192 
193  QString title;
194  int style = WS_CHILD;
195  int exsty = WS_EX_NOPARENTNOTIFY;
196 
197  if (topLevel) {
198  if (!(flags & Qt::FramelessWindowHint) && !tool && !q->testAttribute(Qt::WA_DontShowOnScreen))
199  style = (WS_OVERLAPPED) | WS_SYSMENU;
200  else
201  style = WS_POPUP;
202  if ((type == Qt::ToolTip) || (type == Qt::SplashScreen)) {
203  style = WS_POPUP;
204  exsty |= WS_EX_NOANIMATION;
205  } else {
206  if (flags & Qt::WindowTitleHint)
207  style |= WS_CAPTION;
208  if (flags & Qt::WindowSystemMenuHint)
209  style |= WS_SYSMENU;
211  exsty |= WS_EX_CONTEXTHELP;
212 #ifndef Q_WS_WINCE_WM
213  if (flags & Qt::WindowMinimizeButtonHint)
214  style |= WS_MINIMIZEBOX;
215  if (shouldShowMaximizeButton())
216  style |= WS_MAXIMIZEBOX;
217 #endif
218  if (tool)
219  exsty |= WS_EX_TOOLWINDOW;
220  }
221  }
222  if (dialog) {
223  style = WS_BORDER | WS_CAPTION;
224  if (flags & Qt::WindowOkButtonHint)
225  exsty |= WS_EX_CAPTIONOKBTN;
226  if (flags & Qt::WindowCancelButtonHint || flags & Qt::WA_DeleteOnClose)
227  style |= WS_SYSMENU;
229  exsty |= WS_EX_CONTEXTHELP;
230  }
231  if (popup) {
232  style = WS_POPUP;
233  exsty |= WS_EX_NOANIMATION;
234  }
235 
236  if (flags & Qt::WindowTitleHint) {
237  title = q->isWindow() ? qAppName() : q->objectName();
238  }
239 
240  // The Qt::WA_WState_Created flag is checked by translateConfigEvent() in
241  // qapplication_win.cpp. We switch it off temporarily to avoid move
242  // and resize events during creationt
243  q->setAttribute(Qt::WA_WState_Created, false);
244 
245  if (window) { // override the old window
246  if (destroyOldWindow)
247  destroyw = data.winid;
248  id = window;
249  setWinId(window);
250  LONG res = SetWindowLong(window, GWL_STYLE, style);
251  if (!res)
252  qErrnoWarning("QWidget::create: Failed to set window style");
253 
254  res = SetWindowLong( window, GWL_WNDPROC, (LONG)QtWndProc );
255 
256  if (!res)
257  qErrnoWarning("QWidget::create: Failed to set window procedure");
258  } else if (desktop) { // desktop widget
259  id = GetDesktopWindow();
260  if (!id) { //Create a dummy desktop
261  RECT r;
262  SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
263  id = CreateWindow(reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
264  reinterpret_cast<const wchar_t *>(title.utf16()), style,
265  r.left, r.top, r.right - r.left, r.bottom - r.top,
266  0, 0, appinst, 0);
267  }
268  setWinId(id);
269  } else if (topLevel) { // create top-level widget
270  const bool wasMoved = q->testAttribute(Qt::WA_Moved);
271 
272  int x, y;
273  if (qt_wince_is_mobile()) {
274  x = wasMoved ? data.crect.left() : CW_USEDEFAULT;
275  y = wasMoved ? data.crect.top() : CW_USEDEFAULT;
276  } else {
277  x = wasMoved ? data.crect.left() : 100;
278  y = wasMoved ? data.crect.top() : 100;
279  }
280 
281  int w = CW_USEDEFAULT;
282  int h = CW_USEDEFAULT;
283 
284  // Adjust for framestrut when needed
285  RECT rect = {0,0,0,0};
286  if (AdjustWindowRectEx(&rect, style, FALSE, exsty)) {
287  QTLWExtra *td = maybeTopData();
288  if (wasMoved && (td && !td->posFromMove)) {
289  x = data.crect.x() + rect.left;
290  y = data.crect.y() + rect.top;
291  }
292 
293  if (q->testAttribute(Qt::WA_Resized)) {
294  w = data.crect.width() + (rect.right - rect.left);
295  h = data.crect.height() + (rect.bottom - rect.top);
296  }
297  }
298 
299  id = CreateWindowEx(exsty, reinterpret_cast<const wchar_t *>(windowClassName.utf16()),
300  reinterpret_cast<const wchar_t *>(title.utf16()), style,
301  x, y, w, h,
302  0, 0, appinst, 0);
303 
304  if (!id)
305  qErrnoWarning("QWidget::create: Failed to create window");
306  setWinId(id);
307  if ((flags & Qt::WindowStaysOnTopHint) || (type == Qt::ToolTip))
308  SetWindowPos(id, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
309  } else if (q->testAttribute(Qt::WA_NativeWindow) || paintOnScreen()) { // create child widget
310  id = CreateWindowEx(exsty, (wchar_t*)windowClassName.utf16(), (wchar_t*)title.utf16(), style,
312  parentw, NULL, appinst, NULL);
313  if (!id)
314  qErrnoWarning("QWidget::create: Failed to create window");
315  SetWindowPos(id, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
316  setWinId(id);
317  }
318 
319  if (desktop) {
320  q->setAttribute(Qt::WA_WState_Visible);
321  } else if (topLevel && !q->testAttribute(Qt::WA_DontShowOnScreen)) {
322  RECT cr;
323  GetClientRect(id, &cr);
324  // one cannot trust cr.left and cr.top, use a correction POINT instead
325  POINT pt;
326  pt.x = 0;
327  pt.y = 0;
328  if (!q->testAttribute(Qt::WA_DontShowOnScreen) || q->testAttribute(Qt::WA_Moved))
329  ClientToScreen(id, &pt);
330  data.crect = QRect(QPoint(pt.x, pt.y),
331  QPoint(pt.x + cr.right - 1, pt.y + cr.bottom - 1));
332 
333  if (data.fstrut_dirty) {
334  // be nice to activeqt
336  }
337  }
338 
339  q->setAttribute(Qt::WA_WState_Created); // accept move/resize events
340  hd = 0; // no display context
341 
342  if (window) { // got window from outside
343  if (IsWindowVisible(window))
344  q->setAttribute(Qt::WA_WState_Visible);
345  else
346  q->setAttribute(Qt::WA_WState_Visible, false);
347  }
348 
349  if (extra && !extra->mask.isEmpty())
351 
352 #if defined(QT_NON_COMMERCIAL)
353  QT_NC_WIDGET_CREATE
354 #endif
355 
356  if (q->hasFocus() && q->testAttribute(Qt::WA_InputMethodEnabled))
357  q->inputContext()->setFocusWidget(q);
358 
359  if (destroyw) {
360  DestroyWindow(destroyw);
361  }
362 
363 #ifndef QT_NO_TABLETEVENT
366 #endif // QT_NO_TABLETEVENT
367 
368  if (q->testAttribute(Qt::WA_DropSiteRegistered))
369  registerDropSite(true);
370 
371  if (maybeTopData() && maybeTopData()->opacity != 255)
372  q->setWindowOpacity(maybeTopData()->opacity/255.);
373 
374  if (!topLevel && q->testAttribute(Qt::WA_NativeWindow) && q->testAttribute(Qt::WA_Mapped)) {
375  Q_ASSERT(q->internalWinId());
376  ShowWindow(q->internalWinId(), SW_SHOW);
377  }
378 }
379 
380 /*
381  \internal
382  Platform-specific part of QWidget::show().
383 */
385  Q_Q(QWidget);
386 #if defined(QT_NON_COMMERCIAL)
387  QT_NC_SHOW_WINDOW
388 #endif
389  if (q->testAttribute(Qt::WA_OutsideWSRange))
390  return;
391 
392  q->setAttribute(Qt::WA_Mapped);
393 
394  Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
395 
396  if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
397  invalidateBuffer(q->rect());
398  return;
399  }
400 
401 
402  int sm = SW_SHOW;
403  bool fakedMaximize = false;
404  if (q->isWindow()) {
405 #ifndef Q_WS_WINCE_WM
406  if (q->isMinimized()) {
407  sm = SW_SHOWMINIMIZED;
408  } else if (q->isMaximized()) {
409  sm = SW_SHOWMAXIMIZED;
410  // Windows will not behave correctly when we try to maximize a window which does not
411  // have minimize nor maximize buttons in the window frame. Windows would then ignore
412  // non-available geometry, and rather maximize the widget to the full screen, minus the
413  // window frame (caption). So, we do a trick here, by adding a maximize button before
414  // maximizing the widget, and then remove the maximize button afterwards.
415  Qt::WindowFlags &flags = data.window_flags;
416  if (flags & Qt::WindowTitleHint &&
418  fakedMaximize = TRUE;
419  int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
420  SetWindowLong(q->internalWinId(), GWL_STYLE, style | WS_MAXIMIZEBOX);
421  }
422  } else
423 #else
424  // Imitate minimizing on Windows mobile by hiding the widget.
425  if (q->isMinimized())
426  sm = SW_HIDE;
427 #endif
428  if (q->isHidden()) {
429  sm = SW_HIDE;
430  }
431  }
432  if (q->testAttribute(Qt::WA_ShowWithoutActivating)
433  || (q->windowType() == Qt::Popup)
434  || (q->windowType() == Qt::ToolTip)
435  || (q->windowType() == Qt::Tool)) {
436  sm = SW_SHOWNOACTIVATE;
437  }
438 
439  ShowWindow(q->internalWinId(), sm);
440 
441  if (q->isMaximized() && q->isWindow())
443 
444 #ifndef Q_WS_WINCE_WM
445  if (!qt_wince_is_mobile() && q->isFullScreen()) {
446  HWND handle = FindWindow(L"HHTaskBar", L"");
447  if (handle) {
448  ShowWindow(handle, SW_HIDE);
449  EnableWindow(handle, false);
450  }
451  }
452 
453  if (fakedMaximize) {
454  int style = GetWindowLong(q->internalWinId(), GWL_STYLE);
455  SetWindowLong(q->internalWinId(), GWL_STYLE, style & ~WS_MAXIMIZEBOX);
456  SetWindowPos(q->internalWinId(), 0, 0, 0, 0, 0,
457  SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER
458  | SWP_FRAMECHANGED);
459  }
460 #else
461  Q_UNUSED(fakedMaximize);
462 #endif
463 
464  if (q->isWindow() && sm == SW_SHOW)
465  SetForegroundWindow(q->internalWinId());
466 
467  invalidateBuffer(q->rect());
468 }
469 
470 void QWidget::setWindowState(Qt::WindowStates newstate)
471 {
472  Q_D(QWidget);
473  Qt::WindowStates oldstate = windowState();
474  if (oldstate == newstate)
475  return;
476 
477  int max = SW_SHOWNORMAL;
478  int normal = SW_SHOWNOACTIVATE;
479 
480  if ((oldstate & Qt::WindowMinimized) && !(newstate & Qt::WindowMinimized))
481  newstate |= Qt::WindowActive;
482  if (newstate & Qt::WindowActive)
483  normal = SW_SHOWNORMAL;
484  if (isWindow()) {
485  createWinId();
486  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
487  // Ensure the initial size is valid, since we store it as normalGeometry below.
488  if ((!testAttribute(Qt::WA_Resized) && !isVisible()))
489  adjustSize();
490  if (!d->topData()->normalGeometry.isValid()) {
491  if (newstate & Qt::WindowMaximized && !(oldstate & Qt::WindowFullScreen))
492  d->topData()->normalGeometry = geometry();
493  if (newstate & Qt::WindowMinimized && !(oldstate & Qt::WindowFullScreen))
494  d->topData()->normalGeometry = geometry();
495  }
496  if ((oldstate & Qt::WindowMaximized) != (newstate & Qt::WindowMaximized)) {
497  if (!(newstate & Qt::WindowMaximized)) {
498  int style = GetWindowLong(internalWinId(), GWL_STYLE) | WS_BORDER | WS_POPUP | WS_CAPTION;
499  SetWindowLong(internalWinId(), GWL_STYLE, style);
500  SetWindowLong(internalWinId(), GWL_EXSTYLE, GetWindowLong (internalWinId(), GWL_EXSTYLE) & ~ WS_EX_NODRAG);
501  qt_wince_unmaximize(this);
502  }
503  if (isVisible() && newstate & Qt::WindowMaximized)
504  qt_wince_maximize(this);
505  if (isVisible() && !(newstate & Qt::WindowMinimized)) {
506  ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal);
507  if (!(newstate & Qt::WindowFullScreen)) {
508  QRect r = d->topData()->normalGeometry;
509  if (!(newstate & Qt::WindowMaximized) && r.width() >= 0) {
510  if (pos() != r.topLeft() || size() !=r.size()) {
511  d->topData()->normalGeometry = QRect(0,0,-1,-1);
512  setGeometry(r);
513  }
514  }
515  } else {
516  d->updateFrameStrut();
517  }
518  }
519  }
520  if ((oldstate & Qt::WindowFullScreen) != (newstate & Qt::WindowFullScreen)) {
521  if (newstate & Qt::WindowFullScreen) {
522  if (d->topData()->normalGeometry.width() < 0 && !(oldstate & Qt::WindowMaximized))
523  d->topData()->normalGeometry = geometry();
524  d->topData()->savedFlags = (Qt::WindowFlags)GetWindowLong(internalWinId(), GWL_STYLE);
525  UINT style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
526  if (isVisible())
527  style |= WS_VISIBLE;
528  SetWindowLong(internalWinId(), GWL_STYLE, style);
529  QRect r = qApp->desktop()->screenGeometry(this);
530  UINT swpf = SWP_FRAMECHANGED;
531  if (newstate & Qt::WindowActive)
532  swpf |= SWP_NOACTIVATE;
533  qt_wince_full_screen(internalWinId(), true, swpf);
534  d->updateFrameStrut();
535  } else {
536  UINT style = d->topData()->savedFlags;
537  if (isVisible())
538  style |= WS_VISIBLE;
539  SetWindowLong(internalWinId(), GWL_STYLE, style);
540  UINT swpf = SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;
541  if (newstate & Qt::WindowActive)
542  swpf |= SWP_NOACTIVATE;
543  qt_wince_full_screen(internalWinId(), false, swpf);
544  d->updateFrameStrut();
545 
546  // preserve maximized state
547  if (isVisible()) {
548  ShowWindow(internalWinId(), (newstate & Qt::WindowMaximized) ? max : normal);
549  if (newstate & Qt::WindowMaximized)
550  qt_wince_maximize(this);
551  }
552  if (!(newstate & Qt::WindowMaximized)) {
553  QRect r = d->topData()->normalGeometry;
554  d->topData()->normalGeometry = QRect(0,0,-1,-1);
555  if (r.isValid())
556  setGeometry(r);
557  }
558  }
559  }
560  if ((oldstate & Qt::WindowMinimized) != (newstate & Qt::WindowMinimized)) {
561  if (newstate & Qt::WindowMinimized)
562  qt_wince_minimize(internalWinId());
563  else if (newstate & Qt::WindowMaximized) {
564  ShowWindow(internalWinId(), max);
565  qt_wince_maximize(this);
566  } else {
567  ShowWindow(internalWinId(), normal);
568  }
569  }
570  }
571  data->window_state = newstate;
572  QWindowStateChangeEvent e(oldstate);
573  QApplication::sendEvent(this, &e);
574 }
575 
577 {
578  Q_Q(QWidget);
579  if (!qt_wince_is_mobile() && q->isFullScreen()) {
580  HWND handle = FindWindow(L"HHTaskBar", L"");
581  if (handle) {
582  ShowWindow(handle, SW_SHOWNORMAL);
583  EnableWindow(handle, true);
584  }
585  }
586 }
587 
589  Q_UNUSED(level);
590  return;
591 }
592 
593 // The procedure does nothing, but is required for mousegrabbing to work
594 LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam) {
595  Q_UNUSED(nCode);
596  Q_UNUSED(wParam);
597  Q_UNUSED(lParam);
598  return 0;
599 }
600 
601 void QWidget::grabMouse() {
602  if (!qt_nograb()) {
603  if (mouseGrb)
605  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
606  SetCapture(internalWinId());
607  mouseGrb = this;
608  }
609 }
610 
611 #ifndef QT_NO_CURSOR
612 void QWidget::grabMouse(const QCursor &cursor) {
613  if (!qt_nograb()) {
614  if (mouseGrb)
616  Q_ASSERT(testAttribute(Qt::WA_WState_Created));
617  SetCapture(internalWinId());
618  mouseGrbCur = new QCursor(cursor);
619  SetCursor(mouseGrbCur->handle());
620  mouseGrb = this;
621  }
622 }
623 #endif
624 
625 void QWidget::releaseMouse() {
626  if (!qt_nograb() && mouseGrb == this) {
627  ReleaseCapture();
628  if (journalRec) {
629  journalRec = 0;
630  }
631  if (mouseGrbCur) {
632  delete mouseGrbCur;
633  mouseGrbCur = 0;
634  }
635  mouseGrb = 0;
636  }
637 }
638 
640 {
641  Qt::WindowFlags flags = windowFlags() & 0xff;
642  int threshold = qApp->autoMaximizeThreshold();
643  if ((threshold < 0) || (windowState() & Qt::WindowFullScreen) || (windowState() & Qt::WindowMaximized)) {
644  setVisible(true);
645  return;
646  }
647  int height = sizeHint().height();
648  int screenHeight = (qreal(threshold) / 100.0f * qApp->desktop()->screenGeometry(this).height());
649  bool maximize = height > screenHeight;
650  if (!maximize) {
651  // If we do not maximize yet we check the widget and its child widgets whether they are
652  //vertically expanding. If one of the widgets is expanding we maximize.
653  QList<QWidget *> list = findChildren<QWidget *>();
654  bool expandingChild = sizePolicy().verticalPolicy () == QSizePolicy::Expanding;
655  for (int i = 0; (i < list.size()) && !expandingChild; ++i) {
656  expandingChild = list.at(i)->sizePolicy().verticalPolicy () == QSizePolicy::Expanding;
657  }
658  maximize = expandingChild;
659  }
660  if ((minimumSizeHint().height() > qApp->desktop()->screenGeometry(this).height()) || (minimumSizeHint().width() > qApp->desktop()->screenGeometry(this).width()))
661  maximize = false;
662 
663  if ((flags == Qt::Window || flags == Qt::Dialog) && maximize) {
664  setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen))
666  setVisible(true);
667  }
668  else {
669  setVisible(true);
670  }
671 }
672 
674 
675 #endif // Q_WS_WINCE
HCURSOR_or_HANDLE handle() const
Returns a platform-specific cursor handle.
Definition: qcursor_mac.mm:301
double d
Definition: qnumeric_p.h:62
void qt_wince_minimize(HWND hwnd)
static QWidget * qt_tablet_widget
unsigned long WId
Definition: qwindowdefs.h:119
void grabMouse()
Grabs the mouse input.
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193
The QCursor class provides a mouse cursor with an arbitrary shape.
Definition: qcursor.h:89
HCTX qt_tablet_context
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define WS_EX_TOOLWINDOW
void setWindowState(Qt::WindowStates state)
Sets the window state to windowState.
static void qt_tablet_cleanup_wce()
QRect crect
Definition: qwidget.h:131
#define SPI_GETWORKAREA
Qt::HANDLE hd
Definition: qwidget_p.h:754
HCTX(API * PtrWTOpen)(HWND, LPLOGCONTEXT, BOOL)
BOOL(API * PtrWTOverlap)(HCTX, BOOL)
bool paintOnScreen() const
Definition: qwidget.cpp:2255
int(API * PtrWTQueueSizeGet)(HCTX)
uint window_state
Definition: qwidget.h:120
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define PACKETDATA
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
void qt_wince_maximize(QWidget *widget)
void show_sys()
Platform-specific part of QWidget::show().
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
void qt_wince_full_screen(HWND hwnd, bool fullScreen, UINT swpf)
WindowType
Definition: qnamespace.h:270
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QTLWExtra * maybeTopData() const
Definition: qwidget_p.h:1010
static PtrWTQueueSizeSet ptrWTQueueSizeSet
#define Q_D(Class)
Definition: qglobal.h:2482
QString qAppName()
void registerDropSite(bool)
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
QWidgetData data
Definition: qwidget_p.h:755
Q_CORE_EXPORT void qDebug(const char *,...)
NSWindow * window
void create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
#define QT_WIN_CALLBACK
Definition: qglobal.h:1178
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
#define HWND_TOPMOST
static PtrWTClose ptrWTClose
#define WS_EX_NODRAG
void releaseMouse()
Releases the mouse grab.
BOOL(API * PtrWTEnable)(HCTX, BOOL)
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
Definition: qregion.cpp:4098
#define qApp
void qt_wince_unmaximize(QWidget *widget)
Qt::WindowFlags window_flags
Definition: qwidget.h:119
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void updateFrameStrut()
Computes the frame rectangle when needed.
Q_CORE_EXPORT void qWarning(const char *,...)
#define FALSE
Synonym for false.
Definition: qglobal.h:1019
static PtrWTOpen ptrWTOpen
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
#define WS_EX_NOPARENTNOTIFY
void show()
Shows the widget and its child widgets.
BOOL(API * PtrWTGet)(HCTX, LPLOGCONTEXT)
BOOL(API * PtrWTClose)(HCTX)
BOOL(API * PtrWTQueueSizeSet)(HCTX, int)
void deleteSysExtra()
int(API * PtrWTPacketsGet)(HCTX, int, LPVOID)
void invalidateBuffer(const QRegion &)
Invalidates the rgn (in widget&#39;s coordinates) of the backing store, i.e.
#define TRUE
Synonym for true.
Definition: qglobal.h:1018
#define PACKETMODE
bool qt_wince_is_mobile()
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
bool qt_nograb()
QRegion mask
Definition: qwidget_p.h:260
The QWindowStateChangeEvent class provides the window state before a window state change...
Definition: qevent.h:705
static QWidget * mouseGrb
LRESULT QT_WIN_CALLBACK qJournalRecordProc(int nCode, WPARAM wParam, LPARAM lParam)
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
static HHOOK journalRec
void qWinRequestConfig(WId, int, int, int, int, int)
void setMask_sys(const QRegion &)
void createWinId(WId id=0)
Definition: qwidget.cpp:2574
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
QSizePolicy sizePolicy
the default layout behavior of the widget
Definition: qwidget.h:171
static PtrWTInfo ptrWTInfo
void setRect(int x, int y, int w, int h)
Sets the coordinates of the rectangle&#39;s top-left corner to ({x}, {y}), and its size to the given widt...
Definition: qrect.h:400
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
#define SW_SHOWMINIMIZED
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
uint opacity
Definition: qwidget_p.h:185
static QCursor * mouseGrbCur
Policy verticalPolicy() const
Definition: qsizepolicy.h:119
void setWindowOpacity_sys(qreal opacity)
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
QWExtra * extra
Definition: qwidget_p.h:700
static void qt_tablet_init_wce()
static QWidgetMapper * mapper
Definition: qwidget_p.h:714
Q_CORE_EXPORT HINSTANCE qWinAppInst()
const QString qt_reg_winclass(QWidget *w)
void createWinId()
Definition: qwidget.cpp:2626
uint posFromMove
Definition: qwidget_p.h:186
static PtrWTQueueSizeGet ptrWTQueueSizeGet
void setWinId(WId)
Definition: qwidget.cpp:1726
API
Definition: qegl_p.h:190
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
uint fstrut_dirty
Definition: qwidget.h:126
bool qt_tablet_tilt_support
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
Definition: qrect.h:237
UINT(API * PtrWTInfo)(UINT, UINT, LPVOID)
#define WS_EX_CAPTIONOKBTN
void qAddPostRoutine(QtCleanUpFunction ptr)
Adds a global routine that will be called from the QApplication destructor.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
LRESULT QT_WIN_CALLBACK QtWndProc(HWND, UINT, WPARAM, LPARAM)
WId winid
Definition: qwidget.h:117
static Qt::KeyboardModifiers oldstate
Definition: qdnd_qws.cpp:87
const ushort * utf16() const
Returns the QString as a &#39;\0\&#39;-terminated array of unsigned shorts.
Definition: qstring.cpp:5290
void qErrnoWarning(const char *msg,...)
Definition: qglobal.cpp:2954
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288