[linux] fix bug 76330

This commit is contained in:
SimplestStudio
2025-08-27 10:24:10 +03:00
parent 1e1258aa71
commit 0cad68927f
11 changed files with 52 additions and 40 deletions

View File

@ -242,7 +242,7 @@ core_linux {
}
CONFIG += link_pkgconfig
PKGCONFIG += glib-2.0 gtk+-3.0 atk gtk+-unix-print-3.0 xcb
PKGCONFIG += glib-2.0 gtk+-3.0 atk gtk+-unix-print-3.0 xcb xext
LIBS += -lX11 -lX11-xcb -lcups
cef_version_107 {

View File

@ -304,6 +304,9 @@ void Tab::paintEvent(QPaintEvent *ev)
bool Tab::eventFilter(QObject *obj, QEvent *ev)
{
if (!isEnabled())
return true;
switch (ev->type()) {
case QEvent::HoverEnter:
setProperty("hovered", true);
@ -1139,6 +1142,9 @@ void CTabBar::resizeEvent(QResizeEvent *event)
void CTabBar::wheelEvent(QWheelEvent *event)
{
if (!isEnabled())
return;
QFrame::wheelEvent(event);
if (!d->animationInProgress && d->tabArea->underMouse()) {
#ifdef DONT_USE_SIMPLE_WHEEL_SCROLL
@ -1159,6 +1165,9 @@ void CTabBar::wheelEvent(QWheelEvent *event)
bool CTabBar::eventFilter(QObject *watched, QEvent *event)
{
if (!isEnabled())
return true;
if (watched == d->tabArea) {
switch (event->type()) {
case QEvent::MouseMove: {

View File

@ -39,6 +39,7 @@
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xlib-xcb.h>
#include <X11/extensions/shape.h>
void XcbUtils::moveWindow(xcb_window_t window, int x, int y)
@ -185,3 +186,18 @@ void XcbUtils::getWindowStack(std::vector<xcb_window_t> &winStack)
XFree(win_list);
}
}
void XcbUtils::setInputEnabled(xcb_window_t window, bool enabled)
{
Display* disp = QX11Info::display();
Window wnd = window;
XRectangle rc = {0, 0, 0, 0};
if (enabled) {
XWindowAttributes attr;
XGetWindowAttributes(disp, wnd, &attr);
rc.width = attr.width;
rc.height = attr.height;
}
XShapeCombineRectangles(disp, wnd, ShapeInput, 0, 0, &rc, 1, ShapeSet, YXBanded);
XFlush(disp);
}

View File

@ -46,6 +46,7 @@ void findWindowAsync(const char *window_name, void *user_data,
uint timeout_ms,
void(*callback)(xcb_window_t, void*));
void getWindowStack(std::vector<xcb_window_t> &winStack);
void setInputEnabled(xcb_window_t window, bool enabled);
}
#endif // XCBUTILS_H

View File

@ -63,6 +63,7 @@
#include "shlobj.h"
#include "lmcons.h"
#else
# include "platform_linux/xcbutils.h"
# include <QEventLoop>
# include <QX11Info>
#include <sys/stat.h>
@ -924,47 +925,24 @@ std::wstring Utils::appUserName()
namespace WindowHelper {
#ifdef Q_OS_LINUX
CParentDisable::CParentDisable(QWidget* &parent)
CParentDisable::CParentDisable(QWidget* parent) : m_parent(parent)
{
disable(parent);
enable(false);
}
CParentDisable::~CParentDisable()
{
enable();
enable(true);
}
void CParentDisable::disable(QWidget* &parent)
void CParentDisable::enable(bool enabled)
{
if (parent) {
parent->setProperty("blocked", true);
Qt::WindowFlags flags = Qt::FramelessWindowHint;
if (!QX11Info::isCompositingManagerRunning()) {
flags |= (Qt::SubWindow | Qt::BypassWindowManagerHint);
Utils::processMoreEvents(); // Fixed Cef rendering before reopening the dialog
} else
flags |= Qt::Dialog;
m_pChild = new QWidget(parent, flags);
m_pChild->setAttribute(Qt::WA_TranslucentBackground);
if (QX11Info::isCompositingManagerRunning()) {
m_pChild->setWindowModality(Qt::ApplicationModal);
int offset = parent->isMaximized() ? 0 : 10;
m_pChild->move(parent->pos() - QPoint(offset, offset));
m_pChild->setFixedSize(parent->size() + 2 * QSize(offset, offset));
parent = m_pChild;
} else
m_pChild->setGeometry(parent->rect());
m_pChild->show();
}
}
CWindowBase *wb = dynamic_cast<CWindowBase*>(m_parent);
if (!wb) return;
void CParentDisable::enable()
{
if ( m_pChild ) {
if (m_pChild->parent())
m_pChild->parent()->setProperty("blocked", false);
delete m_pChild, m_pChild = nullptr;
}
wb->setEnabled(enabled);
WId wnd = wb->mainPanel()->winId();
XcbUtils::setInputEnabled(wnd, enabled);
}
// Linux Environment Info

View File

@ -142,13 +142,12 @@ namespace WindowHelper {
#ifdef Q_OS_LINUX
class CParentDisable
{
QWidget* m_pChild = nullptr;
QWidget* m_parent = nullptr;
public:
CParentDisable(QWidget* &parent);
CParentDisable(QWidget* parent);
~CParentDisable();
void disable(QWidget* &parent);
void enable();
void enable(bool enabled);
};
// auto check_button_state(Qt::MouseButton b) -> bool;

View File

@ -545,7 +545,8 @@ void CEditorWindow::onClickButtonHome()
void CEditorWindow::closeEvent(QCloseEvent * e)
{
AscAppManager::getInstance().closeQueue().enter(sWinTag{CLOSE_QUEUE_WIN_TYPE_EDITOR, size_t(this)});
if (isEnabled())
AscAppManager::getInstance().closeQueue().enter(sWinTag{CLOSE_QUEUE_WIN_TYPE_EDITOR, size_t(this)});
e->ignore();
}

View File

@ -284,7 +284,8 @@ void CMainWindow::onCloseEvent()
void CMainWindow::closeEvent(QCloseEvent * e)
{
AscAppManager::getInstance().closeQueue().enter(sWinTag{CLOSE_QUEUE_WIN_TYPE_MAIN, size_t(this)});
if (isEnabled())
AscAppManager::getInstance().closeQueue().enter(sWinTag{CLOSE_QUEUE_WIN_TYPE_MAIN, size_t(this)});
e->ignore();
}

View File

@ -88,7 +88,8 @@ bool CPresenterWindow::holdView(int id) const
void CPresenterWindow::closeEvent(QCloseEvent *e)
{
onCloseEvent();
if (isEnabled())
onCloseEvent();
e->ignore();
}

View File

@ -115,6 +115,11 @@ QWidget * CWindowBase::handle() const
return qobject_cast<QWidget *>(const_cast<CWindowBase*>(this));
}
QWidget * CWindowBase::mainPanel() const
{
return m_pMainPanel;
}
bool CWindowBase::isCustomWindowStyle()
{
return pimpl->is_custom_window_;

View File

@ -71,6 +71,7 @@ public:
static QRect startRect(const QRect &rc, double &dpi);
static QSize expectedContentSize(const QRect &rc, bool extended = false);
QWidget * handle() const;
QWidget * mainPanel() const;
bool isCustomWindowStyle();
void updateScaling(bool resize = true);
virtual void adjustGeometry() = 0;