Skip to content
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,8 @@ protocolnew("staging/ext-data-control" "ext-data-control-v1" false)
protocolnew("staging/pointer-warp" "pointer-warp-v1" false)
protocolnew("staging/fifo" "fifo-v1" false)
protocolnew("staging/commit-timing" "commit-timing-v1" false)
protocolnew("staging/ext-image-capture-source" "ext-image-capture-source-v1" false)
protocolnew("staging/ext-image-copy-capture" "ext-image-copy-capture-v1" false)

protocolwayland()

Expand Down
4 changes: 4 additions & 0 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "managers/ANRManager.hpp"
#include "managers/eventLoop/EventLoopManager.hpp"
#include "managers/permissions/DynamicPermissionManager.hpp"
#include "managers/screenshare/ScreenshareManager.hpp"
#include <algorithm>
#include <aquamarine/output/Output.hpp>
#include <bit>
Expand Down Expand Up @@ -713,6 +714,9 @@ void CCompositor::initManagers(eManagersInitStage stage) {

Debug::log(LOG, "Starting XWayland");
g_pXWayland = makeUnique<CXWayland>(g_pCompositor->m_wantsXwayland);

Debug::log(LOG, "Starting ScreenshareManager");
g_pScreenshareManager = makeUnique<CScreenshareManager>();
} break;
default: UNREACHABLE();
}
Expand Down
2 changes: 2 additions & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,8 @@ std::optional<std::string> CConfigManager::handlePermission(const std::string& c

if (data[1] == "screencopy")
type = PERMISSION_TYPE_SCREENCOPY;
else if (data[1] == "cursorpos")
type = PERMISSION_TYPE_CURSOR_POS;
else if (data[1] == "plugin")
type = PERMISSION_TYPE_PLUGIN;
else if (data[1] == "keyboard" || data[1] == "keeb")
Expand Down
8 changes: 8 additions & 0 deletions src/desktop/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ void CWindow::onMap() {
},
false);

m_realSize->setUpdateCallback([this](auto) {
if (m_isMapped)
m_events.resize.emit();
});

m_movingFromWorkspaceAlpha->setValueAndWarp(1.F);

