Skip to content
Draft
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
4 changes: 2 additions & 2 deletions panels/notification/osd/brightness/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

find_package(TreelandProtocols REQUIRED)
find_package(TreelandProtocols 0.6 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(WaylandClient REQUIRED IMPORTED_TARGET wayland-client)

Expand All @@ -16,7 +16,7 @@ add_library(osd-brightness SHARED
qt_generate_wayland_protocol_client_sources(osd-brightness
NO_INCLUDE_CORE_ONLY
FILES
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-output-manager-v1.xml
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-output-manager-unstable-v2.xml
)

target_link_libraries(osd-brightness PRIVATE
Expand Down
12 changes: 6 additions & 6 deletions panels/notification/osd/brightness/treelandbrightness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

#include "treelandbrightness.h"

#include "wayland-treeland-output-manager-v1-client-protocol.h"
#include "wayland-treeland-output-manager-unstable-v2-client-protocol.h"

Check warning on line 7 in panels/notification/osd/brightness/treelandbrightness.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "wayland-treeland-output-manager-unstable-v2-client-protocol.h" not found.

#include <QGuiApplication>

Check warning on line 9 in panels/notification/osd/brightness/treelandbrightness.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScreen>

Check warning on line 10 in panels/notification/osd/brightness/treelandbrightness.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

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

#include <wayland-client.h>

namespace osd {

TreelandColorControl::TreelandColorControl(struct ::treeland_output_color_control_v1 *object, QObject *parent)
TreelandColorControl::TreelandColorControl(struct ::treeland_output_picture_control_v2 *object, QObject *parent)
: QObject(parent)
, QtWayland::treeland_output_color_control_v1(object)
, QtWayland::treeland_output_picture_control_v2(object)
{
}

Expand All @@ -31,14 +31,14 @@
return m_brightness;
}

void TreelandColorControl::treeland_output_color_control_v1_brightness(wl_fixed_t brightness)
void TreelandColorControl::treeland_output_picture_control_v2_brightness(wl_fixed_t brightness)

Check warning on line 34 in panels/notification/osd/brightness/treelandbrightness.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'treeland_output_picture_control_v2_brightness' is never used.
{
m_brightness = wl_fixed_to_double(brightness);
Q_EMIT brightnessChanged(m_brightness);
}

TreelandBrightness::TreelandBrightness(QObject *parent)
: QWaylandClientExtensionTemplate<TreelandBrightness>(treeland_output_manager_v1_interface.version)
: QWaylandClientExtensionTemplate<TreelandBrightness>(treeland_output_manager_v2_interface.version)
{
setParent(parent);
connect(this, &TreelandBrightness::activeChanged, this, &TreelandBrightness::refresh);
Expand Down Expand Up @@ -76,7 +76,7 @@
return;
}

auto *raw = get_color_control(output);
auto *raw = get_picture_control(output);
if (!raw) {
return;
}
Expand Down
14 changes: 7 additions & 7 deletions panels/notification/osd/brightness/treelandbrightness.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@

#pragma once

#include "qwayland-treeland-output-manager-v1.h"
#include "qwayland-treeland-output-manager-unstable-v2.h"

Check warning on line 7 in panels/notification/osd/brightness/treelandbrightness.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "qwayland-treeland-output-manager-unstable-v2.h" not found.

#include <QObject>

Check warning on line 9 in panels/notification/osd/brightness/treelandbrightness.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QObject> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPointer>

Check warning on line 10 in panels/notification/osd/brightness/treelandbrightness.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandClient/QWaylandClientExtension>

Check warning on line 11 in panels/notification/osd/brightness/treelandbrightness.h

View workflow job for this annotation

GitHub Actions / cppcheck

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

struct wl_output;
struct treeland_output_color_control_v1;
struct treeland_output_picture_control_v2;

namespace osd {

class TreelandColorControl : public QObject, public QtWayland::treeland_output_color_control_v1
class TreelandColorControl : public QObject, public QtWayland::treeland_output_picture_control_v2
{
Q_OBJECT

public:
explicit TreelandColorControl(struct ::treeland_output_color_control_v1 *object, QObject *parent = nullptr);
explicit TreelandColorControl(struct ::treeland_output_picture_control_v2 *object, QObject *parent = nullptr);
~TreelandColorControl() override;

double brightness() const;
Expand All @@ -29,18 +29,18 @@
void brightnessChanged(double brightness);

protected:
void treeland_output_color_control_v1_brightness(wl_fixed_t brightness) override;
void treeland_output_picture_control_v2_brightness(wl_fixed_t brightness) override;

private:
double m_brightness = 0.0;
};

// Read-only Treeland brightness provider for the OSD. It binds a single
// treeland_output_color_control_v1 to the primary wl_output and caches the
// treeland_output_picture_control_v2 to the primary wl_output and caches the
// brightness reported by the compositor. It never commits brightness changes;
// dde-shortcut-tool is responsible for adjusting brightness, and this provider
// only reflects the resulting value.
class TreelandBrightness : public QWaylandClientExtensionTemplate<TreelandBrightness>, public QtWayland::treeland_output_manager_v1
class TreelandBrightness : public QWaylandClientExtensionTemplate<TreelandBrightness>, public QtWayland::treeland_output_manager_v2
{
Q_OBJECT

Expand Down
4 changes: 2 additions & 2 deletions shell/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

find_package(Dtk${DTK_VERSION_MAJOR} COMPONENTS Widget REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS Widgets Gui WaylandClient)
find_package(TreelandProtocols REQUIRED)
find_package(TreelandProtocols 0.6 REQUIRED)
pkg_check_modules(WaylandClient REQUIRED IMPORTED_TARGET wayland-client)

if (NOT DEFINED SYSTEMD_USER_UNIT_DIR)
Expand All @@ -30,7 +30,7 @@ add_executable(dde-shell

qt_generate_wayland_protocol_client_sources(dde-shell
FILES
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-output-manager-v1.xml
${TREELAND_PROTOCOLS_DATA_DIR}/treeland-output-manager-unstable-v2.xml
)

target_compile_definitions(dde-shell
Expand Down
11 changes: 6 additions & 5 deletions shell/treelandoutputwatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "treelandoutputwatcher.h"
#include "wayland-treeland-output-manager-v1-client-protocol.h"
#include "wayland-treeland-output-manager-unstable-v2-client-protocol.h"

Check warning on line 6 in shell/treelandoutputwatcher.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "wayland-treeland-output-manager-unstable-v2-client-protocol.h" not found.

#include <QGuiApplication>

Check warning on line 8 in shell/treelandoutputwatcher.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QGuiApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QScreen>

#include <qpa/qwindowsysteminterface.h>

TreelandOutputWatcher::TreelandOutputWatcher(QObject *parent)
: QWaylandClientExtensionTemplate<TreelandOutputWatcher>(treeland_output_manager_v1_interface.version)
: QWaylandClientExtensionTemplate<TreelandOutputWatcher>(treeland_output_manager_v2_interface.version)
{
setParent(parent);
}
Expand All @@ -21,13 +21,14 @@
destroy();
}

void TreelandOutputWatcher::treeland_output_manager_v1_primary_output(const QString &output_name)
void TreelandOutputWatcher::treeland_output_manager_v2_primary_output(struct ::wl_output *output)
{
if (qApp->primaryScreen()->name() == output_name)
if (!output)
return;

for (auto screen : qApp->screens()) {
if (screen->name() == output_name) {
auto *waylandScreen = screen->nativeInterface<QNativeInterface::QWaylandScreen>();
if (waylandScreen && waylandScreen->output() == output) {
QWindowSystemInterface::handlePrimaryScreenChanged(screen->handle());
return;
}
Expand Down
8 changes: 5 additions & 3 deletions shell/treelandoutputwatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

#pragma once

#include "qwayland-treeland-output-manager-v1.h"
#include "qwayland-treeland-output-manager-unstable-v2.h"
#include <QtWaylandClient/QWaylandClientExtension>

class TreelandOutputWatcher : public QWaylandClientExtensionTemplate<TreelandOutputWatcher>, public QtWayland::treeland_output_manager_v1
struct wl_output;

class TreelandOutputWatcher : public QWaylandClientExtensionTemplate<TreelandOutputWatcher>, public QtWayland::treeland_output_manager_v2
{
Q_OBJECT
public:
TreelandOutputWatcher(QObject *parent = nullptr);
~TreelandOutputWatcher();

protected:
void treeland_output_manager_v1_primary_output(const QString &output_name) override;
void treeland_output_manager_v2_primary_output(struct ::wl_output *output) override;
};
Loading