-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: fix reported display resolutions when fractionally scaled
Qt appears to have no way to retrieve the pixel size sent by wayland, as it overrides it with the logical size and will not return the physical one.
- Loading branch information
Showing
5 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "WaylandScreen.hpp" | ||
|
||
#include <QtWaylandClient/private/qwayland-wayland.h> | ||
#include <QtWaylandClient/private/qwaylanddisplay_p.h> | ||
#include <QtWaylandClient/private/qwaylandintegration_p.h> | ||
#include <cstdint> | ||
#include <qcontainerfwd.h> | ||
#include <qsize.h> | ||
#include <qstringliteral.h> | ||
#include <qtclasshelpermacros.h> | ||
#include <vector> | ||
|
||
using namespace QtWaylandClient; | ||
|
||
class CWaylandScreen : public QtWayland::wl_output { | ||
public: | ||
explicit CWaylandScreen(QWaylandDisplay* display, uint32_t version, uint32_t id); | ||
Q_DISABLE_COPY_MOVE(CWaylandScreen); | ||
SWaylandScreenInfo info; | ||
|
||
protected: | ||
void output_mode(uint32_t flags, int32_t width, int32_t height, int32_t refresh) override; | ||
void output_name(const QString& name) override; | ||
}; | ||
|
||
std::vector<SWaylandScreenInfo> SWaylandScreenInfo::enumerateScreens() { | ||
auto* display = QWaylandIntegration::instance()->display(); | ||
|
||
std::vector<CWaylandScreen*> screens; | ||
for (const auto& global : display->globals()) { | ||
if (global.interface == QStringLiteral("wl_output")) { | ||
screens.emplace_back(new CWaylandScreen(display, global.version, global.id)); | ||
} | ||
} | ||
|
||
display->forceRoundTrip(); | ||
|
||
std::vector<SWaylandScreenInfo> info; | ||
for (auto* screen : screens) { | ||
info.push_back(screen->info); | ||
delete screen; | ||
} | ||
|
||
return info; | ||
} | ||
|
||
CWaylandScreen::CWaylandScreen(QWaylandDisplay* display, uint32_t version, uint32_t id) : QtWayland::wl_output(display->wl_registry(), id, 4u) {} | ||
|
||
void CWaylandScreen::output_mode(uint32_t flags, int width, int height, int refresh) { | ||
info.pixelSize = QSize(width, height); | ||
} | ||
|
||
void CWaylandScreen::output_name(const QString& name) { | ||
info.name = name; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
#include <qcontainerfwd.h> | ||
#include <qsize.h> | ||
#include <qstring.h> | ||
#include <qcontainerfwd.h> | ||
#include <vector> | ||
|
||
struct SWaylandScreenInfo { | ||
QString name; | ||
QSize pixelSize; | ||
|
||
static std::vector<SWaylandScreenInfo> enumerateScreens(); | ||
}; |