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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
protocolnew("staging/fractional-scale" "fractional-scale-v1" false)
protocolnew("stable/viewporter" "viewporter" false)
protocolnew("staging/cursor-shape" "cursor-shape-v1" false)
protocolnew("staging/ext-session-lock" "ext-session-lock-v1" false)
protocolnew("stable/tablet" "tablet-v2" false)
protocolnew("unstable/text-input" "text-input-unstable-v3" false)
protocolnew("protocols" "wlr-layer-shell-unstable-v1" true)
Expand All @@ -142,6 +143,11 @@ add_executable(controls "tests/Controls.cpp")
target_link_libraries(controls PRIVATE PkgConfig::deps hyprtoolkit)
add_dependencies(tests controls)

add_executable(simpleSessionLock "tests/SimpleSessionLock.cpp")
target_link_libraries(simpleSessionLock PRIVATE PkgConfig::deps hyprtoolkit)
add_dependencies(tests simpleSessionLock)


# Installation
install(TARGETS hyprtoolkit)
install(DIRECTORY "include/hyprtoolkit" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@
inherit (pkgsFor.${system}) hyprtoolkit;
});

devShells = eachSystem (system: {
default =
pkgsFor.${system}.mkShell.override {
inherit (self.packages.${system}.default) stdenv;
} {
name = "hyprtoolkit-shell";
hardeningDisable = ["fortify"];
inputsFrom = [pkgsFor.${system}.hyprtoolkit];
packages = [pkgsFor.${system}.clang-tools];
};
});

checks = eachSystem (system: self.packages.${system});

