Skip to content

Commit

Permalink
Merge branch 'clang16' into 'master'
Browse files Browse the repository at this point in the history
Adapt to Clang-Tidy 16 and use GSL

See merge request kwinft/wrapland!142
  • Loading branch information
romangg committed Sep 11, 2023
2 parents 77cbb96 + 3065b33 commit 048a451
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 49 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ set_package_properties(WaylandProtocols PROPERTIES TYPE REQUIRED)
find_package(EGL)
set_package_properties(EGL PROPERTIES TYPE REQUIRED)

find_package(Microsoft.GSL)
set_package_properties(Microsoft.GSL PROPERTIES TYPE REQUIRED)

include(KDEInstallDirs)
include(CheckIncludeFile)
include(CTest)
Expand Down
1 change: 1 addition & 0 deletions WraplandConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

include(CMakeFindDependencyMacro)
find_dependency(Qt6Gui @REQUIRED_QT_VERSION@)
find_dependency(Microsoft.GSL)

include("${CMAKE_CURRENT_LIST_DIR}/WraplandTargets.cmake")
1 change: 1 addition & 0 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ target_include_directories(WraplandServer

target_link_libraries(WraplandServer
PUBLIC
Microsoft.GSL::GSL
Qt6::Gui
PRIVATE
Wayland::Server
Expand Down
14 changes: 7 additions & 7 deletions server/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ output_transform transform_to_output(wl_output_transform transform)
}

output::Private::Private(output_metadata metadata, output_manager& manager, output* q_ptr)
: manager{manager}
: manager{&manager}
, q_ptr{q_ptr}
{
if (metadata.description.empty()) {
Expand All @@ -93,24 +93,24 @@ output::Private::Private(output_metadata metadata, output_manager& manager, outp
published.meta = pending.meta;

manager.outputs.push_back(q_ptr);
QObject::connect(&manager.display, &Display::destroyed, q_ptr, [this] {
QObject::connect(manager.display, &Display::destroyed, q_ptr, [this] {
xdg_output.reset();
wayland_output.reset();
});
}

output::Private::~Private()
{
remove_all(manager.outputs, q_ptr);
remove_all(manager->outputs, q_ptr);
}

void output::Private::done()
{
if (published.state.enabled != pending.state.enabled) {
if (pending.state.enabled) {
wayland_output.reset(new WlOutput(q_ptr, &manager.display));
if (manager.xdg_manager) {
xdg_output.reset(new XdgOutput(q_ptr, &manager.display));
wayland_output.reset(new WlOutput(q_ptr, manager->display));
if (manager->xdg_manager) {
xdg_output.reset(new XdgOutput(q_ptr, manager->display));
}
} else {
wayland_output.reset();
Expand All @@ -127,7 +127,7 @@ void output::Private::done()
}
}
}
if (auto& wlr_man = manager.wlr_manager_v1) {
if (auto& wlr_man = manager->wlr_manager_v1) {
if (wlr_head_v1) {
wlr_head_v1->broadcast();
} else {
Expand Down
6 changes: 3 additions & 3 deletions server/output_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Wrapland::Server
{

output_manager::output_manager(Display& display)
: display{display}
: display{&display}
{
}

Expand All @@ -36,14 +36,14 @@ void output_manager::commit_changes() const
XdgOutputManager& output_manager::create_xdg_manager()
{
assert(!xdg_manager);
xdg_manager = std::make_unique<XdgOutputManager>(&display);
xdg_manager = std::make_unique<XdgOutputManager>(display);
return *xdg_manager;
}

wlr_output_manager_v1& output_manager::create_wlr_manager_v1()
{
assert(!wlr_manager_v1);
wlr_manager_v1 = std::make_unique<wlr_output_manager_v1>(&display);
wlr_manager_v1 = std::make_unique<wlr_output_manager_v1>(display);
return *wlr_manager_v1;
}

Expand Down
3 changes: 2 additions & 1 deletion server/output_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <Wrapland/Server/wraplandserver_export.h>

#include <gsl/pointers>
#include <memory>
#include <vector>

Expand All @@ -29,7 +30,7 @@ class WRAPLANDSERVER_EXPORT output_manager
XdgOutputManager& create_xdg_manager();
wlr_output_manager_v1& create_wlr_manager_v1();

Display& display;
gsl::not_null<Display*> display;
std::vector<output*> outputs;

std::unique_ptr<XdgOutputManager> xdg_manager;
Expand Down
3 changes: 2 additions & 1 deletion server/output_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.

#include "output.h"

#include <gsl/pointers>
#include <wayland-server.h>

namespace Wrapland::Server
Expand Down Expand Up @@ -56,7 +57,7 @@ class output::Private

static int32_t get_mode_flags(output_mode const& mode, output_state const& state);

output_manager& manager;
gsl::not_null<output_manager*> manager;

int connector_id{0};
std::vector<output_mode> modes;
Expand Down
2 changes: 1 addition & 1 deletion server/plasma_virtual_desktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class WRAPLANDSERVER_EXPORT PlasmaVirtualDesktop : public QObject
friend class PlasmaVirtualDesktopManager;

class Private;
const std::unique_ptr<Private> d_ptr;
std::unique_ptr<Private> d_ptr;
};

}
2 changes: 1 addition & 1 deletion server/plasma_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class WRAPLANDSERVER_EXPORT PlasmaWindow : public QObject
explicit PlasmaWindow(PlasmaWindowManager* manager);

class Private;
const std::unique_ptr<Private> d_ptr;
std::unique_ptr<Private> d_ptr;
};

}
Expand Down
7 changes: 6 additions & 1 deletion server/text_input_v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ uint32_t convert_content_hints(text_input_v3_content_hints hints)
return ret;
}

static text_input_v3_content_purpose convert_content_purpose(uint32_t purpose)
namespace
{

text_input_v3_content_purpose convert_content_purpose(uint32_t purpose)
{
auto const wlPurpose = static_cast<zwp_text_input_v3_content_purpose>(purpose);

Expand Down Expand Up @@ -130,6 +133,8 @@ static text_input_v3_content_purpose convert_content_purpose(uint32_t purpose)
}
}

}

uint32_t convert_content_purpose(text_input_v3_content_purpose purpose)
{
switch (purpose) {
Expand Down
18 changes: 7 additions & 11 deletions server/wlr_output_configuration_head_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ QSize estimate_logical_size(output_state const& state, double scale)
wlr_output_configuration_head_v1::Private::Private(Client* client,
uint32_t version,
uint32_t id,
wlr_output_configuration_v1& configuration,
wlr_output_head_v1_res& head,
wlr_output_configuration_head_v1& q_ptr)
: Wayland::Resource<wlr_output_configuration_head_v1>(
Expand All @@ -57,9 +56,8 @@ wlr_output_configuration_head_v1::Private::Private(Client* client,
&zwlr_output_configuration_head_v1_interface,
&s_interface,
&q_ptr)
, state{head.d_ptr->head->output.d_ptr->published.state}
, state{head.d_ptr->head->output->d_ptr->published.state}
, scale{estimate_scale(state)}
, configuration{configuration}
, head{&head}
{
}
Expand Down Expand Up @@ -146,21 +144,19 @@ void wlr_output_configuration_head_v1::Private::set_adaptive_sync_callback(wl_cl
priv->state.adaptive_sync = wlState == ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED;
}

wlr_output_configuration_head_v1::wlr_output_configuration_head_v1(
Client* client,
uint32_t version,
uint32_t id,
wlr_output_configuration_v1& configuration,
wlr_output_head_v1_res& head)
: d_ptr{new Private(client, version, id, configuration, head, *this)}
wlr_output_configuration_head_v1::wlr_output_configuration_head_v1(Client* client,
uint32_t version,
uint32_t id,
wlr_output_head_v1_res& head)
: d_ptr{new Private(client, version, id, head, *this)}
{
}

wlr_output_configuration_head_v1::~wlr_output_configuration_head_v1() = default;

output& wlr_output_configuration_head_v1::get_output() const
{
return d_ptr->head->d_ptr->head->output;
return *d_ptr->head->d_ptr->head->output;
}

output_state const& wlr_output_configuration_head_v1::get_state() const
Expand Down
1 change: 0 additions & 1 deletion server/wlr_output_configuration_head_v1.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class WRAPLANDSERVER_EXPORT wlr_output_configuration_head_v1 : public QObject
wlr_output_configuration_head_v1(Client* client,
uint32_t version,
uint32_t id,
wlr_output_configuration_v1& configuration,
wlr_output_head_v1_res& head);
friend class wlr_output_configuration_v1_res;

Expand Down
3 changes: 0 additions & 3 deletions server/wlr_output_configuration_head_v1_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ class wlr_output_configuration_head_v1::Private
Private(Client* client,
uint32_t version,
uint32_t id,
wlr_output_configuration_v1& configuration,
wlr_output_head_v1_res& head,
wlr_output_configuration_head_v1& q_ptr);

output_state state;
double scale;

wlr_output_configuration_v1& configuration;
wlr_output_head_v1_res* head;

private:
Expand Down
4 changes: 2 additions & 2 deletions server/wlr_output_configuration_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void wlr_output_configuration_v1_res::Private::enable_head_callback(wl_client* /
return;
}

priv->enabled_heads.push_back(new wlr_output_configuration_head_v1(
priv->client->handle, priv->version, id, *priv->front, *head));
priv->enabled_heads.push_back(
new wlr_output_configuration_head_v1(priv->client->handle, priv->version, id, *head));
}

void wlr_output_configuration_v1_res::Private::disable_head_callback(wl_client* /*wlClient*/,
Expand Down
30 changes: 15 additions & 15 deletions server/wlr_output_head_v1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ double estimate_scale(output_state const& data)
}

wlr_output_head_v1::wlr_output_head_v1(Server::output& output, wlr_output_manager_v1& manager)
: output{output}
, manager{manager}
: output{&output}
, manager{&manager}
{
manager.d_ptr->add_head(*this);
}
Expand All @@ -40,8 +40,8 @@ wlr_output_head_v1::~wlr_output_head_v1()
res->d_ptr->head = nullptr;
}

manager.d_ptr->changed = true;
remove_all(manager.d_ptr->heads, this);
manager->d_ptr->changed = true;
remove_all(manager->d_ptr->heads, this);
}

wlr_output_head_v1_res* wlr_output_head_v1::add_bind(wlr_output_manager_v1_bind& bind)
Expand All @@ -50,27 +50,27 @@ wlr_output_head_v1_res* wlr_output_head_v1::add_bind(wlr_output_manager_v1_bind&
bind.send<zwlr_output_manager_v1_send_head>(res->d_ptr->resource);
resources.push_back(res);

res->send_static_data(output.d_ptr->pending.meta);
res->send_static_data(output->d_ptr->pending.meta);

for (auto&& mode : output.d_ptr->modes) {
for (auto&& mode : output->d_ptr->modes) {
res->add_mode(*new wlr_output_mode_v1(bind.client->handle, bind.version, mode));
}

res->send_mutable_data(output.d_ptr->pending.state);
res->send_mutable_data(output->d_ptr->pending.state);

return res;
}

void wlr_output_head_v1::broadcast()
{
auto const published = output.d_ptr->published;
auto const pending = output.d_ptr->pending;
auto const published = output->d_ptr->published;
auto const pending = output->d_ptr->pending;

if (published.state.enabled != pending.state.enabled) {
for (auto res : resources) {
res->send_enabled(pending.state.enabled);
}
manager.d_ptr->changed = true;
manager->d_ptr->changed = true;
}

if (!pending.state.enabled) {
Expand All @@ -82,22 +82,22 @@ void wlr_output_head_v1::broadcast()
for (auto res : resources) {
res->send_current_mode(pending.state.mode);
}
manager.d_ptr->changed = true;
manager->d_ptr->changed = true;
}

if (published.state.geometry.topLeft() != pending.state.geometry.topLeft()
|| !published.state.enabled) {
for (auto res : resources) {
res->send_position(pending.state.geometry.topLeft().toPoint());
}
manager.d_ptr->changed = true;
manager->d_ptr->changed = true;
}

if (published.state.transform != pending.state.transform || !published.state.enabled) {
for (auto res : resources) {
res->send_transform(pending.state.transform);
}
manager.d_ptr->changed = true;
manager->d_ptr->changed = true;
}

if (auto scale = estimate_scale(pending.state);
Expand All @@ -106,14 +106,14 @@ void wlr_output_head_v1::broadcast()
res->send_scale(scale);
}
current_scale = scale;
manager.d_ptr->changed = true;
manager->d_ptr->changed = true;
}

if (published.state.adaptive_sync != pending.state.adaptive_sync || !published.state.enabled) {
for (auto res : resources) {
res->send_adaptive_sync(pending.state.adaptive_sync);
}
manager.d_ptr->changed = true;
manager->d_ptr->changed = true;
}
}

Expand Down
5 changes: 3 additions & 2 deletions server/wlr_output_head_v1_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "wayland-wlr-output-management-v1-server-protocol.h"

#include <QObject>
#include <gsl/pointers>
#include <memory>

namespace Wrapland::Server
Expand All @@ -33,9 +34,9 @@ class wlr_output_head_v1 : public QObject
wlr_output_head_v1_res* add_bind(wlr_output_manager_v1_bind& bind);
void broadcast();

Server::output& output;
gsl::not_null<Server::output*> output;
std::vector<wlr_output_head_v1_res*> resources;
wlr_output_manager_v1& manager;
gsl::not_null<wlr_output_manager_v1*> manager;

double current_scale{1.};
};
Expand Down

0 comments on commit 048a451

Please sign in to comment.