Skip to content

Commit

Permalink
ext-idle-notify: move to new impl
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Apr 29, 2024
1 parent 8613398 commit f2b03e9
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 82 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ target_link_libraries(Hyprland
uuid
)

protocol("protocols/idle.xml" "idle" true)
protocol("protocols/tablet-unstable-v2.xml" "tablet-unstable-v2" true)
protocol("protocols/wlr-layer-shell-unstable-v1.xml" "wlr-layer-shell-unstable-v1" true)
protocol("protocols/wlr-screencopy-unstable-v1.xml" "wlr-screencopy-unstable-v1" true)
Expand All @@ -276,6 +275,7 @@ protocolNew("unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unst
protocolNew("unstable/text-input/text-input-unstable-v3.xml" "text-input-unstable-v3" false)
protocolNew("unstable/pointer-constraints/pointer-constraints-unstable-v1.xml" "pointer-constraints-unstable-v1" false)
protocolNew("staging/xdg-activation/xdg-activation-v1.xml" "xdg-activation-v1" false)
protocolNew("staging/ext-idle-notify/ext-idle-notify-v1.xml" "ext-idle-notify-v1" false)

# tools
add_subdirectory(hyprctl)
Expand Down
49 changes: 0 additions & 49 deletions protocols/idle.xml

This file was deleted.

2 changes: 1 addition & 1 deletion protocols/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ protocols = [
['wlr-layer-shell-unstable-v1.xml'],
['wlr-screencopy-unstable-v1.xml'],
['tablet-unstable-v2.xml'],
['idle.xml'],
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml'],
[hl_protocol_dir, 'protocols/hyprland-global-shortcuts-v1.xml']
]
Expand All @@ -53,6 +52,7 @@ new_protocols = [
[wl_protocol_dir, 'unstable/text-input/text-input-unstable-v3.xml'],
[wl_protocol_dir, 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'],
[wl_protocol_dir, 'staging/xdg-activation/xdg-activation-v1.xml'],
[wl_protocol_dir, 'staging/ext-idle-notify/ext-idle-notify-v1.xml'],
]

wl_protos_src = []
Expand Down
9 changes: 0 additions & 9 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,6 @@ void CCompositor::initServer() {

m_sWLRPresentation = wlr_presentation_create(m_sWLDisplay, m_sWLRBackend);

m_sWLRIdleNotifier = wlr_idle_notifier_v1_create(m_sWLDisplay);

m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay, 4);

m_sWLRServerDecoMgr = wlr_server_decoration_manager_create(m_sWLDisplay);
Expand Down Expand Up @@ -2701,13 +2699,6 @@ PHLWINDOW CCompositor::getForceFocus() {
return nullptr;
}

void CCompositor::notifyIdleActivity() {
wlr_idle_notifier_v1_notify_activity(g_pCompositor->m_sWLRIdleNotifier, g_pCompositor->m_sSeat.seat);
}

void CCompositor::setIdleActivityInhibit(bool enabled) {
wlr_idle_notifier_v1_set_inhibited(g_pCompositor->m_sWLRIdleNotifier, !enabled);
}
void CCompositor::arrangeMonitors() {
static auto* const PXWLFORCESCALEZERO = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling");

Expand Down
3 changes: 0 additions & 3 deletions src/Compositor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class CCompositor {
wlr_drm* m_sWRLDRM;
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
wlr_output_layout* m_sWLROutputLayout;
wlr_idle_notifier_v1* m_sWLRIdleNotifier;
wlr_layer_shell_v1* m_sWLRLayerShell;
wlr_xdg_shell* m_sWLRXDGShell;
wlr_cursor* m_sWLRCursor;
Expand Down Expand Up @@ -185,8 +184,6 @@ class CCompositor {
void performUserChecks();
void moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWorkspace);
PHLWINDOW getForceFocus();
void notifyIdleActivity();
void setIdleActivityInhibit(bool inhibit);
void arrangeMonitors();
void enterUnsafeState();
void leaveUnsafeState();
Expand Down
1 change: 0 additions & 1 deletion src/includes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ extern "C" {
#include <wlr/backend/wayland.h>
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include <wlr/util/box.h>
#include <wlr/util/transform.h>
#include <wlr/render/swapchain.h>
Expand Down
3 changes: 3 additions & 0 deletions src/managers/ProtocolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "../protocols/PointerConstraints.hpp"
#include "../protocols/OutputPower.hpp"
#include "../protocols/XDGActivation.hpp"
#include "../protocols/IdleNotify.hpp"

#include "tearing-control-v1.hpp"
#include "fractional-scale-v1.hpp"
Expand All @@ -35,6 +36,7 @@
#include "pointer-constraints-unstable-v1.hpp"
#include "wlr-output-power-management-unstable-v1.hpp"
#include "xdg-activation-v1.hpp"
#include "ext-idle-notify-v1.hpp"

CProtocolManager::CProtocolManager() {

Expand All @@ -55,6 +57,7 @@ CProtocolManager::CProtocolManager() {
PROTO::constraints = std::make_unique<CPointerConstraintsProtocol>(&zwp_pointer_constraints_v1_interface, 1, "PointerConstraints");
PROTO::outputPower = std::make_unique<COutputPowerProtocol>(&zwlr_output_power_manager_v1_interface, 1, "OutputPower");
PROTO::activation = std::make_unique<CXDGActivationProtocol>(&xdg_activation_v1_interface, 1, "XDGActivation");
PROTO::idle = std::make_unique<CIdleNotifyProtocol>(&ext_idle_notifier_v1_interface, 1, "IdleNotify");

// Old protocol implementations.
// TODO: rewrite them to use hyprwayland-scanner.
Expand Down
19 changes: 10 additions & 9 deletions src/managers/input/IdleInhibitor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "InputManager.hpp"
#include "../../Compositor.hpp"
#include "../../protocols/IdleInhibit.hpp"
#include "../../protocols/IdleNotify.hpp"

void CInputManager::newIdleInhibitor(std::any inhibitor) {
const auto PINHIBIT = m_vIdleInhibitors.emplace_back(std::make_unique<SIdleInhibitor>()).get();
Expand Down Expand Up @@ -29,11 +30,11 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) {
void CInputManager::recheckIdleInhibitorStatus() {

for (auto& ii : m_vIdleInhibitors) {
if (ii->pWindow.expired()) {
g_pCompositor->setIdleActivityInhibit(false);
return;
} else if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow.lock())) {
g_pCompositor->setIdleActivityInhibit(false);
if (ii->pWindow.expired())
continue;

if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow.lock())) {
PROTO::idle->setInhibit(true);
return;
}
}
Expand All @@ -44,21 +45,21 @@ void CInputManager::recheckIdleInhibitorStatus() {
continue;

if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS) {
g_pCompositor->setIdleActivityInhibit(false);
PROTO::idle->setInhibit(true);
return;
}

if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w)) {
g_pCompositor->setIdleActivityInhibit(false);
PROTO::idle->setInhibit(true);
return;
}

if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->m_pWorkspace)) {
g_pCompositor->setIdleActivityInhibit(false);
PROTO::idle->setInhibit(true);
return;
}
}

g_pCompositor->setIdleActivityInhibit(true);
PROTO::idle->setInhibit(false);
return;
}
9 changes: 5 additions & 4 deletions src/managers/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "../../protocols/IdleInhibit.hpp"
#include "../../protocols/RelativePointer.hpp"
#include "../../protocols/PointerConstraints.hpp"
#include "../../protocols/IdleNotify.hpp"