formatter = eachSystem (system: pkgsFor.${system}.alejandra);
Expand Down
21 changes: 21 additions & 0 deletions include/hyprtoolkit/core/Backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace Hyprtoolkit {
class IWindow;
class IOutput;
class CTimer;
class ISystemIconFactory;
struct SWindowCreationData;
Expand Down Expand Up @@ -73,6 +74,26 @@ namespace Hyprtoolkit {

Hyprutils::Memory::CSharedPointer<CPalette> getPalette();

void unlockSession();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kinda sucks. I'd rather you'd make some lock state controller.

ILockState that you can get from the backend if you have a lockscreen, and will return nullptr if you dont.

This would play nicely with making Lock Surfaces -> you can only make them once you obtain the lockstate.

std::expected<SP<ILockState>, eLockError> createSystemLock();


/*
Get currently registered outputs.
Make sure you register the `removed` event to get rid of your reference once the output is removed.
*/
std::vector<Hyprutils::Memory::CSharedPointer<IOutput>> getOutputs();

struct {
/*
Get notified when a new output was added.
*/
Hyprutils::Signal::CSignalT<Hyprutils::Memory::CSharedPointer<IOutput>> outputAdded;

/*
Sent when the compositor denies us as the exclusive lock screen client.
*/
Hyprutils::Signal::CSignalT<> lockDenied;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be moved to the ILockState mentioned above

} m_events;

HT_HIDDEN : CBackend();

void terminate();
Expand Down
19 changes: 19 additions & 0 deletions include/hyprtoolkit/core/Output.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <hyprutils/signal/Signal.hpp>
#include <hyprutils/math/Vector2D.hpp>

namespace Hyprtoolkit {
class IOutput {
public:
virtual ~IOutput() = default;
virtual uint32_t handle() = 0;
virtual std::string port() = 0;
virtual std::string desc() = 0;

struct {
// output removed
Hyprutils::Signal::CSignalT<> removed;
} m_events;
};
}
10 changes: 7 additions & 3 deletions include/hyprtoolkit/window/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
namespace Hyprtoolkit {
class IElement;
class IWindow;
class IOutput;
struct SWindowCreationData;

enum eWindowType : uint8_t {
HT_WINDOW_TOPLEVEL = 0,
HT_WINDOW_POPUP = 1,
HT_WINDOW_LAYER = 2,
HT_WINDOW_TOPLEVEL = 0,
HT_WINDOW_POPUP = 1,
HT_WINDOW_LAYER = 2,
HT_WINDOW_LOCK_SURFACE = 3,
};

class CWindowBuilder {
Expand All @@ -28,6 +30,8 @@ namespace Hyprtoolkit {
Hyprutils::Memory::CSharedPointer<CWindowBuilder> preferredSize(const Hyprutils::Math::Vector2D&);
Hyprutils::Memory::CSharedPointer<CWindowBuilder> minSize(const Hyprutils::Math::Vector2D&);
Hyprutils::Memory::CSharedPointer<CWindowBuilder> maxSize(const Hyprutils::Math::Vector2D&);
// FIXME: implement for window types other than HT_WINDOW_LOCK_SURFACE
Hyprutils::Memory::CSharedPointer<CWindowBuilder> prefferedOutput(const Hyprutils::Memory::CSharedPointer<IOutput>& output);

// only for HT_WINDOW_LAYER
Hyprutils::Memory::CSharedPointer<CWindowBuilder> marginTopLeft(const Hyprutils::Math::Vector2D&);
Expand Down
45 changes: 37 additions & 8 deletions src/core/Backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

#include "./platforms/WaylandPlatform.hpp"
#include "../renderer/gl/OpenGL.hpp"
#include "../window/WaylandWindow.hpp"
#include "../output/WaylandOutput.hpp"
#include "../window/WaylandLayer.hpp"
#include "../window/WaylandLockSurface.hpp"
#include "../window/WaylandWindow.hpp"
#include "../Macros.hpp"
#include "../helpers/Timer.hpp"
#include "../element/Element.hpp"
Expand Down Expand Up @@ -67,6 +69,13 @@ SP<CBackend> CBackend::create() {
g_logger->log(HT_LOG_ERROR, "couldn't start aq backend");
return nullptr;
}
g_waylandPlatform = makeUnique<CWaylandPlatform>();
if (!g_waylandPlatform->attempt()) {
g_waylandPlatform = nullptr;
return nullptr;
}
g_openGL = makeShared<COpenGLRenderer>(g_waylandPlatform->m_drmState.fd);
g_renderer = g_openGL;

return g_backend;
};
Expand All @@ -83,14 +92,23 @@ SP<CPalette> CBackend::getPalette() {
return g_palette;
}

void CBackend::unlockSession() {
if (!g_waylandPlatform)
return;

g_waylandPlatform->unlockSessionLock();
}

std::vector<SP<IOutput>> CBackend::getOutputs() {
if (!g_waylandPlatform)
return {};

return std::vector<SP<IOutput>>(g_waylandPlatform->m_outputs.begin(), g_waylandPlatform->m_outputs.end());
}

SP<IWindow> CBackend::openWindow(const SWindowCreationData& data) {
if (!g_waylandPlatform) {
g_waylandPlatform = makeUnique<CWaylandPlatform>();
if (!g_waylandPlatform->attempt())
return nullptr;
g_openGL = makeShared<COpenGLRenderer>(g_waylandPlatform->m_drmState.fd);
g_renderer = g_openGL;
}
if (!g_waylandPlatform)
return nullptr;

if (data.type == HT_WINDOW_LAYER) {
if (!g_waylandPlatform->m_waylandState.layerShell)
Expand All @@ -101,6 +119,17 @@ SP<IWindow> CBackend::openWindow(const SWindowCreationData& data) {
w->m_rootElement->impl->window = w;
g_waylandPlatform->m_layers.emplace_back(w);
return w;
} else if (data.type == HT_WINDOW_LOCK_SURFACE) {
if (!g_waylandPlatform->m_waylandState.sessionLock) {
g_logger->log(HT_LOG_ERROR, "No session lock manager. Does your compositor support it?");
return nullptr;
}

auto w = makeShared<CWaylandLockSurface>(data);
w->m_self = w;
w->m_rootElement->impl->window = w;
g_waylandPlatform->m_lockSurfaces.emplace_back(w);
return w;
}

auto w = makeShared<CWaylandWindow>(data);
Expand Down
Empty file added src/core/Output.cpp
Empty file.
Loading