Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Build-Depends:
libxcb-res0-dev,
libxcb-util-dev,
libxcb1-dev,
libxcb-shape0-dev,
libxtst-dev,
libyaml-cpp-dev,
qml6-module-qtquick-controls2-styles-chameleon,
Expand Down
2 changes: 1 addition & 1 deletion frame/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ target_link_directories(dde-shell-frame INTERFACE

if (BUILD_WITH_X11)
target_compile_definitions(dde-shell-frame PRIVATE BUILD_WITH_X11)
pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb-ewmh xcb-icccm xtst x11)
pkg_check_modules(XCB REQUIRED IMPORTED_TARGET xcb-ewmh xcb-icccm xtst xcb-shape x11)
target_sources(dde-shell-frame PRIVATE layershell/x11dlayershellemulation.h layershell/x11dlayershellemulation.cpp)
target_link_libraries(dde-shell-frame PRIVATE PkgConfig::XCB)
endif(BUILD_WITH_X11)
Expand Down
24 changes: 24 additions & 0 deletions frame/layershell/dlayershellwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
int preferredWidth = -1;
int preferredHeight = -1;
bool closeOnDismissed = true;
QRegion inputRegion;
};

void DLayerShellWindow::setAnchors(DLayerShellWindow::Anchors anchors)

Check warning on line 49 in frame/layershell/dlayershellwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setAnchors' is never used.
{
if (anchors != d->anchors) {
d->anchors = anchors;
Expand Down Expand Up @@ -192,6 +193,29 @@
return d->preferredHeight;
}

void DLayerShellWindow::setInputRegion(const QRegion &region)
{
if (d->inputRegion != region) {
d->inputRegion = region;
Q_EMIT inputRegionChanged();
}
}

void DLayerShellWindow::resetInputRegion()

Check warning on line 204 in frame/layershell/dlayershellwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'resetInputRegion' is never used.
{
setInputRegion(QRegion());
}

QRegion DLayerShellWindow::inputRegion() const
{
return d->inputRegion;
}

void DLayerShellWindow::setInputRegionRect(int x, int y, int width, int height)
{
setInputRegion(QRegion(x, y, width, height));
}

bool DLayerShellWindow::closeOnDismissed() const
{
return d->closeOnDismissed;
Expand Down
8 changes: 8 additions & 0 deletions frame/layershell/dlayershellwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
Q_PROPERTY(int preferredWidth READ preferredWidth WRITE setPreferredWidth RESET resetPreferredWidth NOTIFY geometryHintsChanged)
Q_PROPERTY(int preferredHeight READ preferredHeight WRITE setPreferredHeight RESET resetPreferredHeight NOTIFY geometryHintsChanged)
Q_PROPERTY(QRegion inputRegion READ inputRegion WRITE setInputRegion RESET resetInputRegion NOTIFY inputRegionChanged)

Q_PROPERTY(bool closeOnDismissed READ closeOnDismissed WRITE setCloseOnDismissed)

Expand Down Expand Up @@ -121,6 +122,12 @@
void resetPreferredHeight();
int preferredHeight() const;

void setInputRegion(const QRegion &region);
void resetInputRegion();
QRegion inputRegion() const;

Q_INVOKABLE void setInputRegionRect(int x, int y, int width, int height);

/**
* Sets a string based identifier for this window.
* This may be used by a compositor to determine stacking
Expand Down Expand Up @@ -156,9 +163,10 @@
void layerChanged();
void scopeChanged();
void geometryHintsChanged();
void inputRegionChanged();

private:
DLayerShellWindow(QWindow* window);

Check warning on line 169 in frame/layershell/dlayershellwindow.h

View workflow job for this annotation

GitHub Actions / cppcheck

Class 'DLayerShellWindow' has a constructor with 1 argument that is not explicit. Such, so called "Converting constructors", should in general be explicit for type safety reasons as that prevents unintended implicit conversions.
QScopedPointer<DLayerShellWindowPrivate> d;
};

Expand Down
9 changes: 8 additions & 1 deletion frame/layershell/qwaylandlayershellsurface.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -75,6 +75,13 @@ QWaylandLayerShellSurface::QWaylandLayerShellSurface(QtWayland::zwlr_layer_shell
window->waylandSurface()->commit();
});

auto applyInputRegion = [this, window]() {
window->window()->setMask(m_dlayerShellWindow->inputRegion());
window->waylandSurface()->commit();
};

connect(m_dlayerShellWindow, &DLayerShellWindow::inputRegionChanged, this, applyInputRegion);

calcAndSetRequestSize(window->surfaceSize());

if (m_requestSize.isValid()) {
Expand Down
39 changes: 39 additions & 0 deletions frame/layershell/x11dlayershellemulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformwindow_p.h>

#include <xcb/xcb.h>

Check warning on line 17 in frame/layershell/x11dlayershellemulation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <xcb/xcb.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <xcb/xcb_ewmh.h>

Check warning on line 18 in frame/layershell/x11dlayershellemulation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <xcb/xcb_ewmh.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <xcb/xcb_icccm.h>

Check warning on line 19 in frame/layershell/x11dlayershellemulation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <xcb/xcb_icccm.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <xcb/shape.h>

Check warning on line 20 in frame/layershell/x11dlayershellemulation.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <xcb/shape.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

DS_BEGIN_NAMESPACE

Expand Down Expand Up @@ -71,6 +72,9 @@
onScopeChanged();
connect(m_dlayerShellWindow, &DLayerShellWindow::scopeChanged, this, &LayerShellEmulation::onScopeChanged);

onInputRegionChanged();
connect(m_dlayerShellWindow, &DLayerShellWindow::inputRegionChanged, this, &LayerShellEmulation::onInputRegionChanged);

// connect(m_dlayerShellWindow, &DS_NAMESPACE::DLayerShellWindow::keyboardInteractivityChanged, this, &LayerShellEmulation::onKeyboardInteractivityChanged);
}

Expand Down Expand Up @@ -321,6 +325,41 @@
qCDebug(layershell) << "Set WM_CLASS for window" << m_window->winId() << " wm_class:" << wmClassData;
}

void LayerShellEmulation::onInputRegionChanged()
{
auto *x11Application = qGuiApp->nativeInterface<QNativeInterface::QX11Application>();
if (!x11Application || !m_window->winId() || !m_dlayerShellWindow) {
return;
}

if (m_dlayerShellWindow->inputRegion().isNull()) {
// Reset input region (no shape constraint)
xcb_shape_mask(x11Application->connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, m_window->winId(), 0, 0, XCB_NONE);
xcb_flush(x11Application->connection());
return;
}

QRegion region = m_dlayerShellWindow->inputRegion();
qreal scaleFactor = qGuiApp->devicePixelRatio();

QVector<xcb_rectangle_t> rects;
for (const QRect &r : region) {
xcb_rectangle_t rect;
rect.x = r.x() * scaleFactor;
rect.y = r.y() * scaleFactor;
rect.width = r.width() * scaleFactor;
rect.height = r.height() * scaleFactor;
rects.append(rect);
}

// Set the input shape via XCB
// If rects vector is empty, the window will become completely transparent to input clicks (unclickable)
xcb_shape_rectangles(x11Application->connection(), XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT,
XCB_CLIP_ORDERING_UNSORTED, m_window->winId(), 0, 0,
rects.size(), rects.data());
xcb_flush(x11Application->connection());
}

// void X11Emulation::onKeyboardInteractivityChanged()
// {
// // kwin no implentation on wayland
Expand Down
3 changes: 2 additions & 1 deletion frame/layershell/x11dlayershellemulation.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -28,6 +28,7 @@ private slots:
void onPositionChanged();
void onExclusionZoneChanged();
void onScopeChanged();
void onInputRegionChanged();
// void onKeyboardInteractivityChanged();

private:
Expand Down
13 changes: 0 additions & 13 deletions panels/notification/bubble/bubbleitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,19 +282,6 @@ void BubbleItem::updateActions()
m_actions = array;
}

int BubbleItem::level() const
{
return m_level;
}

void BubbleItem::setLevel(int level)
{
if (m_level == level)
return;

m_level = level;
emit levelChanged();
}

QString BubbleItem::timeTip() const
{
Expand Down
6 changes: 1 addition & 5 deletions panels/notification/bubble/bubbleitem.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -36,11 +36,9 @@
qint64 ctime() const;

QString defaultAction() const;
QVariantList actions() const;

Check warning on line 39 in panels/notification/bubble/bubbleitem.h

View workflow job for this annotation

GitHub Actions / cppcheck

Local variable 'actions' shadows outer function
void updateActions();

int level() const;
void setLevel(int level);

QString timeTip() const;
void setTimeTip(const QString &timeTip);
Expand All @@ -51,15 +49,13 @@
bool isValid() const;

signals:
void levelChanged();
void timeTipChanged();

private:
QString displayText() const;

private:
NotifyEntity m_entity;
int m_level = 0;
int m_urgency = NotifyEntity::Normal;
QString m_timeTip;
bool m_enablePreview = true;
Expand Down
Loading
Loading