CInputManager::CInputManager() {
m_sListeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) {
Expand Down Expand Up @@ -144,7 +145,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);

if (time)
g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();

m_vLastCursorPosFloored = MOUSECOORDSFLOORED;

Expand Down Expand Up @@ -480,7 +481,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e);

g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();

m_tmrLastCursorMovement.reset();

Expand Down Expand Up @@ -705,7 +706,7 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {

bool passEvent = g_pKeybindManager->onAxisEvent(e);

g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();

if (!passEvent)
return;
Expand Down Expand Up @@ -1216,7 +1217,7 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar

bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);

g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();

if (passEvent) {

Expand Down
9 changes: 5 additions & 4 deletions src/managers/input/Tablets.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "InputManager.hpp"
#include "../../Compositor.hpp"
#include "../../protocols/IdleNotify.hpp"

void CInputManager::newTabletTool(wlr_input_device* pDevice) {
const auto PNEWTABLET = &m_lTablets.emplace_back();
Expand Down Expand Up @@ -99,7 +100,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
if (EVENT->updated_axes & (WLR_TABLET_TOOL_AXIS_TILT_X | WLR_TABLET_TOOL_AXIS_TILT_Y))
wlr_tablet_v2_tablet_tool_notify_tilt(PTOOL->wlrTabletToolV2, PTOOL->tiltX, PTOOL->tiltY);

g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();
},
PNEWTABLET, "Tablet");

Expand All @@ -120,7 +121,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
wlr_send_tablet_v2_tablet_tool_up(PTOOL->wlrTabletToolV2);
}

g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();
},
PNEWTABLET, "Tablet");

Expand All @@ -132,7 +133,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);

wlr_tablet_v2_tablet_tool_notify_button(PTOOL->wlrTabletToolV2, (zwp_tablet_pad_v2_button_state)EVENT->button, (zwp_tablet_pad_v2_button_state)EVENT->state);
g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();
},
PNEWTABLET, "Tablet");

Expand All @@ -158,7 +159,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
g_pInputManager->focusTablet(PTAB, EVENT->tool);
}

g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();
},
PNEWTABLET, "Tablet");

Expand Down
3 changes: 2 additions & 1 deletion src/managers/input/Touch.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "InputManager.hpp"
#include "../../Compositor.hpp"
#include "../../config/ConfigValue.hpp"
#include "../../protocols/IdleNotify.hpp"

void CInputManager::onTouchDown(wlr_touch_down_event* e) {
static auto PSWIPETOUCH = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch");
Expand Down Expand Up @@ -83,7 +84,7 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {

wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, m_sTouchData.touchFocusSurface, e->time_msec, e->touch_id, local.x, local.y);

g_pCompositor->notifyIdleActivity();
PROTO::idle->onActivity();
}

void CInputManager::onTouchUp(wlr_touch_up_event* e) {
Expand Down
Loading

0 comments on commit f2b03e9

Please sign in to comment.