m_reportedSize = m_pendingReportedSize;
Expand Down Expand Up @@ -631,6 +636,9 @@ void CWindow::onBorderAngleAnimEnd(WP<CBaseAnimatedVariable> pav) {
void CWindow::setHidden(bool hidden) {
m_hidden = hidden;

if (hidden)
m_events.hide.emit();

if (hidden && Desktop::focusState()->window() == m_self)
Desktop::focusState()->window().reset();

Expand Down
3 changes: 3 additions & 0 deletions src/desktop/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class CWindow {

struct {
CSignalT<> destroy;
CSignalT<> unmap;
CSignalT<> hide;
CSignalT<> resize;
} m_events;

WP<CXDGSurfaceResource> m_xdgSurface;
Expand Down
3 changes: 2 additions & 1 deletion src/events/Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "../desktop/state/FocusState.hpp"
#include "../managers/LayoutManager.hpp"
#include "../managers/EventManager.hpp"
#include "../managers/HookSystemManager.hpp"
#include "../managers/animation/AnimationManager.hpp"

#include <hyprutils/string/String.hpp>
Expand Down Expand Up @@ -576,7 +577,7 @@ void Events::listener_unmapWindow(void* owner, void* data) {
g_pConfigManager->storeFloatingSize(PWINDOW, PWINDOW->m_realSize->value());
}

PROTO::toplevelExport->onWindowUnmap(PWINDOW);
PWINDOW->m_events.unmap.emit();

if (PWINDOW->isFullscreen())
g_pCompositor->setWindowFullscreenInternal(PWINDOW, FSMODE_NONE);
Expand Down
11 changes: 7 additions & 4 deletions src/helpers/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
#include "../protocols/core/DataDevice.hpp"
#include "../render/Renderer.hpp"
#include "../managers/EventManager.hpp"
#include "../managers/screenshare/ScreenshareManager.hpp"
#include "../managers/LayoutManager.hpp"
#include "../managers/animation/AnimationManager.hpp"
#include "../managers/animation/DesktopAnimationManager.hpp"
#include "../managers/input/InputManager.hpp"
#include "../managers/HookSystemManager.hpp"
#include "../hyprerror/HyprError.hpp"
#include "../i18n/Engine.hpp"
#include "sync/SyncTimeline.hpp"
Expand Down Expand Up @@ -84,10 +86,11 @@ void CMonitor::onConnect(bool noRule) {
m_frameScheduler->onFrame();
});
m_listeners.commit = m_output->events.commit.listen([this] {
if (true) { // FIXME: E->state->committed & WLR_OUTPUT_STATE_BUFFER
PROTO::screencopy->onOutputCommit(m_self.lock());
PROTO::toplevelExport->onOutputCommit(m_self.lock());
}
m_events.commit.emit();

// FIXME: E->state->committed & WLR_OUTPUT_STATE_BUFFER
if (true && g_pScreenshareManager)
g_pScreenshareManager->onOutputCommit(m_self.lock());
});
m_listeners.needsFrame = m_output->events.needsFrame.listen([this] { g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); });

Expand Down
1 change: 1 addition & 0 deletions src/helpers/Monitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class CMonitor {
} m_tearingState;

struct {
CSignalT<> commit;
CSignalT<> destroy;
CSignalT<> connect;
CSignalT<> disconnect;
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ I18n::CI18nEngine::CI18nEngine() {

huEngine->registerEntry("en_US", TXT_KEY_PERMISSION_REQUEST_UNKNOWN, "An application <b>{app}</b> is requesting an unknown permission.");
huEngine->registerEntry("en_US", TXT_KEY_PERMISSION_REQUEST_SCREENCOPY, "An application <b>{app}</b> is trying to capture your screen.\n\nDo you want to allow it to?");
huEngine->registerEntry("en_US", TXT_KEY_PERMISSION_REQUEST_CURSOR_POS,
"An application <b>{app}</b> is trying to capture your cursor position.\n\nDo you want to allow it to?");
huEngine->registerEntry("en_US", TXT_KEY_PERMISSION_REQUEST_PLUGIN, "An application <b>{app}</b> is trying to load a plugin: <b>{plugin}</b>.\n\nDo you want to allow it to?");
huEngine->registerEntry("en_US", TXT_KEY_PERMISSION_REQUEST_KEYBOARD, "A new keyboard has been detected: <b>{keyboard}</b>.\n\nDo you want to allow it to operate?");
huEngine->registerEntry("en_US", TXT_KEY_PERMISSION_UNKNOWN_NAME, "(unknown)");
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace I18n {

TXT_KEY_PERMISSION_REQUEST_UNKNOWN,
TXT_KEY_PERMISSION_REQUEST_SCREENCOPY,
TXT_KEY_PERMISSION_REQUEST_CURSOR_POS,
TXT_KEY_PERMISSION_REQUEST_PLUGIN,
TXT_KEY_PERMISSION_REQUEST_KEYBOARD,
TXT_KEY_PERMISSION_UNKNOWN_NAME,
Expand Down Expand Up @@ -47,4 +48,4 @@ namespace I18n {
};

SP<CI18nEngine> i18nEngine();
};
};
15 changes: 15 additions & 0 deletions src/managers/PointerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ Vector2D CPointerManager::position() {
return m_pointerPos;
}

Vector2D CPointerManager::hotspot() {
return m_currentCursorImage.hotspot;
}

bool CPointerManager::hasCursor() {
return m_currentCursorImage.pBuffer || m_currentCursorImage.surface;
}
Expand All @@ -107,6 +111,7 @@ void CPointerManager::setCursorBuffer(SP<Aquamarine::IBuffer> buf, const Vector2
m_currentCursorImage.scale = scale;
updateCursorBackend();
damageIfSoftware();
m_events.cursorChanged.emit();
}

return;
Expand All @@ -124,6 +129,7 @@ void CPointerManager::setCursorBuffer(SP<Aquamarine::IBuffer> buf, const Vector2

updateCursorBackend();
damageIfSoftware();
m_events.cursorChanged.emit();
}

void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hotspot) {
Expand All @@ -135,6 +141,7 @@ void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hots
m_currentCursorImage.scale = surf && surf->resource() ? surf->resource()->m_current.scale : 1.F;
updateCursorBackend();
damageIfSoftware();
m_events.cursorChanged.emit();
}

return;
Expand All @@ -156,6 +163,7 @@ void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hots
recheckEnteredOutputs();
updateCursorBackend();
damageIfSoftware();
m_events.cursorChanged.emit();
});

if (surf->resource()->m_current.texture) {
Expand All @@ -169,6 +177,7 @@ void CPointerManager::setCursorSurface(SP<CWLSurface> surf, const Vector2D& hots
recheckEnteredOutputs();
updateCursorBackend();
damageIfSoftware();
m_events.cursorChanged.emit();
}

void CPointerManager::recheckEnteredOutputs() {
Expand Down Expand Up @@ -253,6 +262,8 @@ void CPointerManager::resetCursorImage(bool apply) {
ms->cursorFrontBuffer = nullptr;
}
}

m_events.cursorChanged.emit();
}

