@@ -73,12 +73,7 @@ void FluFrameless::componentComplete() {
73
73
int w = window ()->width ();
74
74
int h = window ()->height ();
75
75
_current = window ()->winId ();
76
- window ()->setFlags ((window ()->flags ()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::FramelessWindowHint);
77
- #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
78
- if (QQuickWindow::sceneGraphBackend () == " software" ) {
79
- window ()->setFlag (Qt::FramelessWindowHint, false );
80
- }
81
- #endif
76
+ window ()->setFlags ((window ()->flags ()) | Qt::CustomizeWindowHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint);
82
77
if (!_fixSize) {
83
78
window ()->setFlag (Qt::WindowMaximizeButtonHint);
84
79
}
@@ -97,14 +92,14 @@ void FluFrameless::componentComplete() {
97
92
HWND hwnd = reinterpret_cast <HWND>(window ()->winId ());
98
93
DWORD style = ::GetWindowLongPtr (hwnd, GWL_STYLE);
99
94
if (_fixSize) {
100
- ::SetWindowLongPtr (hwnd, GWL_STYLE, style | WS_THICKFRAME );
95
+ ::SetWindowLongPtr (hwnd, GWL_STYLE, style | WS_CAPTION );
101
96
for (int i = 0 ; i <= QGuiApplication::screens ().count () - 1 ; ++i) {
102
97
connect (QGuiApplication::screens ().at (i), &QScreen::logicalDotsPerInchChanged, this , [=] {
103
98
SetWindowPos (hwnd, nullptr , 0 , 0 , 0 , 0 , SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
104
99
});
105
100
}
106
101
} else {
107
- ::SetWindowLongPtr (hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME );
102
+ ::SetWindowLongPtr (hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_CAPTION );
108
103
}
109
104
SetWindowPos (hwnd, nullptr , 0 , 0 , 0 , 0 , SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
110
105
connect (window (), &QQuickWindow::screenChanged, this , [hwnd] {
@@ -151,29 +146,22 @@ void FluFrameless::componentComplete() {
151
146
return false ;
152
147
} else if (uMsg == WM_NCCALCSIZE) {
153
148
const auto clientRect = ((wParam == FALSE ) ? reinterpret_cast <LPRECT>(lParam) : &(reinterpret_cast <LPNCCALCSIZE_PARAMS>(lParam))->rgrc [0 ]);
154
- const LONG originalTop = clientRect->top ;
155
- const LONG originalLeft = clientRect->left ;
156
- const LONG originalRight = clientRect->right ;
157
- const LONG originalBottom = clientRect->bottom ;
158
- const LRESULT hitTestResult = ::DefWindowProcW (hwnd, WM_NCCALCSIZE, wParam, lParam);
159
- if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
160
- *result = static_cast <QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
161
- return true ;
162
- }
163
- int offsetSize;
164
149
bool isMaximum = ::IsZoomed (hwnd);
165
- if (isMaximum || _isFullScreen ()) {
166
- offsetSize = 0 ;
167
- } else {
168
- offsetSize = 1 ;
169
- }
170
- if (!isCompositionEnabled ()) {
171
- offsetSize = 0 ;
150
+ if (!isMaximum){
151
+ if (clientRect->top != 0 )
152
+ {
153
+ clientRect->top -= 1 ;
154
+ clientRect->bottom -= 1 ;
155
+ }
156
+ } else {
157
+ const LONG originalTop = clientRect->top ;
158
+ const LRESULT hitTestResult = ::DefWindowProcW (hwnd, WM_NCCALCSIZE, wParam, lParam);
159
+ if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
160
+ *result = static_cast <QT_NATIVE_EVENT_RESULT_TYPE>(hitTestResult);
161
+ return true ;
162
+ }
163
+ clientRect->top = originalTop-originalTop;
172
164
}
173
- clientRect->top = originalTop + offsetSize;
174
- clientRect->bottom = originalBottom - offsetSize;
175
- clientRect->left = originalLeft + offsetSize;
176
- clientRect->right = originalRight - offsetSize;
177
165
_setMaximizeHovered (false );
178
166
*result = WVR_REDRAW;
179
167
return true ;
@@ -230,6 +218,18 @@ void FluFrameless::componentComplete() {
230
218
}
231
219
*result = HTCLIENT;
232
220
return true ;
221
+ } else if (uMsg == WM_NCPAINT) {
222
+ if (isCompositionEnabled ()){
223
+ return false ;
224
+ }
225
+ *result = FALSE ;
226
+ return true ;
227
+ } else if (uMsg == WM_NCACTIVATE) {
228
+ if (isCompositionEnabled ()){
229
+ return false ;
230
+ }
231
+ *result = TRUE ;
232
+ return true ;
233
233
} else if (_isWindows11OrGreater && (uMsg == WM_NCLBUTTONDBLCLK || uMsg == WM_NCLBUTTONDOWN)) {
234
234
if (_hitMaximizeButton ()) {
235
235
QMouseEvent event = QMouseEvent (QEvent::MouseButtonPress, QPoint (), QPoint (), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
@@ -244,23 +244,8 @@ void FluFrameless::componentComplete() {
244
244
_setMaximizePressed (false );
245
245
return true ;
246
246
}
247
- } else if (uMsg == WM_NCPAINT) {
248
- *result = FALSE ;
249
- return true ;
250
- } else if (uMsg == WM_NCACTIVATE) {
251
- *result = static_cast <QT_NATIVE_EVENT_RESULT_TYPE>(::DefWindowProcW (hwnd, WM_NCACTIVATE, wParam, -1 ));
247
+ } else if (uMsg == WM_ERASEBKGND) {
252
248
return true ;
253
- } else if (uMsg == WM_GETMINMAXINFO) {
254
- auto *minmaxInfo = reinterpret_cast <MINMAXINFO *>(lParam);
255
- auto pixelRatio = window ()->devicePixelRatio ();
256
- auto geometry = window ()->screen ()->availableGeometry ();
257
- RECT rect;
258
- SystemParametersInfo (SPI_GETWORKAREA, 0 , &rect, 0 );
259
- minmaxInfo->ptMaxPosition .x = rect.left ;
260
- minmaxInfo->ptMaxPosition .y = rect.top ;
261
- minmaxInfo->ptMaxSize .x = qRound (geometry.width () * pixelRatio);
262
- minmaxInfo->ptMaxSize .y = qRound (geometry.height () * pixelRatio);
263
- return false ;
264
249
} else if (uMsg == WM_NCRBUTTONDOWN) {
265
250
if (wParam == HTCAPTION) {
266
251
_showSystemMenu (QCursor::pos ());
@@ -358,27 +343,27 @@ void FluFrameless::_setMaximizeHovered(bool val) {
358
343
359
344
void FluFrameless::_updateCursor (int edges) {
360
345
switch (edges) {
361
- case 0 :
362
- window ()->setCursor (Qt::ArrowCursor);
363
- break ;
364
- case Qt::LeftEdge:
365
- case Qt::RightEdge:
366
- window ()->setCursor (Qt::SizeHorCursor);
367
- break ;
368
- case Qt::TopEdge:
369
- case Qt::BottomEdge:
370
- window ()->setCursor (Qt::SizeVerCursor);
371
- break ;
372
- case Qt::LeftEdge | Qt::TopEdge:
373
- case Qt::RightEdge | Qt::BottomEdge:
374
- window ()->setCursor (Qt::SizeFDiagCursor);
375
- break ;
376
- case Qt::RightEdge | Qt::TopEdge:
377
- case Qt::LeftEdge | Qt::BottomEdge:
378
- window ()->setCursor (Qt::SizeBDiagCursor);
379
- break ;
380
- default :
381
- break ;
346
+ case 0 :
347
+ window ()->setCursor (Qt::ArrowCursor);
348
+ break ;
349
+ case Qt::LeftEdge:
350
+ case Qt::RightEdge:
351
+ window ()->setCursor (Qt::SizeHorCursor);
352
+ break ;
353
+ case Qt::TopEdge:
354
+ case Qt::BottomEdge:
355
+ window ()->setCursor (Qt::SizeVerCursor);
356
+ break ;
357
+ case Qt::LeftEdge | Qt::TopEdge:
358
+ case Qt::RightEdge | Qt::BottomEdge:
359
+ window ()->setCursor (Qt::SizeFDiagCursor);
360
+ break ;
361
+ case Qt::RightEdge | Qt::TopEdge:
362
+ case Qt::LeftEdge | Qt::BottomEdge:
363
+ window ()->setCursor (Qt::SizeBDiagCursor);
364
+ break ;
365
+ default :
366
+ break ;
382
367
}
383
368
}
384
369
0 commit comments