Skip to content

Commit

Permalink
output-management: move to new impl
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed May 3, 2024
1 parent d5bf153 commit 2fd5525
Show file tree
Hide file tree
Showing 16 changed files with 1,383 additions and 136 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pkg_check_modules(deps REQUIRED IMPORTED_TARGET
wayland-server wayland-client wayland-cursor wayland-protocols
cairo pango pangocairo pixman-1
libdrm libinput hwdata libseat libdisplay-info libliftoff libudev gbm
hyprwayland-scanner>=0.3.3 hyprlang>=0.3.2 hyprcursor>=0.1.7
hyprwayland-scanner>=0.3.4 hyprlang>=0.3.2 hyprcursor>=0.1.7
)

file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp")
Expand Down Expand Up @@ -264,6 +264,7 @@ protocolNew("protocols/wlr-output-power-management-unstable-v1.xml" "wlr-output-
protocolNew("protocols/virtual-keyboard-unstable-v1.xml" "virtual-keyboard-unstable-v1" true)
protocolNew("protocols/wlr-virtual-pointer-unstable-v1.xml" "wlr-virtual-pointer-unstable-v1" true)
protocolNew("protocols/input-method-unstable-v2.xml" "input-method-unstable-v2" true)
protocolNew("protocols/wlr-output-management-unstable-v1.xml" "wlr-output-management-unstable-v1" true)
protocolNew("staging/tearing-control/tearing-control-v1.xml" "tearing-control-v1" false)
protocolNew("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false)
protocolNew("unstable/xdg-output/xdg-output-unstable-v1.xml" "xdg-output-unstable-v1" false)
Expand Down
1 change: 1 addition & 0 deletions protocols/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ new_protocols = [
['input-method-unstable-v2.xml'],
['virtual-keyboard-unstable-v1.xml'],
['wlr-virtual-pointer-unstable-v1.xml'],
['wlr-output-management-unstable-v1.xml'],
[wl_protocol_dir, 'staging/tearing-control/tearing-control-v1.xml'],
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
Expand Down
601 changes: 601 additions & 0 deletions protocols/wlr-output-management-unstable-v1.xml

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ void CCompositor::initServer() {
m_sWLRServerDecoMgr = wlr_server_decoration_manager_create(m_sWLDisplay);
wlr_server_decoration_manager_set_default_mode(m_sWLRServerDecoMgr, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);

m_sWLROutputMgr = wlr_output_manager_v1_create(m_sWLDisplay);

m_sWRLDRMLeaseMgr = wlr_drm_lease_v1_manager_create(m_sWLDisplay, m_sWLRBackend);
if (!m_sWRLDRMLeaseMgr) {
Debug::log(INFO, "Failed to create wlr_drm_lease_v1_manager");
Expand Down Expand Up @@ -300,9 +298,6 @@ void CCompositor::initAllSignals() {
addWLSignal(&m_sSeat.seat->events.request_set_selection, &Events::listen_requestSetSel, &m_sSeat, "Seat");
addWLSignal(&m_sSeat.seat->events.request_set_primary_selection, &Events::listen_requestSetPrimarySel, &m_sSeat, "Seat");
addWLSignal(&m_sWLRLayerShell->events.new_surface, &Events::listen_newLayerSurface, m_sWLRLayerShell, "LayerShell");
addWLSignal(&m_sWLROutputLayout->events.change, &Events::listen_change, m_sWLROutputLayout, "OutputLayout");
addWLSignal(&m_sWLROutputMgr->events.apply, &Events::listen_outputMgrApply, m_sWLROutputMgr, "OutputMgr");
addWLSignal(&m_sWLROutputMgr->events.test, &Events::listen_outputMgrTest, m_sWLROutputMgr, "OutputMgr");
addWLSignal(&m_sWLRRenderer->events.destroy, &Events::listen_RendererDestroy, m_sWLRRenderer, "WLRRenderer");

if (m_sWRLDRMLeaseMgr)
Expand Down Expand Up @@ -340,9 +335,6 @@ void CCompositor::removeAllSignals() {
removeWLSignal(&Events::listen_requestSetSel);
removeWLSignal(&Events::listen_requestSetPrimarySel);
removeWLSignal(&Events::listen_newLayerSurface);
removeWLSignal(&Events::listen_change);
removeWLSignal(&Events::listen_outputMgrApply);
removeWLSignal(&Events::listen_outputMgrTest);
removeWLSignal(&Events::listen_RendererDestroy);

if (m_sWRLDRMLeaseMgr)
Expand Down
1 change: 0 additions & 1 deletion src/Compositor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class CCompositor {
wlr_layer_shell_v1* m_sWLRLayerShell;
wlr_xdg_shell* m_sWLRXDGShell;
wlr_cursor* m_sWLRCursor;
wlr_output_manager_v1* m_sWLROutputMgr;
wlr_presentation* m_sWLRPresentation;
wlr_egl* m_sWLREGL;
int m_iDRMFD;
Expand Down
7 changes: 6 additions & 1 deletion src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <fstream>
#include <iostream>
#include <sstream>
#include <ranges>

extern "C" char** environ;

Expand Down Expand Up @@ -954,7 +955,7 @@ std::string CConfigManager::getDeviceString(const std::string& dev, const std::s
}

SMonitorRule CConfigManager::getMonitorRuleFor(const CMonitor& PMONITOR) {
for (auto& r : m_dMonitorRules) {
for (auto& r : m_dMonitorRules | std::views::reverse) {
if (PMONITOR.matchesStaticSelector(r.name)) {
return r;
}
Expand Down Expand Up @@ -1236,6 +1237,10 @@ void CConfigManager::dispatchExecOnce() {
g_pCompositor->performUserChecks();
}

void CConfigManager::appendMonitorRule(const SMonitorRule& r) {
m_dMonitorRules.emplace_back(r);
}

void CConfigManager::performMonitorReload() {

bool overAgain = false;
Expand Down
1 change: 1 addition & 0 deletions src/config/ConfigManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class CConfigManager {
void dispatchExecOnce();

void performMonitorReload();
void appendMonitorRule(const SMonitorRule&);
bool m_bWantsMonitorReload = false;
bool m_bForceReload = false;
bool m_bNoMonitorReload = false;
Expand Down
4 changes: 0 additions & 4 deletions src/events/Events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ namespace Events {
LISTENER(requestSetSel);
LISTENER(requestSetPrimarySel);

// outputMgr
LISTENER(outputMgrApply);
LISTENER(outputMgrTest);

// Monitor part 2 the sequel
DYNLISTENFUNC(monitorFrame);
DYNLISTENFUNC(monitorDestroy);
Expand Down
10 changes: 0 additions & 10 deletions src/events/Misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
// //
// ------------------------------ //

void Events::listener_outputMgrApply(wl_listener* listener, void* data) {
const auto CONFIG = (wlr_output_configuration_v1*)data;
g_pHyprRenderer->outputMgrApplyTest(CONFIG, false);
}

void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
const auto CONFIG = (wlr_output_configuration_v1*)data;
g_pHyprRenderer->outputMgrApplyTest(CONFIG, true);
}

void Events::listener_leaseRequest(wl_listener* listener, void* data) {
const auto REQUEST = (wlr_drm_lease_request_v1*)data;
struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST);
Expand Down
44 changes: 0 additions & 44 deletions src/events/Monitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,6 @@
// //
// --------------------------------------------------------- //

void Events::listener_change(wl_listener* listener, void* data) {
// layout got changed, let's update monitors.
const auto CONFIG = wlr_output_configuration_v1_create();

if (!CONFIG)
return;

for (auto& m : g_pCompositor->m_vRealMonitors) {
if (!m->output)
continue;

if (g_pCompositor->m_pUnsafeOutput == m.get())
continue;

const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m->output);

CBox BOX;
wlr_output_layout_get_box(g_pCompositor->m_sWLROutputLayout, m->output, BOX.pWlr());
BOX.applyFromWlr();

//m->vecSize.x = BOX.width;
// m->vecSize.y = BOX.height;
m->vecPosition.x = BOX.x;
m->vecPosition.y = BOX.y;

CONFIGHEAD->state.enabled = m->output->enabled;
CONFIGHEAD->state.mode = m->output->current_mode;
if (!m->output->current_mode) {
CONFIGHEAD->state.custom_mode = {
m->output->width,
m->output->height,
m->output->refresh,
};
}
CONFIGHEAD->state.x = m->vecPosition.x;
CONFIGHEAD->state.y = m->vecPosition.y;
CONFIGHEAD->state.transform = m->transform;
CONFIGHEAD->state.scale = m->scale;
CONFIGHEAD->state.adaptive_sync_enabled = m->vrrActive;
}

wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG);
}

static void checkDefaultCursorWarp(std::shared_ptr<CMonitor>* PNEWMONITORWRAP, std::string monitorName) {
const auto PNEWMONITOR = PNEWMONITORWRAP->get();

Expand Down
1 change: 1 addition & 0 deletions src/helpers/Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class CMonitor {
float xwaylandScale = 1.f;
std::array<float, 9> projMatrix = {0};
std::optional<Vector2D> forceSize;
wlr_output_mode* currentMode = nullptr;

bool dpmsStatus = true;
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
Expand Down
2 changes: 2 additions & 0 deletions src/managers/ProtocolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "../protocols/InputMethodV2.hpp"
#include "../protocols/VirtualKeyboard.hpp"
#include "../protocols/VirtualPointer.hpp"
#include "../protocols/OutputManagement.hpp"

CProtocolManager::CProtocolManager() {

Expand All @@ -47,6 +48,7 @@ CProtocolManager::CProtocolManager() {
PROTO::ime = std::make_unique<CInputMethodV2Protocol>(&zwp_input_method_manager_v2_interface, 1, "IMEv2");
PROTO::virtualKeyboard = std::make_unique<CVirtualKeyboardProtocol>(&zwp_virtual_keyboard_manager_v1_interface, 1, "VirtualKeyboard");
PROTO::virtualPointer = std::make_unique<CVirtualPointerProtocol>(&zwlr_virtual_pointer_manager_v1_interface, 2, "VirtualPointer");
PROTO::outputManagement = std::make_unique<COutputManagementProtocol>(&zwlr_output_manager_v1_interface, 4, "OutputManagement");

// Old protocol implementations.
// TODO: rewrite them to use hyprwayland-scanner.
Expand Down
Loading

0 comments on commit 2fd5525

Please sign in to comment.