void CPointerManager::updateCursorBackend() {
Expand Down Expand Up @@ -1125,3 +1136,7 @@ void CPointerManager::sendStoredMovement() {
m_storedDelta = Vector2D{};
m_storedUnaccel = Vector2D{};
}

const CPointerManager::SCursorImage& CPointerManager::currentCursorImage() {
return m_currentCursorImage;
}
53 changes: 31 additions & 22 deletions src/managers/PointerManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,37 @@ class CPointerManager {

//
Vector2D position();
Vector2D hotspot();
Vector2D cursorSizeLogical();
void storeMovement(uint64_t time, const Vector2D& delta, const Vector2D& deltaUnaccel);
void setStoredMovement(uint64_t time, const Vector2D& delta, const Vector2D& deltaUnaccel);
void sendStoredMovement();

void recheckEnteredOutputs();

// returns the thing in global coords
CBox getCursorBoxGlobal();

struct SCursorImage {
SP<Aquamarine::IBuffer> pBuffer;
SP<CTexture> bufferTex;
WP<CWLSurface> surface;

Vector2D hotspot;
Vector2D size;
float scale = 1.F;

CHyprSignalListener destroySurface;
CHyprSignalListener commitSurface;
};

const SCursorImage& currentCursorImage();
SP<CTexture> getCurrentCursorTexture();

struct {
CSignalT<> cursorChanged;
} m_events;

private:
void recheckPointerPosition();
void onMonitorLayoutChange();
Expand All @@ -81,13 +105,9 @@ class CPointerManager {
// returns the thing in device coordinates. Is NOT offset by the hotspot, relies on set_cursor with hotspot.
Vector2D getCursorPosForMonitor(PHLMONITOR pMonitor);
// returns the thing in logical coordinates of the monitor
CBox getCursorBoxLogicalForMonitor(PHLMONITOR pMonitor);
// returns the thing in global coords
CBox getCursorBoxGlobal();

Vector2D transformedHotspot(PHLMONITOR pMonitor);
CBox getCursorBoxLogicalForMonitor(PHLMONITOR pMonitor);

SP<CTexture> getCurrentCursorTexture();
Vector2D transformedHotspot(PHLMONITOR pMonitor);

struct SPointerListener {
CHyprSignalListener destroy;
Expand Down Expand Up @@ -139,24 +159,13 @@ class CPointerManager {
std::vector<CBox> monitorBoxes;
} m_currentMonitorLayout;

struct {
SP<Aquamarine::IBuffer> pBuffer;
SP<CTexture> bufferTex;
WP<CWLSurface> surface;

Vector2D hotspot;
Vector2D size;
float scale = 1.F;

CHyprSignalListener destroySurface;
CHyprSignalListener commitSurface;
} m_currentCursorImage; // TODO: support various sizes per-output so we can have pixel-perfect cursors
SCursorImage m_currentCursorImage; // TODO: support various sizes per-output so we can have pixel-perfect cursors

Vector2D m_pointerPos = {0, 0};
Vector2D m_pointerPos = {0, 0};

uint64_t m_storedTime = 0;
Vector2D m_storedDelta = {0, 0};
Vector2D m_storedUnaccel = {0, 0};
uint64_t m_storedTime = 0;
Vector2D m_storedDelta = {0, 0};
Vector2D m_storedUnaccel = {0, 0};

struct SMonitorPointerState {
SMonitorPointerState(const PHLMONITOR& m) : monitor(m) {}
Expand Down
11 changes: 9 additions & 2 deletions src/managers/ProtocolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include "../protocols/SecurityContext.hpp"
#include "../protocols/CTMControl.hpp"
#include "../protocols/HyprlandSurface.hpp"
#include "../protocols/ImageCaptureSource.hpp"
#include "../protocols/ImageCopyCapture.hpp"
#include "../protocols/core/Seat.hpp"
#include "../protocols/core/DataDevice.hpp"
#include "../protocols/core/Compositor.hpp"
Expand All @@ -67,6 +69,7 @@
#include "../protocols/PointerWarp.hpp"
#include "../protocols/Fifo.hpp"
#include "../protocols/CommitTiming.hpp"
#include "HookSystemManager.hpp"

#include "../helpers/Monitor.hpp"
#include "../render/Renderer.hpp"
Expand Down Expand Up @@ -199,6 +202,11 @@ CProtocolManager::CProtocolManager() {
PROTO::fifo = makeUnique<CFifoProtocol>(&wp_fifo_manager_v1_interface, 1, "Fifo");
PROTO::commitTiming = makeUnique<CCommitTimingProtocol>(&wp_commit_timing_manager_v1_interface, 1, "CommitTiming");

PROTO::imageCaptureSource = makeUnique<CImageCaptureSourceProtocol>(); // ctor inits actual protos, output and toplevel
PROTO::imageCopyCapture = makeUnique<CImageCopyCaptureProtocol>(&ext_image_copy_capture_manager_v1_interface, 1, "ImageCopyCapture");

// ! please read the top of this file before adding another protocol

if (*PENABLECM)
PROTO::colorManagement = makeUnique<CColorManagementProtocol>(&wp_color_manager_v1_interface, 1, "ColorManagement", *PDEBUGCM);

Expand All @@ -207,8 +215,6 @@ CProtocolManager::CProtocolManager() {
PROTO::frogColorManagement = makeUnique<CFrogColorManagementProtocol>(&frog_color_management_factory_v1_interface, 1, "FrogColorManagement");
}

// ! please read the top of this file before adding another protocol

for (auto const& b : g_pCompositor->m_aqBackend->getImplementations()) {
if (b->type() != Aquamarine::AQ_BACKEND_DRM)
continue;
Expand Down Expand Up @@ -304,6 +310,7 @@ CProtocolManager::~CProtocolManager() {
PROTO::pointerWarp.reset();
PROTO::fifo.reset();
PROTO::commitTiming.reset();
PROTO::imageCaptureSource.reset();

for (auto& [_, lease] : PROTO::lease) {
lease.reset();
Expand Down
2 changes: 2 additions & 0 deletions src/managers/permissions/DynamicPermissionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ static const char* permissionToString(eDynamicPermissionType type) {
case PERMISSION_TYPE_SCREENCOPY: return "PERMISSION_TYPE_SCREENCOPY";
case PERMISSION_TYPE_PLUGIN: return "PERMISSION_TYPE_PLUGIN";
case PERMISSION_TYPE_KEYBOARD: return "PERMISSION_TYPE_KEYBOARD";
case PERMISSION_TYPE_CURSOR_POS: return "PERMISSION_TYPE_CURSOR_POS";
}

return "error";
Expand Down Expand Up @@ -251,6 +252,7 @@ void CDynamicPermissionManager::askForPermission(wl_client* client, const std::s
std::string description = "";
switch (rule->m_type) {
case PERMISSION_TYPE_SCREENCOPY: description = I18n::i18nEngine()->localize(I18n::TXT_KEY_PERMISSION_REQUEST_SCREENCOPY, {{"app", appName}}); break;
case PERMISSION_TYPE_CURSOR_POS: description = I18n::i18nEngine()->localize(I18n::TXT_KEY_PERMISSION_REQUEST_CURSOR_POS, {{"app", appName}}); break;
case PERMISSION_TYPE_PLUGIN: description = I18n::i18nEngine()->localize(I18n::TXT_KEY_PERMISSION_REQUEST_SCREENCOPY, {{"app", appName}, {"plugin", binaryPath}}); break;
case PERMISSION_TYPE_KEYBOARD: description = I18n::i18nEngine()->localize(I18n::TXT_KEY_PERMISSION_REQUEST_KEYBOARD, {{"keyboard", binaryPath}}); break;
case PERMISSION_TYPE_UNKNOWN: description = I18n::i18nEngine()->localize(I18n::TXT_KEY_PERMISSION_REQUEST_UNKNOWN, {{"app", appName}}); break;
Expand Down
3 changes: 2 additions & 1 deletion src/managers/permissions/DynamicPermissionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum eDynamicPermissionType : uint8_t {
PERMISSION_TYPE_SCREENCOPY,
PERMISSION_TYPE_PLUGIN,
PERMISSION_TYPE_KEYBOARD,
PERMISSION_TYPE_CURSOR_POS,
};

enum eDynamicPermissionRuleSource : uint8_t {
Expand Down Expand Up @@ -104,4 +105,4 @@ class CDynamicPermissionManager {
std::vector<SP<CDynamicPermissionRule>> m_rules;
};

inline UP<CDynamicPermissionManager> g_pDynamicPermissionManager;
inline UP<CDynamicPermissionManager> g_pDynamicPermissionManager;
Loading
Loading