Skip to content

Commit

Permalink
protocols: move screencopy and toplevel export to hyprwayland-scanner (
Browse files Browse the repository at this point in the history
…#7065)

* move screencopy and toplevel export to hyprwayland-scanner

* oops
  • Loading branch information
ikalco authored Jul 27, 2024
1 parent 963816b commit ec672b1
Show file tree
Hide file tree
Showing 11 changed files with 665 additions and 768 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,16 @@ endfunction()
target_link_libraries(Hyprland OpenGL::EGL OpenGL::GL Threads::Threads
libudis86 uuid)

protocol("protocols/wlr-screencopy-unstable-v1.xml"
"wlr-screencopy-unstable-v1" true)
protocol(
"subprojects/hyprland-protocols/protocols/hyprland-global-shortcuts-v1.xml"
"hyprland-global-shortcuts-v1" true)

protocol(
"subprojects/hyprland-protocols/protocols/hyprland-toplevel-export-v1.xml"
"hyprland-toplevel-export-v1" true)
protocol("unstable/text-input/text-input-unstable-v1.xml"
"text-input-unstable-v1" false)
"unstable/text-input/text-input-unstable-v1.xml"
"text-input-unstable-v1" false)

protocolnew("subprojects/hyprland-protocols/protocols" "hyprland-toplevel-export-v1" true)
protocolnew("protocols" "wlr-screencopy-unstable-v1" true)
protocolnew("protocols" "wlr-gamma-control-unstable-v1" true)
protocolnew("protocols" "wlr-foreign-toplevel-management-unstable-v1" true)
protocolnew("protocols" "wlr-output-power-management-unstable-v1" true)
Expand Down
4 changes: 2 additions & 2 deletions protocols/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ hyprwayland_scanner = find_program(

protocols = [
[wl_protocol_dir, 'unstable/text-input/text-input-unstable-v1.xml'],
['wlr-screencopy-unstable-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-global-shortcuts-v1.xml']
]

Expand All @@ -42,6 +40,8 @@ new_protocols = [
['wlr-layer-shell-unstable-v1.xml'],
['wayland-drm.xml'],
['wlr-data-control-unstable-v1.xml'],
['wlr-screencopy-unstable-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-focus-grab-v1.xml'],
[wl_protocol_dir, 'staging/tearing-control/tearing-control-v1.xml'],
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
Expand Down
6 changes: 4 additions & 2 deletions src/events/Monitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "Events.hpp"
#include "../debug/HyprCtl.hpp"
#include "../config/ConfigValue.hpp"
#include "../protocols/Screencopy.hpp"
#include "../protocols/ToplevelExport.hpp"
#include <aquamarine/output/Output.hpp>

// --------------------------------------------------------- //
Expand Down Expand Up @@ -118,8 +120,8 @@ void Events::listener_monitorCommit(void* owner, void* data) {
const auto PMONITOR = (CMonitor*)owner;

if (true) { // FIXME: E->state->committed & WLR_OUTPUT_STATE_BUFFER
g_pProtocolManager->m_pScreencopyProtocolManager->onOutputCommit(PMONITOR);
g_pProtocolManager->m_pToplevelExportProtocolManager->onOutputCommit(PMONITOR);
PROTO::screencopy->onOutputCommit(PMONITOR);
PROTO::toplevelExport->onOutputCommit(PMONITOR);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/events/Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../protocols/LayerShell.hpp"
#include "../protocols/XDGShell.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../protocols/ToplevelExport.hpp"
#include "../xwayland/XSurface.hpp"

#include <hyprutils/string/String.hpp>
Expand Down Expand Up @@ -601,7 +602,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
g_pEventManager->postEvent(SHyprIPCEvent{"closewindow", std::format("{:x}", PWINDOW)});
EMIT_HOOK_EVENT("closeWindow", PWINDOW);

g_pProtocolManager->m_pToplevelExportProtocolManager->onWindowUnmap(PWINDOW);
PROTO::toplevelExport->onWindowUnmap(PWINDOW);

if (PWINDOW->m_bIsFullscreen)
g_pCompositor->setWindowFullscreen(PWINDOW, false, FULLSCREEN_FULL);
Expand Down
8 changes: 6 additions & 2 deletions src/managers/ProtocolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "../protocols/LinuxDMABUF.hpp"
#include "../protocols/DRMLease.hpp"
#include "../protocols/DRMSyncobj.hpp"
#include "../protocols/Screencopy.hpp"
#include "../protocols/ToplevelExport.hpp"

#include "../protocols/core/Seat.hpp"
#include "../protocols/core/DataDevice.hpp"
Expand Down Expand Up @@ -142,6 +144,8 @@ CProtocolManager::CProtocolManager() {
PROTO::dataWlr = std::make_unique<CDataDeviceWLRProtocol>(&zwlr_data_control_manager_v1_interface, 2, "DataDeviceWlr");
PROTO::primarySelection = std::make_unique<CPrimarySelectionProtocol>(&zwp_primary_selection_device_manager_v1_interface, 1, "PrimarySelection");
PROTO::xwaylandShell = std::make_unique<CXWaylandShellProtocol>(&xwayland_shell_v1_interface, 1, "XWaylandShell");
PROTO::screencopy = std::make_unique<CScreencopyProtocol>(&zwlr_screencopy_manager_v1_interface, 3, "Screencopy");
PROTO::toplevelExport = std::make_unique<CToplevelExportProtocol>(&hyprland_toplevel_export_manager_v1_interface, 2, "ToplevelExport");

for (auto& b : g_pCompositor->m_pAqBackend->getImplementations()) {
if (b->type() != Aquamarine::AQ_BACKEND_DRM)
Expand All @@ -161,10 +165,8 @@ CProtocolManager::CProtocolManager() {

// Old protocol implementations.
// TODO: rewrite them to use hyprwayland-scanner.
m_pToplevelExportProtocolManager = std::make_unique<CToplevelExportProtocolManager>();
m_pTextInputV1ProtocolManager = std::make_unique<CTextInputV1ProtocolManager>();
m_pGlobalShortcutsProtocolManager = std::make_unique<CGlobalShortcutsProtocolManager>();
m_pScreencopyProtocolManager = std::make_unique<CScreencopyProtocolManager>();
}

CProtocolManager::~CProtocolManager() {
Expand Down Expand Up @@ -214,6 +216,8 @@ CProtocolManager::~CProtocolManager() {
PROTO::dataWlr.reset();
PROTO::primarySelection.reset();
PROTO::xwaylandShell.reset();
PROTO::screencopy.reset();
PROTO::toplevelExport.reset();

PROTO::lease.reset();
PROTO::sync.reset();
Expand Down
5 changes: 1 addition & 4 deletions src/managers/ProtocolManager.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#pragma once

#include "../defines.hpp"
#include "../protocols/ToplevelExport.hpp"
#include "../protocols/TextInputV1.hpp"
#include "../protocols/GlobalShortcuts.hpp"
#include "../protocols/Screencopy.hpp"
#include "../helpers/Monitor.hpp"
#include "../helpers/memory/Memory.hpp"
#include "../helpers/signal/Signal.hpp"
#include <unordered_map>
Expand All @@ -15,10 +14,8 @@ class CProtocolManager {
~CProtocolManager();

// TODO: rewrite to use the new protocol framework
std::unique_ptr<CToplevelExportProtocolManager> m_pToplevelExportProtocolManager;
std::unique_ptr<CTextInputV1ProtocolManager> m_pTextInputV1ProtocolManager;
std::unique_ptr<CGlobalShortcutsProtocolManager> m_pGlobalShortcutsProtocolManager;
std::unique_ptr<CScreencopyProtocolManager> m_pScreencopyProtocolManager;

private:
std::unordered_map<std::string, CHyprSignalListener> m_mModeChangeListeners;
Expand Down
Loading

0 comments on commit ec672b1

Please sign in to comment.