mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
Fix window title on Windows 7.
Regression was introduced in dd68c7e90
.
Fixes #6106.
This commit is contained in:
parent
abfe685697
commit
1225c9194a
12 changed files with 135 additions and 140 deletions
|
@ -162,9 +162,6 @@ void Application::run() {
|
|||
|
||||
DEBUG_LOG(("Application Info: inited..."));
|
||||
|
||||
QCoreApplication::instance()->installNativeEventFilter(
|
||||
psNativeEventFilter());
|
||||
|
||||
cChangeTimeFormat(QLocale::system().timeFormat(QLocale::ShortFormat));
|
||||
|
||||
DEBUG_LOG(("Application Info: starting app..."));
|
||||
|
|
|
@ -118,17 +118,6 @@ QString CurrentExecutablePath(int argc, char *argv[]) {
|
|||
|
||||
namespace {
|
||||
|
||||
class _PsEventFilter : public QAbstractNativeEventFilter {
|
||||
public:
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
|
||||
//auto wnd = App::wnd();
|
||||
//if (!wnd) return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
_PsEventFilter *_psEventFilter = nullptr;
|
||||
|
||||
QRect _monitorRect;
|
||||
auto _monitorLastGot = 0LL;
|
||||
|
||||
|
@ -149,12 +138,6 @@ void psShowOverAll(QWidget *w, bool canFocus) {
|
|||
void psBringToBack(QWidget *w) {
|
||||
}
|
||||
|
||||
QAbstractNativeEventFilter *psNativeEventFilter() {
|
||||
delete _psEventFilter;
|
||||
_psEventFilter = new _PsEventFilter();
|
||||
return _psEventFilter;
|
||||
}
|
||||
|
||||
void psWriteDump() {
|
||||
}
|
||||
|
||||
|
@ -255,9 +238,6 @@ void start() {
|
|||
|
||||
void finish() {
|
||||
Notifications::Finish();
|
||||
|
||||
delete _psEventFilter;
|
||||
_psEventFilter = nullptr;
|
||||
}
|
||||
|
||||
bool TranslucentWindowsSupported(QPoint globalPosition) {
|
||||
|
|
|
@ -69,8 +69,6 @@ void psBringToBack(QWidget *w);
|
|||
int psCleanup();
|
||||
int psFixPrevious();
|
||||
|
||||
QAbstractNativeEventFilter *psNativeEventFilter();
|
||||
|
||||
void psNewVersion();
|
||||
|
||||
void psUpdateOverlayed(QWidget *widget);
|
||||
|
|
|
@ -95,11 +95,30 @@ private:
|
|||
|
||||
#endif // OS_MAC_OLD
|
||||
|
||||
class EventFilter : public QAbstractNativeEventFilter {
|
||||
public:
|
||||
EventFilter(not_null<MainWindow*> window) : _window(window) {
|
||||
}
|
||||
|
||||
bool nativeEventFilter(
|
||||
const QByteArray &eventType,
|
||||
void *message,
|
||||
long *result) {
|
||||
return Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||
return _window->psFilterNativeEvent(message);
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
not_null<MainWindow*> _window;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class MainWindow::Private {
|
||||
public:
|
||||
Private(MainWindow *window);
|
||||
explicit Private(not_null<MainWindow*> window);
|
||||
|
||||
void setNativeWindow(NSWindow *window, NSView *view);
|
||||
void setWindowBadge(const QString &str);
|
||||
|
@ -123,7 +142,7 @@ private:
|
|||
void initCustomTitle();
|
||||
void refreshWeakTitleReferences();
|
||||
|
||||
MainWindow *_public;
|
||||
not_null<MainWindow*> _public;
|
||||
friend class MainWindow;
|
||||
|
||||
#ifdef OS_MAC_OLD
|
||||
|
@ -139,11 +158,13 @@ private:
|
|||
bool _useNativeTitle = false;
|
||||
bool _inFullScreen = false;
|
||||
|
||||
MainWindowObserver *_observer;
|
||||
MainWindowObserver *_observer = nullptr;
|
||||
NSPasteboard *_generalPasteboard = nullptr;
|
||||
int _generalPasteboardChangeCount = -1;
|
||||
bool _generalPasteboardHasText = false;
|
||||
|
||||
EventFilter _nativeEventFilter;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Platform
|
||||
|
@ -187,9 +208,10 @@ private:
|
|||
|
||||
namespace Platform {
|
||||
|
||||
MainWindow::Private::Private(MainWindow *window)
|
||||
MainWindow::Private::Private(not_null<MainWindow*> window)
|
||||
: _public(window)
|
||||
, _observer([[MainWindowObserver alloc] init:this]) {
|
||||
, _observer([[MainWindowObserver alloc] init:this])
|
||||
, _nativeEventFilter(window) {
|
||||
_generalPasteboard = [NSPasteboard generalPasteboard];
|
||||
|
||||
@autoreleasepool {
|
||||
|
@ -384,6 +406,9 @@ MainWindow::Private::~Private() {
|
|||
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||
: Window::MainWindow(controller)
|
||||
, _private(std::make_unique<Private>(this)) {
|
||||
QCoreApplication::instance()->installNativeEventFilter(
|
||||
&_private->_nativeEventFilter);
|
||||
|
||||
#ifndef OS_MAC_OLD
|
||||
auto forceOpenGL = std::make_unique<QOpenGLWidget>(this);
|
||||
#endif // !OS_MAC_OLD
|
||||
|
|
|
@ -68,8 +68,6 @@ int psFixPrevious();
|
|||
|
||||
bool psShowOpenWithMenu(int x, int y, const QString &file);
|
||||
|
||||
QAbstractNativeEventFilter *psNativeEventFilter();
|
||||
|
||||
void psNewVersion();
|
||||
|
||||
void psUpdateOverlayed(QWidget *widget);
|
||||
|
|
|
@ -33,23 +33,6 @@ namespace {
|
|||
|
||||
QStringList _initLogs;
|
||||
|
||||
class _PsEventFilter : public QAbstractNativeEventFilter {
|
||||
public:
|
||||
_PsEventFilter() {
|
||||
}
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
|
||||
return Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||
auto wnd = App::wnd();
|
||||
if (!wnd) return false;
|
||||
|
||||
return wnd->psFilterNativeEvent(message);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
_PsEventFilter *_psEventFilter = nullptr;
|
||||
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
@ -76,12 +59,6 @@ void psBringToBack(QWidget *w) {
|
|||
objc_bringToBack(w->winId());
|
||||
}
|
||||
|
||||
QAbstractNativeEventFilter *psNativeEventFilter() {
|
||||
delete _psEventFilter;
|
||||
_psEventFilter = new _PsEventFilter();
|
||||
return _psEventFilter;
|
||||
}
|
||||
|
||||
void psWriteDump() {
|
||||
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
|
||||
double v = objc_appkitVersion();
|
||||
|
@ -139,9 +116,6 @@ void start() {
|
|||
}
|
||||
|
||||
void finish() {
|
||||
delete _psEventFilter;
|
||||
_psEventFilter = nullptr;
|
||||
|
||||
objc_finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_window.h"
|
||||
#include "platform/platform_notifications_manager.h"
|
||||
#include "platform/win/windows_dlls.h"
|
||||
#include "platform/win/windows_event_filter.h"
|
||||
#include "window/notifications_manager.h"
|
||||
#include "mainwindow.h"
|
||||
#include "core/application.h"
|
||||
|
@ -129,7 +130,8 @@ public:
|
|||
update(Change::Moved | Change::Resized);
|
||||
}
|
||||
|
||||
bool init(QColor c) {
|
||||
bool init(not_null<MainWindow*> window, QColor c) {
|
||||
_window = window;
|
||||
_fullsize = st::windowShadow.width();
|
||||
_shift = st::windowShadowShift;
|
||||
auto cornersImage = QImage(_fullsize, _fullsize, QImage::Format_ARGB32_Premultiplied);
|
||||
|
@ -186,7 +188,7 @@ public:
|
|||
accumulate_max(max_h, st::titleHeight + st::windowMinHeight);
|
||||
|
||||
HINSTANCE appinst = (HINSTANCE)GetModuleHandle(0);
|
||||
HWND hwnd = App::wnd() ? App::wnd()->psHwnd() : 0;
|
||||
HWND hwnd = _window ? _window->psHwnd() : nullptr;
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
QString cn = QString("TelegramShadow%1").arg(i);
|
||||
|
@ -320,7 +322,7 @@ public:
|
|||
}
|
||||
|
||||
void update(Changes changes, WINDOWPOS *pos = 0) {
|
||||
HWND hwnd = App::wnd() ? App::wnd()->psHwnd() : 0;
|
||||
HWND hwnd = _window ? _window->psHwnd() : 0;
|
||||
if (!hwnd || !hwnds[0]) return;
|
||||
|
||||
if (changes == Changes(Change::Activate)) {
|
||||
|
@ -339,7 +341,7 @@ public:
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (!App::wnd()->positionInited()) return;
|
||||
if (!_window->positionInited()) return;
|
||||
|
||||
int x = _x, y = _y, w = _w, h = _h;
|
||||
if (pos && (!(pos->flags & SWP_NOMOVE) || !(pos->flags & SWP_NOSIZE) || !(pos->flags & SWP_NOREPOSITION))) {
|
||||
|
@ -497,12 +499,17 @@ public:
|
|||
if (screenDC) ReleaseDC(0, screenDC);
|
||||
}
|
||||
|
||||
MainWindow *window() const {
|
||||
return _window;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
int _x = 0, _y = 0, _w = 0, _h = 0;
|
||||
int _metaSize = 0, _fullsize = 0, _size = 0, _shift = 0;
|
||||
QVector<BYTE> _alphas, _colors;
|
||||
|
||||
MainWindow *_window = nullptr;
|
||||
bool hidden = true;
|
||||
|
||||
HWND hwnds[4];
|
||||
|
@ -520,8 +527,10 @@ private:
|
|||
_PsShadowWindows _psShadowWindows;
|
||||
|
||||
LRESULT CALLBACK _PsShadowWindows::wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||
auto wnd = App::wnd();
|
||||
if (!wnd || !wnd->shadowsWorking()) return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
const auto window = _psShadowWindows.window();
|
||||
if (!window || !window->shadowsWorking()) {
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
|
@ -533,7 +542,7 @@ LRESULT CALLBACK _PsShadowWindows::wndProc(HWND hwnd, UINT msg, WPARAM wParam, L
|
|||
|
||||
switch (msg) {
|
||||
case WM_CLOSE:
|
||||
App::wnd()->close();
|
||||
window->close();
|
||||
break;
|
||||
|
||||
case WM_NCHITTEST: {
|
||||
|
@ -566,20 +575,20 @@ LRESULT CALLBACK _PsShadowWindows::wndProc(HWND hwnd, UINT msg, WPARAM wParam, L
|
|||
case WM_NCPOINTERUPDATE:
|
||||
case WM_NCPOINTERDOWN:
|
||||
case WM_NCPOINTERUP:
|
||||
if (App::wnd() && App::wnd()->psHwnd()) {
|
||||
if (window && window->psHwnd()) {
|
||||
if (msg == WM_NCLBUTTONDOWN) {
|
||||
::SetForegroundWindow(App::wnd()->psHwnd());
|
||||
::SetForegroundWindow(window->psHwnd());
|
||||
}
|
||||
LRESULT res = SendMessage(App::wnd()->psHwnd(), msg, wParam, lParam);
|
||||
LRESULT res = SendMessage(window->psHwnd(), msg, wParam, lParam);
|
||||
return res;
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
case WM_ACTIVATE:
|
||||
if (App::wnd() && App::wnd()->psHwnd() && wParam == WA_ACTIVE) {
|
||||
if ((HWND)lParam != App::wnd()->psHwnd()) {
|
||||
if (window && window->psHwnd() && wParam == WA_ACTIVE) {
|
||||
if ((HWND)lParam != window->psHwnd()) {
|
||||
::SetForegroundWindow(hwnd);
|
||||
::SetWindowPos(App::wnd()->psHwnd(), hwnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
::SetWindowPos(window->psHwnd(), hwnd, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
|
||||
}
|
||||
}
|
||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||
|
@ -601,6 +610,9 @@ UINT MainWindow::_taskbarCreatedMsgId = 0;
|
|||
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||
: Window::MainWindow(controller)
|
||||
, ps_tbHider_hWnd(createTaskbarHider()) {
|
||||
QCoreApplication::instance()->installNativeEventFilter(
|
||||
EventFilter::CreateInstance(this));
|
||||
|
||||
if (!_taskbarCreatedMsgId) {
|
||||
_taskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
|
||||
}
|
||||
|
@ -787,7 +799,7 @@ void MainWindow::initHook() {
|
|||
|
||||
Q_DECLARE_METATYPE(QMargins);
|
||||
void MainWindow::psFirstShow() {
|
||||
_psShadowWindows.init(st::windowShadowFg->c);
|
||||
_psShadowWindows.init(this, st::windowShadowFg->c);
|
||||
_shadowsWorking = true;
|
||||
|
||||
psUpdateMargins();
|
||||
|
@ -973,6 +985,8 @@ MainWindow::~MainWindow() {
|
|||
psDestroyIcons();
|
||||
_psShadowWindows.destroy();
|
||||
if (ps_tbHider_hWnd) DestroyWindow(ps_tbHider_hWnd);
|
||||
|
||||
EventFilter::Destroy();
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
@ -665,14 +665,15 @@ void querySystemNotificationSettings() {
|
|||
bool SkipAudio() {
|
||||
querySystemNotificationSettings();
|
||||
|
||||
if (UserNotificationState == QUNS_NOT_PRESENT || UserNotificationState == QUNS_PRESENTATION_MODE) {
|
||||
if (UserNotificationState == QUNS_NOT_PRESENT
|
||||
|| UserNotificationState == QUNS_PRESENTATION_MODE
|
||||
|| QuietHoursEnabled) {
|
||||
return true;
|
||||
}
|
||||
if (QuietHoursEnabled) {
|
||||
return true;
|
||||
}
|
||||
if (EventFilter::getInstance()->sessionLoggedOff()) {
|
||||
return true;
|
||||
if (const auto filter = EventFilter::GetInstance()) {
|
||||
if (filter->sessionLoggedOff()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -680,10 +681,10 @@ bool SkipAudio() {
|
|||
bool SkipToast() {
|
||||
querySystemNotificationSettings();
|
||||
|
||||
if (UserNotificationState == QUNS_PRESENTATION_MODE || UserNotificationState == QUNS_RUNNING_D3D_FULL_SCREEN/* || UserNotificationState == QUNS_BUSY*/) {
|
||||
return true;
|
||||
}
|
||||
if (QuietHoursEnabled) {
|
||||
if (UserNotificationState == QUNS_PRESENTATION_MODE
|
||||
|| UserNotificationState == QUNS_RUNNING_D3D_FULL_SCREEN
|
||||
//|| UserNotificationState == QUNS_BUSY
|
||||
|| QuietHoursEnabled) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/win/notifications_manager_win.h"
|
||||
#include "platform/win/windows_app_user_model_id.h"
|
||||
#include "platform/win/windows_dlls.h"
|
||||
#include "platform/win/windows_event_filter.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
|
@ -81,10 +80,6 @@ namespace {
|
|||
|
||||
};
|
||||
|
||||
QAbstractNativeEventFilter *psNativeEventFilter() {
|
||||
return EventFilter::createInstance();
|
||||
}
|
||||
|
||||
void psDeleteDir(const QString &dir) {
|
||||
std::wstring wDir = QDir::toNativeSeparators(dir).toStdWString();
|
||||
WCHAR path[4096];
|
||||
|
@ -286,7 +281,6 @@ void start() {
|
|||
}
|
||||
|
||||
void finish() {
|
||||
EventFilter::destroy();
|
||||
}
|
||||
|
||||
bool IsApplicationActive() {
|
||||
|
|
|
@ -74,8 +74,6 @@ void psBringToBack(QWidget *w);
|
|||
int psCleanup();
|
||||
int psFixPrevious();
|
||||
|
||||
QAbstractNativeEventFilter *psNativeEventFilter();
|
||||
|
||||
void psNewVersion();
|
||||
|
||||
void psUpdateOverlayed(TWidget *widget);
|
||||
|
|
|
@ -29,40 +29,56 @@ bool IsCompositionEnabled() {
|
|||
|
||||
} // namespace
|
||||
|
||||
EventFilter *EventFilter::createInstance() {
|
||||
destroy();
|
||||
instance = new EventFilter();
|
||||
return getInstance();
|
||||
EventFilter *EventFilter::CreateInstance(not_null<MainWindow*> window) {
|
||||
Expects(instance == nullptr);
|
||||
|
||||
return (instance = new EventFilter(window));
|
||||
}
|
||||
|
||||
EventFilter *EventFilter::getInstance() {
|
||||
EventFilter *EventFilter::GetInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
void EventFilter::destroy() {
|
||||
void EventFilter::Destroy() {
|
||||
Expects(instance != nullptr);
|
||||
|
||||
delete instance;
|
||||
instance = nullptr;
|
||||
}
|
||||
|
||||
bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *result) {
|
||||
auto wnd = App::wnd();
|
||||
if (!wnd) return false;
|
||||
EventFilter::EventFilter(not_null<MainWindow*> window) : _window(window) {
|
||||
}
|
||||
|
||||
MSG *msg = (MSG*)message;
|
||||
bool EventFilter::nativeEventFilter(
|
||||
const QByteArray &eventType,
|
||||
void *message,
|
||||
long *result) {
|
||||
const auto msg = static_cast<MSG*>(message);
|
||||
if (msg->message == WM_ENDSESSION) {
|
||||
App::quit();
|
||||
return false;
|
||||
}
|
||||
if (msg->hwnd == wnd->psHwnd() || msg->hwnd && !wnd->psHwnd()) {
|
||||
return mainWindowEvent(msg->hwnd, msg->message, msg->wParam, msg->lParam, (LRESULT*)result);
|
||||
if (msg->hwnd == _window->psHwnd()
|
||||
|| msg->hwnd && !_window->psHwnd()) {
|
||||
return mainWindowEvent(
|
||||
msg->hwnd,
|
||||
msg->message,
|
||||
msg->wParam,
|
||||
msg->lParam,
|
||||
(LRESULT*)result);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *result) {
|
||||
bool EventFilter::mainWindowEvent(
|
||||
HWND hWnd,
|
||||
UINT msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam,
|
||||
LRESULT *result) {
|
||||
using ShadowsChange = MainWindow::ShadowsChange;
|
||||
|
||||
if (auto tbCreatedMsgId = Platform::MainWindow::TaskbarCreatedMsgId()) {
|
||||
if (const auto tbCreatedMsgId = Platform::MainWindow::TaskbarCreatedMsgId()) {
|
||||
if (msg == tbCreatedMsgId) {
|
||||
Platform::MainWindow::TaskbarCreated();
|
||||
}
|
||||
|
@ -90,15 +106,15 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
|
||||
case WM_ACTIVATE: {
|
||||
if (LOWORD(wParam) == WA_CLICKACTIVE) {
|
||||
App::wnd()->setInactivePress(true);
|
||||
_window->setInactivePress(true);
|
||||
}
|
||||
if (LOWORD(wParam) != WA_INACTIVE) {
|
||||
App::wnd()->shadowsActivate();
|
||||
_window->shadowsActivate();
|
||||
} else {
|
||||
App::wnd()->shadowsDeactivate();
|
||||
_window->shadowsDeactivate();
|
||||
}
|
||||
if (Global::started()) {
|
||||
App::wnd()->update();
|
||||
_window->update();
|
||||
}
|
||||
} return false;
|
||||
|
||||
|
@ -141,42 +157,40 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
WINDOWPLACEMENT wp;
|
||||
wp.length = sizeof(WINDOWPLACEMENT);
|
||||
if (GetWindowPlacement(hWnd, &wp) && (wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)) {
|
||||
App::wnd()->shadowsUpdate(ShadowsChange::Hidden);
|
||||
_window->shadowsUpdate(ShadowsChange::Hidden);
|
||||
} else {
|
||||
App::wnd()->shadowsUpdate(ShadowsChange::Moved | ShadowsChange::Resized, (WINDOWPOS*)lParam);
|
||||
_window->shadowsUpdate(ShadowsChange::Moved | ShadowsChange::Resized, (WINDOWPOS*)lParam);
|
||||
}
|
||||
} return false;
|
||||
|
||||
case WM_SIZE: {
|
||||
if (App::wnd()) {
|
||||
if (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED || wParam == SIZE_MINIMIZED) {
|
||||
if (wParam != SIZE_RESTORED || App::wnd()->windowState() != Qt::WindowNoState) {
|
||||
Qt::WindowState state = Qt::WindowNoState;
|
||||
if (wParam == SIZE_MAXIMIZED) {
|
||||
state = Qt::WindowMaximized;
|
||||
} else if (wParam == SIZE_MINIMIZED) {
|
||||
state = Qt::WindowMinimized;
|
||||
}
|
||||
emit App::wnd()->windowHandle()->windowStateChanged(state);
|
||||
} else {
|
||||
App::wnd()->positionUpdated();
|
||||
if (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED || wParam == SIZE_MINIMIZED) {
|
||||
if (wParam != SIZE_RESTORED || _window->windowState() != Qt::WindowNoState) {
|
||||
Qt::WindowState state = Qt::WindowNoState;
|
||||
if (wParam == SIZE_MAXIMIZED) {
|
||||
state = Qt::WindowMaximized;
|
||||
} else if (wParam == SIZE_MINIMIZED) {
|
||||
state = Qt::WindowMinimized;
|
||||
}
|
||||
App::wnd()->psUpdateMargins();
|
||||
MainWindow::ShadowsChanges changes = (wParam == SIZE_MINIMIZED || wParam == SIZE_MAXIMIZED) ? ShadowsChange::Hidden : (ShadowsChange::Resized | ShadowsChange::Shown);
|
||||
App::wnd()->shadowsUpdate(changes);
|
||||
emit _window->windowHandle()->windowStateChanged(state);
|
||||
} else {
|
||||
_window->positionUpdated();
|
||||
}
|
||||
_window->psUpdateMargins();
|
||||
MainWindow::ShadowsChanges changes = (wParam == SIZE_MINIMIZED || wParam == SIZE_MAXIMIZED) ? ShadowsChange::Hidden : (ShadowsChange::Resized | ShadowsChange::Shown);
|
||||
_window->shadowsUpdate(changes);
|
||||
}
|
||||
} return false;
|
||||
|
||||
case WM_SHOWWINDOW: {
|
||||
LONG style = GetWindowLong(hWnd, GWL_STYLE);
|
||||
auto changes = ShadowsChange::Resized | ((wParam && !(style & (WS_MAXIMIZE | WS_MINIMIZE))) ? ShadowsChange::Shown : ShadowsChange::Hidden);
|
||||
App::wnd()->shadowsUpdate(changes);
|
||||
_window->shadowsUpdate(changes);
|
||||
} return false;
|
||||
|
||||
case WM_MOVE: {
|
||||
App::wnd()->shadowsUpdate(ShadowsChange::Moved);
|
||||
App::wnd()->positionUpdated();
|
||||
_window->shadowsUpdate(ShadowsChange::Moved);
|
||||
_window->positionUpdated();
|
||||
} return false;
|
||||
|
||||
case WM_NCHITTEST: {
|
||||
|
@ -185,7 +199,7 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
POINTS p = MAKEPOINTS(lParam);
|
||||
RECT r;
|
||||
GetWindowRect(hWnd, &r);
|
||||
auto res = App::wnd()->hitTest(QPoint(p.x - r.left + App::wnd()->deltaLeft(), p.y - r.top + App::wnd()->deltaTop()));
|
||||
auto res = _window->hitTest(QPoint(p.x - r.left + _window->deltaLeft(), p.y - r.top + _window->deltaTop()));
|
||||
switch (res) {
|
||||
case Window::HitTestResult::Client:
|
||||
case Window::HitTestResult::SysButton: *result = HTCLIENT; break;
|
||||
|
@ -210,8 +224,8 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
case WM_SYSCOMMAND: {
|
||||
if (wParam == SC_MOUSEMENU) {
|
||||
POINTS p = MAKEPOINTS(lParam);
|
||||
App::wnd()->updateSystemMenu(App::wnd()->windowHandle()->windowState());
|
||||
TrackPopupMenu(App::wnd()->psMenu(), TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON, p.x, p.y, 0, hWnd, 0);
|
||||
_window->updateSystemMenu(_window->windowHandle()->windowState());
|
||||
TrackPopupMenu(_window->psMenu(), TPM_LEFTALIGN | TPM_TOPALIGN | TPM_LEFTBUTTON, p.x, p.y, 0, hWnd, 0);
|
||||
}
|
||||
} return false;
|
||||
|
||||
|
@ -219,10 +233,10 @@ bool EventFilter::mainWindowEvent(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
if (HIWORD(wParam)) return false;
|
||||
int cmd = LOWORD(wParam);
|
||||
switch (cmd) {
|
||||
case SC_CLOSE: App::wnd()->close(); return true;
|
||||
case SC_MINIMIZE: App::wnd()->setWindowState(Qt::WindowMinimized); return true;
|
||||
case SC_MAXIMIZE: App::wnd()->setWindowState(Qt::WindowMaximized); return true;
|
||||
case SC_RESTORE: App::wnd()->setWindowState(Qt::WindowNoState); return true;
|
||||
case SC_CLOSE: _window->close(); return true;
|
||||
case SC_MINIMIZE: _window->setWindowState(Qt::WindowMinimized); return true;
|
||||
case SC_MAXIMIZE: _window->setWindowState(Qt::WindowMaximized); return true;
|
||||
case SC_RESTORE: _window->setWindowState(Qt::WindowNoState); return true;
|
||||
}
|
||||
} return true;
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Platform {
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class EventFilter : public QAbstractNativeEventFilter {
|
||||
public:
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
|
||||
|
@ -23,14 +25,14 @@ public:
|
|||
_sessionLoggedOff = loggedOff;
|
||||
}
|
||||
|
||||
static EventFilter *createInstance();
|
||||
static EventFilter *getInstance();
|
||||
static void destroy();
|
||||
static EventFilter *CreateInstance(not_null<MainWindow*> window);
|
||||
static EventFilter *GetInstance();
|
||||
static void Destroy();
|
||||
|
||||
private:
|
||||
EventFilter() {
|
||||
}
|
||||
explicit EventFilter(not_null<MainWindow*> window);
|
||||
|
||||
not_null<MainWindow*> _window;
|
||||
bool _sessionLoggedOff = false;
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue