Compare commits
No commits in common. "924ce5d12793360cb0656eb01d6b3a42d9679377" and "0241ecd07fc516b7f3379f6185cb42be85c8d2ad" have entirely different histories.
924ce5d127
...
0241ecd07f
|
@ -1,13 +1,11 @@
|
||||||
#include "FluFramelessHelper.h"
|
#include "FluFramelessHelper.h"
|
||||||
|
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QScreen>
|
|
||||||
#include "FluTools.h"
|
#include "FluTools.h"
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#pragma comment (lib,"user32.lib")
|
#pragma comment (lib,"user32.lib")
|
||||||
#pragma comment (lib,"dwmapi.lib")
|
#pragma comment (lib,"dwmapi.lib")
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <windowsx.h>
|
|
||||||
#include <dwmapi.h>
|
#include <dwmapi.h>
|
||||||
|
|
||||||
static inline QByteArray qtNativeEventType()
|
static inline QByteArray qtNativeEventType()
|
||||||
|
@ -89,7 +87,7 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
||||||
}
|
}
|
||||||
const auto msg = static_cast<const MSG *>(message);
|
const auto msg = static_cast<const MSG *>(message);
|
||||||
const HWND hwnd = msg->hwnd;
|
const HWND hwnd = msg->hwnd;
|
||||||
if (!hwnd || !msg) {
|
if (!hwnd) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const qint64 wid = reinterpret_cast<qint64>(hwnd);
|
const qint64 wid = reinterpret_cast<qint64>(hwnd);
|
||||||
|
@ -97,6 +95,10 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const UINT uMsg = msg->message;
|
const UINT uMsg = msg->message;
|
||||||
|
if (!msg || !hwnd)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const WPARAM wParam = msg->wParam;
|
const WPARAM wParam = msg->wParam;
|
||||||
const LPARAM lParam = msg->lParam;
|
const LPARAM lParam = msg->lParam;
|
||||||
if(uMsg == WM_WINDOWPOSCHANGING){
|
if(uMsg == WM_WINDOWPOSCHANGING){
|
||||||
|
@ -111,29 +113,23 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
||||||
}else if(uMsg == WM_NCCALCSIZE){
|
}else if(uMsg == WM_NCCALCSIZE){
|
||||||
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
const auto clientRect = ((wParam == FALSE) ? reinterpret_cast<LPRECT>(lParam) : &(reinterpret_cast<LPNCCALCSIZE_PARAMS>(lParam))->rgrc[0]);
|
||||||
const LONG originalTop = clientRect->top;
|
const LONG originalTop = clientRect->top;
|
||||||
|
const LONG originalBottom = clientRect->bottom;
|
||||||
const LONG originalLeft = clientRect->left;
|
const LONG originalLeft = clientRect->left;
|
||||||
|
const LONG originalRight= clientRect->right;
|
||||||
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
const LRESULT hitTestResult = ::DefWindowProcW(hwnd, WM_NCCALCSIZE, wParam, lParam);
|
||||||
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
if ((hitTestResult != HTERROR) && (hitTestResult != HTNOWHERE)) {
|
||||||
*result = hitTestResult;
|
*result = hitTestResult;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int offsetTop = 0;
|
if(IsZoomed(hwnd)){
|
||||||
bool isMax = IsZoomed(hwnd);
|
|
||||||
if(isMax){
|
|
||||||
_helper->setOriginalPos(QPoint(originalLeft,originalTop));
|
_helper->setOriginalPos(QPoint(originalLeft,originalTop));
|
||||||
if(isTaskbarAutoHide()){
|
if(isTaskbarAutoHide()){
|
||||||
clientRect->bottom -= 1;
|
clientRect->bottom -= 1;
|
||||||
}
|
}
|
||||||
offsetTop = 0;
|
|
||||||
}else{
|
}else{
|
||||||
_helper->setOriginalPos({});
|
_helper->setOriginalPos({});
|
||||||
if(FluTools::getInstance()->isWindows11OrGreater()){
|
|
||||||
offsetTop = 0;
|
|
||||||
}else{
|
|
||||||
offsetTop = 1;
|
|
||||||
}
|
}
|
||||||
}
|
clientRect->top = originalTop + 1;
|
||||||
clientRect->top = originalTop+offsetTop;
|
|
||||||
*result = WVR_REDRAW;
|
*result = WVR_REDRAW;
|
||||||
return true;
|
return true;
|
||||||
}if(uMsg == WM_NCHITTEST){
|
}if(uMsg == WM_NCHITTEST){
|
||||||
|
@ -160,15 +156,10 @@ bool FramelessEventFilter::nativeEventFilter(const QByteArray &eventType, void *
|
||||||
}else if(uMsg == WM_NCPAINT){
|
}else if(uMsg == WM_NCPAINT){
|
||||||
*result = 0;
|
*result = 0;
|
||||||
return true;
|
return true;
|
||||||
}else if(uMsg == WM_NCACTIVATE){
|
}
|
||||||
|
else if(uMsg == WM_NCACTIVATE){
|
||||||
*result = DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
|
*result = DefWindowProcW(hwnd, WM_NCACTIVATE, wParam, -1);
|
||||||
return true;
|
return true;
|
||||||
}else if(uMsg == WM_SYSCOMMAND){
|
|
||||||
const WPARAM filteredWParam = (wParam & 0xFFF0);
|
|
||||||
if (filteredWParam == SC_MAXIMIZE) {
|
|
||||||
_helper->window->showMaximized();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -287,7 +278,7 @@ void FluFramelessHelper::componentComplete(){
|
||||||
_appBarHeight = QQmlProperty(window,"_appBarHeight");
|
_appBarHeight = QQmlProperty(window,"_appBarHeight");
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if(isCompositionEnabled()){
|
if(isCompositionEnabled()){
|
||||||
window->setFlag(Qt::CustomizeWindowHint,true);
|
window->setFlags(Qt::Window|Qt::CustomizeWindowHint);
|
||||||
_nativeEvent =new FramelessEventFilter(this);
|
_nativeEvent =new FramelessEventFilter(this);
|
||||||
qApp->installNativeEventFilter(_nativeEvent);
|
qApp->installNativeEventFilter(_nativeEvent);
|
||||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||||
|
@ -307,7 +298,7 @@ void FluFramelessHelper::componentComplete(){
|
||||||
#endif
|
#endif
|
||||||
int w = _realWidth.read().toInt();
|
int w = _realWidth.read().toInt();
|
||||||
int h = _realHeight.read().toInt()+_appBarHeight.read().toInt();
|
int h = _realHeight.read().toInt()+_appBarHeight.read().toInt();
|
||||||
if(!resizeable()){
|
if(_fixSize.read().toBool()){
|
||||||
window->setMaximumSize(QSize(w,h));
|
window->setMaximumSize(QSize(w,h));
|
||||||
window->setMinimumSize(QSize(w,h));
|
window->setMinimumSize(QSize(w,h));
|
||||||
}
|
}
|
||||||
|
@ -317,7 +308,6 @@ void FluFramelessHelper::componentComplete(){
|
||||||
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
|
_stayTop.connectNotifySignal(this,SLOT(_onStayTopChange()));
|
||||||
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
|
_screen.connectNotifySignal(this,SLOT(_onScreenChanged()));
|
||||||
window->installEventFilter(this);
|
window->installEventFilter(this);
|
||||||
Q_EMIT loadCompleted();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +324,7 @@ void FluFramelessHelper::showSystemMenu(){
|
||||||
QPoint point = QCursor::pos();
|
QPoint point = QCursor::pos();
|
||||||
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
HWND hwnd = reinterpret_cast<HWND>(window->winId());
|
||||||
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_SYSMENU);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX);
|
||||||
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
|
const HMENU hMenu = ::GetSystemMenu(hwnd, FALSE);
|
||||||
DeleteMenu(hMenu, SC_MOVE, MF_BYCOMMAND);
|
DeleteMenu(hMenu, SC_MOVE, MF_BYCOMMAND);
|
||||||
DeleteMenu(hMenu, SC_SIZE, MF_BYCOMMAND);
|
DeleteMenu(hMenu, SC_SIZE, MF_BYCOMMAND);
|
||||||
|
@ -352,7 +342,7 @@ void FluFramelessHelper::showSystemMenu(){
|
||||||
if (result != FALSE) {
|
if (result != FALSE) {
|
||||||
PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
PostMessageW(hwnd, WM_SYSCOMMAND, result, 0);
|
||||||
}
|
}
|
||||||
SetWindowLongPtr(hwnd, GWL_STYLE, style &~ WS_SYSMENU);
|
SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION &~ WS_SYSMENU);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,7 +404,7 @@ void FluFramelessHelper::setOriginalPos(QVariant pos){
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FluFramelessHelper::resizeable(){
|
bool FluFramelessHelper::resizeable(){
|
||||||
return !_fixSize.read().toBool();
|
return !(window->width() == window->maximumWidth() && window->width() == window->minimumWidth() && window->height() == window->maximumHeight() && window->height() == window->minimumHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FluFramelessHelper::_maximized(){
|
bool FluFramelessHelper::_maximized(){
|
||||||
|
|
|
@ -41,7 +41,6 @@ public:
|
||||||
QObject* maximizeButton();
|
QObject* maximizeButton();
|
||||||
void setOriginalPos(QVariant pos);
|
void setOriginalPos(QVariant pos);
|
||||||
Q_INVOKABLE void showSystemMenu();
|
Q_INVOKABLE void showSystemMenu();
|
||||||
Q_SIGNAL void loadCompleted();
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -240,7 +240,3 @@ bool FluTools::isWindows10OrGreater(){
|
||||||
return var.toBool();
|
return var.toBool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int FluTools::getTaskBarHeight(QQuickWindow* window){
|
|
||||||
return window->screen()->geometry().height() - window->screen()->availableGeometry().height();
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QtQml/qqml.h>
|
#include <QtQml/qqml.h>
|
||||||
#include <QQuickWindow>
|
|
||||||
#include "singleton.h"
|
#include "singleton.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +54,6 @@ public:
|
||||||
Q_INVOKABLE int windowBuildNumber();
|
Q_INVOKABLE int windowBuildNumber();
|
||||||
Q_INVOKABLE bool isWindows11OrGreater();
|
Q_INVOKABLE bool isWindows11OrGreater();
|
||||||
Q_INVOKABLE bool isWindows10OrGreater();
|
Q_INVOKABLE bool isWindows10OrGreater();
|
||||||
Q_INVOKABLE int getTaskBarHeight(QQuickWindow* window);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FLUTOOLS_H
|
#endif // FLUTOOLS_H
|
||||||
|
|
|
@ -8,7 +8,7 @@ Button {
|
||||||
property string contentDescription: ""
|
property string contentDescription: ""
|
||||||
QtObject{
|
QtObject{
|
||||||
id:d
|
id:d
|
||||||
property bool checked: (rect_back.height === background.height) && (progress === 1)
|
property bool checked: rect_back.height == background.height
|
||||||
}
|
}
|
||||||
property color normalColor: {
|
property color normalColor: {
|
||||||
if(d.checked){
|
if(d.checked){
|
||||||
|
|
|
@ -70,13 +70,12 @@ Window {
|
||||||
_realHeight = height
|
_realHeight = height
|
||||||
_realWidth = width
|
_realWidth = width
|
||||||
moveWindowToDesktopCenter()
|
moveWindowToDesktopCenter()
|
||||||
fixWindowSize()
|
|
||||||
lifecycle.onCompleted(window)
|
|
||||||
initArgument(argument)
|
|
||||||
useSystemAppBar = FluApp.useSystemAppBar
|
useSystemAppBar = FluApp.useSystemAppBar
|
||||||
if(!useSystemAppBar){
|
if(!useSystemAppBar){
|
||||||
loader_frameless_helper.sourceComponent = com_frameless_helper
|
loader_frameless_helper.sourceComponent = com_frameless
|
||||||
}
|
}
|
||||||
|
lifecycle.onCompleted(window)
|
||||||
|
initArgument(argument)
|
||||||
if(window.autoMaximize){
|
if(window.autoMaximize){
|
||||||
window.showMaximized()
|
window.showMaximized()
|
||||||
}else{
|
}else{
|
||||||
|
@ -120,12 +119,8 @@ Window {
|
||||||
function onClosing(event){closeListener(event)}
|
function onClosing(event){closeListener(event)}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
id:com_frameless_helper
|
id:com_frameless
|
||||||
FluFramelessHelper{
|
FluFramelessHelper{}
|
||||||
onLoadCompleted:{
|
|
||||||
window.moveWindowToDesktopCenter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
id:com_background
|
id:com_background
|
||||||
|
@ -305,15 +300,12 @@ Window {
|
||||||
}
|
}
|
||||||
function moveWindowToDesktopCenter(){
|
function moveWindowToDesktopCenter(){
|
||||||
screen = Qt.application.screens[FluTools.cursorScreenIndex()]
|
screen = Qt.application.screens[FluTools.cursorScreenIndex()]
|
||||||
var taskBarHeight = FluTools.getTaskBarHeight(window)
|
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height)
|
||||||
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height-taskBarHeight)/2+Screen.virtualY,window.width,window.height)
|
|
||||||
}
|
|
||||||
function fixWindowSize(){
|
|
||||||
if(fixSize){
|
if(fixSize){
|
||||||
window.maximumWidth = window.width
|
maximumWidth = width
|
||||||
window.maximumHeight = window.height
|
maximumHeight = height
|
||||||
window.minimumWidth = window.width
|
minimumWidth = width
|
||||||
window.minimumHeight = window.height
|
minimumHeight = height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onResult(data){
|
function onResult(data){
|
||||||
|
|
|
@ -9,7 +9,7 @@ Button {
|
||||||
property string contentDescription: ""
|
property string contentDescription: ""
|
||||||
QtObject{
|
QtObject{
|
||||||
id:d
|
id:d
|
||||||
property bool checked: (rect_back.height === background.height) && (progress === 1)
|
property bool checked: rect_back.height == background.height
|
||||||
}
|
}
|
||||||
property color normalColor: {
|
property color normalColor: {
|
||||||
if(d.checked){
|
if(d.checked){
|
||||||
|
|
|
@ -69,13 +69,12 @@ Window {
|
||||||
_realHeight = height
|
_realHeight = height
|
||||||
_realWidth = width
|
_realWidth = width
|
||||||
moveWindowToDesktopCenter()
|
moveWindowToDesktopCenter()
|
||||||
fixWindowSize()
|
|
||||||
lifecycle.onCompleted(window)
|
|
||||||
initArgument(argument)
|
|
||||||
useSystemAppBar = FluApp.useSystemAppBar
|
useSystemAppBar = FluApp.useSystemAppBar
|
||||||
if(!useSystemAppBar){
|
if(!useSystemAppBar){
|
||||||
loader_frameless_helper.sourceComponent = com_frameless_helper
|
loader_frameless_helper.sourceComponent = com_frameless
|
||||||
}
|
}
|
||||||
|
lifecycle.onCompleted(window)
|
||||||
|
initArgument(argument)
|
||||||
if(window.autoMaximize){
|
if(window.autoMaximize){
|
||||||
window.showMaximized()
|
window.showMaximized()
|
||||||
}else{
|
}else{
|
||||||
|
@ -119,12 +118,8 @@ Window {
|
||||||
function onClosing(event){closeListener(event)}
|
function onClosing(event){closeListener(event)}
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
id:com_frameless_helper
|
id:com_frameless
|
||||||
FluFramelessHelper{
|
FluFramelessHelper{}
|
||||||
onLoadCompleted:{
|
|
||||||
window.moveWindowToDesktopCenter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Component{
|
Component{
|
||||||
id:com_background
|
id:com_background
|
||||||
|
@ -304,15 +299,12 @@ Window {
|
||||||
}
|
}
|
||||||
function moveWindowToDesktopCenter(){
|
function moveWindowToDesktopCenter(){
|
||||||
screen = Qt.application.screens[FluTools.cursorScreenIndex()]
|
screen = Qt.application.screens[FluTools.cursorScreenIndex()]
|
||||||
var taskBarHeight = FluTools.getTaskBarHeight(window)
|
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height)/2+Screen.virtualY,window.width,window.height)
|
||||||
window.setGeometry((Screen.width-window.width)/2+Screen.virtualX,(Screen.height-window.height-taskBarHeight)/2+Screen.virtualY,window.width,window.height)
|
|
||||||
}
|
|
||||||
function fixWindowSize(){
|
|
||||||
if(fixSize){
|
if(fixSize){
|
||||||
window.maximumWidth = window.width
|
maximumWidth = width
|
||||||
window.maximumHeight = window.height
|
maximumHeight = height
|
||||||
window.minimumWidth = window.width
|
minimumWidth = width
|
||||||
window.minimumHeight = window.height
|
minimumHeight = height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function onResult(data){
|
function onResult(data){
|
||||||
|
|
Loading…
Reference in New Issue