forked from github_mirror/framelesshelper
Minor tweaks
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
6adbefa814
commit
6bc6ed63cc
|
@ -226,7 +226,7 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (window->windowStates().testFlag(Qt::WindowState::WindowNoState)
|
if ((window->windowState() == Qt::WindowState::WindowNoState)
|
||||||
&& !isInSpecificObjects(globalPoint, getIgnoreObjects(window))
|
&& !isInSpecificObjects(globalPoint, getIgnoreObjects(window))
|
||||||
&& getResizable(window)) {
|
&& getResizable(window)) {
|
||||||
if (!window->startSystemResize(edges)) {
|
if (!window->startSystemResize(edges)) {
|
||||||
|
@ -254,10 +254,10 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event)
|
||||||
if (isInTitlebarArea(getMousePos(mouseEvent, true),
|
if (isInTitlebarArea(getMousePos(mouseEvent, true),
|
||||||
getMousePos(mouseEvent, false),
|
getMousePos(mouseEvent, false),
|
||||||
currentWindow)) {
|
currentWindow)) {
|
||||||
if (currentWindow->windowStates().testFlag(Qt::WindowState::WindowFullScreen)) {
|
if (currentWindow->windowState() == Qt::WindowState::WindowFullScreen) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (currentWindow->windowStates().testFlag(Qt::WindowState::WindowMaximized)) {
|
if (currentWindow->windowState() == Qt::WindowState::WindowMaximized) {
|
||||||
currentWindow->showNormal();
|
currentWindow->showNormal();
|
||||||
} else {
|
} else {
|
||||||
currentWindow->showMaximized();
|
currentWindow->showMaximized();
|
||||||
|
@ -282,7 +282,7 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event)
|
||||||
case QEvent::MouseMove: {
|
case QEvent::MouseMove: {
|
||||||
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
if (mouseEvent) {
|
if (mouseEvent) {
|
||||||
if (currentWindow->windowStates().testFlag(Qt::WindowState::WindowNoState)
|
if ((currentWindow->windowState() == Qt::WindowState::WindowNoState)
|
||||||
&& getResizable(currentWindow)) {
|
&& getResizable(currentWindow)) {
|
||||||
currentWindow->setCursor(
|
currentWindow->setCursor(
|
||||||
getCursorShape(getWindowEdges(getMousePos(mouseEvent, false),
|
getCursorShape(getWindowEdges(getMousePos(mouseEvent, false),
|
||||||
|
|
|
@ -289,7 +289,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
*result = 0;
|
*result = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool nonclient = false;
|
bool nonClientAreaExists = false;
|
||||||
const auto clientRect = &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(msg->lParam)->rgrc[0]);
|
const auto clientRect = &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(msg->lParam)->rgrc[0]);
|
||||||
if (shouldHaveWindowFrame()) {
|
if (shouldHaveWindowFrame()) {
|
||||||
// Store the original top before the default window proc
|
// Store the original top before the default window proc
|
||||||
|
@ -308,7 +308,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// We don't need this correction when we're fullscreen. We will
|
// We don't need this correction when we're fullscreen. We will
|
||||||
// have the WS_POPUP size, so we don't have to worry about
|
// have the WS_POPUP size, so we don't have to worry about
|
||||||
// borders, and the default frame will be fine.
|
// borders, and the default frame will be fine.
|
||||||
if (IsMaximized(msg->hwnd) && !(window->windowState() & Qt::WindowFullScreen)) {
|
if (IsMaximized(msg->hwnd) && !(window->windowState() == Qt::WindowFullScreen)) {
|
||||||
// Windows automatically adds a standard width border to all
|
// Windows automatically adds a standard width border to all
|
||||||
// sides when a window is maximized. We have to remove it
|
// sides when a window is maximized. We have to remove it
|
||||||
// otherwise the content of our window will be cut-off from
|
// otherwise the content of our window will be cut-off from
|
||||||
|
@ -324,7 +324,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
clientRect->left += bw;
|
clientRect->left += bw;
|
||||||
clientRect->right -= bw;
|
clientRect->right -= bw;
|
||||||
}
|
}
|
||||||
nonclient = true;
|
nonClientAreaExists = true;
|
||||||
}
|
}
|
||||||
// Attempt to detect if there's an autohide taskbar, and if
|
// Attempt to detect if there's an autohide taskbar, and if
|
||||||
// there is, reduce our size a bit on the side with the taskbar,
|
// there is, reduce our size a bit on the side with the taskbar,
|
||||||
|
@ -399,16 +399,16 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
if (top) {
|
if (top) {
|
||||||
// Peculiarly, when we're fullscreen,
|
// Peculiarly, when we're fullscreen,
|
||||||
clientRect->top += kAutoHideTaskbarThicknessPy;
|
clientRect->top += kAutoHideTaskbarThicknessPy;
|
||||||
nonclient = true;
|
nonClientAreaExists = true;
|
||||||
} else if (bottom) {
|
} else if (bottom) {
|
||||||
clientRect->bottom -= kAutoHideTaskbarThicknessPy;
|
clientRect->bottom -= kAutoHideTaskbarThicknessPy;
|
||||||
nonclient = true;
|
nonClientAreaExists = true;
|
||||||
} else if (left) {
|
} else if (left) {
|
||||||
clientRect->left += kAutoHideTaskbarThicknessPx;
|
clientRect->left += kAutoHideTaskbarThicknessPx;
|
||||||
nonclient = true;
|
nonClientAreaExists = true;
|
||||||
} else if (right) {
|
} else if (right) {
|
||||||
clientRect->right -= kAutoHideTaskbarThicknessPx;
|
clientRect->right -= kAutoHideTaskbarThicknessPx;
|
||||||
nonclient = true;
|
nonClientAreaExists = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ bool FramelessHelperWin::nativeEventFilter(const QByteArray &eventType, void *me
|
||||||
// Windows exhibits bugs where client pixels and child HWNDs are
|
// Windows exhibits bugs where client pixels and child HWNDs are
|
||||||
// mispositioned by the width/height of the upper-left nonclient
|
// mispositioned by the width/height of the upper-left nonclient
|
||||||
// area.
|
// area.
|
||||||
*result = nonclient ? 0 : WVR_REDRAW;
|
*result = nonClientAreaExists ? 0 : WVR_REDRAW;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// These undocumented messages are sent to draw themed window
|
// These undocumented messages are sent to draw themed window
|
||||||
|
|
|
@ -742,16 +742,18 @@ void Utilities::displaySystemMenu(const QWindow *window, const QPoint &pos)
|
||||||
SetMenuItemInfoW(hMenu, SC_MAXIMIZE, FALSE, &mii);
|
SetMenuItemInfoW(hMenu, SC_MAXIMIZE, FALSE, &mii);
|
||||||
SetMenuItemInfoW(hMenu, SC_MINIMIZE, FALSE, &mii);
|
SetMenuItemInfoW(hMenu, SC_MINIMIZE, FALSE, &mii);
|
||||||
mii.fState = MF_GRAYED;
|
mii.fState = MF_GRAYED;
|
||||||
const auto isMin = [window]{
|
const bool isMin = [window]{
|
||||||
return (window->windowState() == Qt::WindowMinimized);
|
return (window->windowState() == Qt::WindowMinimized);
|
||||||
}();
|
}();
|
||||||
const auto isMax = [window]{
|
const bool isMax = [window]{
|
||||||
return (window->windowState() == Qt::WindowMaximized);
|
return (window->windowState() == Qt::WindowMaximized);
|
||||||
}();
|
}();
|
||||||
const auto isFull = [window]{
|
const bool isFull = [window]{
|
||||||
return (window->windowState() == Qt::WindowFullScreen);
|
return (window->windowState() == Qt::WindowFullScreen);
|
||||||
}();
|
}();
|
||||||
const bool isNormal = !isMin && !isMax && !isFull;
|
const bool isNormal = [window]{
|
||||||
|
return (window->windowState() == Qt::WindowNoState);
|
||||||
|
}();
|
||||||
const bool isFix = isWindowFixedSize(window);
|
const bool isFix = isWindowFixedSize(window);
|
||||||
if (isFix || isMax || isFull) {
|
if (isFix || isMax || isFull) {
|
||||||
SetMenuItemInfoW(hMenu, SC_SIZE, FALSE, &mii);
|
SetMenuItemInfoW(hMenu, SC_SIZE, FALSE, &mii);
|
||||||
|
|
Loading…
Reference in New Issue