source: trunk/src/gui/kernel/qdesktopwidget_pm.cpp

Last change on this file was 659, checked in by Dmitry A. Kuminov, 15 years ago

global: Updated year to 2010 in OS/2-specific headers.

File size: 5.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** Copyright (C) 2010 netlabs.org. OS/2 parts.
8**
9** This file is part of the QtGui module of the Qt Toolkit.
10**
11** $QT_BEGIN_LICENSE:LGPL$
12** Commercial Usage
13** Licensees holding valid Qt Commercial licenses may use this file in
14** accordance with the Qt Commercial License Agreement provided with the
15** Software or, alternatively, in accordance with the terms contained in
16** a written agreement between you and Nokia.
17**
18** GNU Lesser General Public License Usage
19** Alternatively, this file may be used under the terms of the GNU Lesser
20** General Public License version 2.1 as published by the Free Software
21** Foundation and appearing in the file LICENSE.LGPL included in the
22** packaging of this file. Please review the following information to
23** ensure the GNU Lesser General Public License version 2.1 requirements
24** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** In addition, as a special exception, Nokia gives you certain additional
27** rights. These rights are described in the Nokia Qt LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** GNU General Public License Usage
31** Alternatively, this file may be used under the terms of the GNU
32** General Public License version 3.0 as published by the Free Software
33** Foundation and appearing in the file LICENSE.GPL included in the
34** packaging of this file. Please review the following information to
35** ensure the GNU General Public License version 3.0 requirements will be
36** met: http://www.gnu.org/copyleft/gpl.html.
37**
38** If you have questions regarding the use of this file, please contact
39** Nokia at [email protected].
40** $QT_END_LICENSE$
41**
42****************************************************************************/
43
44#include "qdesktopwidget.h"
45#include "qt_os2.h"
46#include "qapplication_p.h"
47#include "qwidget_p.h"
48
49#include "qdebug.h"
50
51QT_BEGIN_NAMESPACE
52
53// stolen from xWorkplace sources
54static
55APIRET qt_DosQueryProcAddr(PCSZ pcszModuleName, ULONG ulOrdinal, PFN *ppfn)
56{
57 HMODULE hmod = NULL;
58 APIRET rc = 0;
59 if (!(rc = DosQueryModuleHandle( (PSZ)pcszModuleName, &hmod))) {
60 if ((rc = DosQueryProcAddr( hmod, ulOrdinal, NULL, ppfn))) {
61 // the CP programming guide and reference says use
62 // DosLoadModule if DosQueryProcAddr fails with this error
63 if (rc == ERROR_INVALID_HANDLE) {
64 if (!(rc = DosLoadModule(NULL, 0, (PSZ) pcszModuleName,
65 &hmod))) {
66 rc = DosQueryProcAddr(hmod, ulOrdinal, NULL, ppfn);
67 }
68 }
69 }
70 }
71 return rc;
72}
73
74class QDesktopWidgetPrivate : public QWidgetPrivate
75{
76public:
77 QRect workArea;
78};
79
80/*
81 \omit
82 Function is commented out in header
83 \fn void *QDesktopWidget::handle(int screen) const
84
85 Returns the window system handle of the display device with the
86 index \a screen, for low-level access. Using this function is not
87 portable.
88
89 The return type varies with platform; see qwindowdefs.h for details.
90
91 \sa x11Display(), QPaintDevice::handle()
92 \endomit
93*/
94
95QDesktopWidget::QDesktopWidget()
96 : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
97{
98 setObjectName(QLatin1String("desktop"));
99}
100
101QDesktopWidget::~QDesktopWidget()
102{
103}
104
105bool QDesktopWidget::isVirtualDesktop() const
106{
107 return true;
108}
109
110int QDesktopWidget::primaryScreen() const
111{
112 return 0;
113}
114
115int QDesktopWidget::numScreens() const
116{
117 return 1;
118}
119
120QWidget *QDesktopWidget::screen(int /* screen */)
121{
122 // It seems that a Qt::WType_Desktop cannot be moved?
123 return this;
124}
125
126const QRect QDesktopWidget::availableGeometry(int screen) const
127{
128 Q_D(const QDesktopWidget);
129
130 if (!d->workArea.isValid())
131 const_cast<QDesktopWidget *>(this)->resizeEvent(0);
132 if (d->workArea.isValid())
133 return d->workArea;
134
135 return geometry();
136}
137
138const QRect QDesktopWidget::screenGeometry(int screen) const
139{
140 return geometry();
141}
142
143int QDesktopWidget::screenNumber(const QWidget * /* widget */) const
144{
145 return 0;
146}
147
148int QDesktopWidget::screenNumber(const QPoint & /* point */) const
149{
150 return 0;
151}
152
153void QDesktopWidget::resizeEvent(QResizeEvent *e)
154{
155 Q_D(QDesktopWidget);
156
157 if (e == 0) {
158 // this is a Work Area Changed notification, see WM_SYSVALUECHANGED
159 // in qapplication_pm.cpp
160 typedef
161 BOOL (APIENTRY *WinQueryDesktopWorkArea_T) (HWND hwndDesktop,
162 PRECTL pwrcWorkArea);
163 static WinQueryDesktopWorkArea_T WinQueryDesktopWorkArea =
164 (WinQueryDesktopWorkArea_T) ~0;
165
166 if ((ULONG) WinQueryDesktopWorkArea == (ULONG) ~0) {
167 if (qt_DosQueryProcAddr("PMMERGE", 5469,
168 (PFN *) &WinQueryDesktopWorkArea))
169 WinQueryDesktopWorkArea = NULL;
170 }
171
172 if (WinQueryDesktopWorkArea) {
173 RECTL rcl;
174 if (WinQueryDesktopWorkArea(HWND_DESKTOP, &rcl)) {
175 // flip y coordinates
176 d->workArea.setCoords(rcl.xLeft, height() - rcl.yTop,
177 rcl.xRight - 1,
178 height() - (rcl.yBottom + 1));
179 }
180 }
181
182 emit workAreaResized(0);
183 return;
184 }
185
186 // otherwise nothing to do, the desktop cannot be dynamically resized
187 // on OS/2
188}
189
190QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.