idle: implement new protocol

This commit is contained in:
vaxerski 2023-07-13 18:05:34 +02:00
parent 9f7382bca4
commit f8def68e7e
6 changed files with 30 additions and 14 deletions

View file

@ -187,7 +187,8 @@ void CCompositor::initServer() {
m_sWLRPresentation = wlr_presentation_create(m_sWLDisplay, m_sWLRBackend); m_sWLRPresentation = wlr_presentation_create(m_sWLDisplay, m_sWLRBackend);
m_sWLRIdle = wlr_idle_create(m_sWLDisplay); m_sWLRIdle = wlr_idle_create(m_sWLDisplay);
m_sWLRIdleNotifier = wlr_idle_notifier_v1_create(m_sWLDisplay);
m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay, 4); m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay, 4);
@ -2435,3 +2436,13 @@ CWindow* CCompositor::getForceFocus() {
return nullptr; return nullptr;
} }
void CCompositor::notifyIdleActivity() {
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
wlr_idle_notifier_v1_notify_activity(g_pCompositor->m_sWLRIdleNotifier, g_pCompositor->m_sSeat.seat);
}
void CCompositor::setIdleActivityInhibit(bool inhibit) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, inhibit);
wlr_idle_notifier_v1_set_inhibited(g_pCompositor->m_sWLRIdleNotifier, inhibit);
}

View file

@ -28,7 +28,8 @@
#include "hyprerror/HyprError.hpp" #include "hyprerror/HyprError.hpp"
#include "plugins/PluginSystem.hpp" #include "plugins/PluginSystem.hpp"
enum eManagersInitStage { enum eManagersInitStage
{
STAGE_PRIORITY = 0, STAGE_PRIORITY = 0,
STAGE_LATE STAGE_LATE
}; };
@ -53,6 +54,7 @@ class CCompositor {
wlr_xdg_activation_v1* m_sWLRXDGActivation; wlr_xdg_activation_v1* m_sWLRXDGActivation;
wlr_output_layout* m_sWLROutputLayout; wlr_output_layout* m_sWLROutputLayout;
wlr_idle* m_sWLRIdle; wlr_idle* m_sWLRIdle;
wlr_idle_notifier_v1* m_sWLRIdleNotifier;
wlr_layer_shell_v1* m_sWLRLayerShell; wlr_layer_shell_v1* m_sWLRLayerShell;
wlr_xdg_shell* m_sWLRXDGShell; wlr_xdg_shell* m_sWLRXDGShell;
wlr_cursor* m_sWLRCursor; wlr_cursor* m_sWLRCursor;
@ -170,7 +172,7 @@ class CCompositor {
CMonitor* getMonitorInDirection(const char&); CMonitor* getMonitorInDirection(const char&);
void updateAllWindowsAnimatedDecorationValues(); void updateAllWindowsAnimatedDecorationValues();
void updateWindowAnimatedDecorationValues(CWindow*); void updateWindowAnimatedDecorationValues(CWindow*);
int getNextAvailableMonitorID(std::string const & name); int getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*); void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
void swapActiveWorkspaces(CMonitor*, CMonitor*); void swapActiveWorkspaces(CMonitor*, CMonitor*);
CMonitor* getMonitorFromString(const std::string&); CMonitor* getMonitorFromString(const std::string&);
@ -197,6 +199,8 @@ class CCompositor {
void performUserChecks(); void performUserChecks();
void moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace); void moveWindowToWorkspaceSafe(CWindow* pWindow, CWorkspace* pWorkspace);
CWindow* getForceFocus(); CWindow* getForceFocus();
void notifyIdleActivity();
void setIdleActivityInhibit(bool inhibit);
std::string explicitConfigPath; std::string explicitConfigPath;

View file

@ -103,6 +103,7 @@ extern "C" {
#include <wlr/backend/wayland.h> #include <wlr/backend/wayland.h>
#include <wlr/types/wlr_session_lock_v1.h> #include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_single_pixel_buffer_v1.h> #include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include <libdrm/drm_fourcc.h> #include <libdrm/drm_fourcc.h>

View file

@ -42,10 +42,10 @@ void CInputManager::recheckIdleInhibitorStatus() {
for (auto& ii : m_lIdleInhibitors) { for (auto& ii : m_lIdleInhibitors) {
if (!ii.pWindow) { if (!ii.pWindow) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); g_pCompositor->setIdleActivityInhibit(false);
return; return;
} else if (g_pHyprRenderer->shouldRenderWindow(ii.pWindow)) { } else if (g_pHyprRenderer->shouldRenderWindow(ii.pWindow)) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); g_pCompositor->setIdleActivityInhibit(false);
return; return;
} }
} }
@ -56,21 +56,21 @@ void CInputManager::recheckIdleInhibitorStatus() {
continue; continue;
if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS) { if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); g_pCompositor->setIdleActivityInhibit(false);
return; return;
} }
if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w.get())) { if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w.get())) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); g_pCompositor->setIdleActivityInhibit(false);
return; return;
} }
if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID)) { if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->m_iWorkspaceID)) {
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, false); g_pCompositor->setIdleActivityInhibit(false);
return; return;
} }
} }
wlr_idle_set_enabled(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat, true); g_pCompositor->setIdleActivityInhibit(true);
return; return;
} }

View file

@ -320,7 +320,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
m_bEmptyFocusCursorSet = false; m_bEmptyFocusCursorSet = false;
if (time) if (time)
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); g_pCompositor->notifyIdleActivity();
Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos;
@ -432,7 +432,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
} }
void CInputManager::onMouseButton(wlr_pointer_button_event* e) { void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); g_pCompositor->notifyIdleActivity();
EMIT_HOOK_EVENT("mouseButton", e); EMIT_HOOK_EVENT("mouseButton", e);
@ -607,7 +607,7 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
bool passEvent = g_pKeybindManager->onAxisEvent(e); bool passEvent = g_pKeybindManager->onAxisEvent(e);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); g_pCompositor->notifyIdleActivity();
if (passEvent) { if (passEvent) {
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta, std::round(factor * e->delta_discrete), e->source); wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta, std::round(factor * e->delta_discrete), e->source);
@ -1067,7 +1067,7 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard); bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); g_pCompositor->notifyIdleActivity();
if (passEvent) { if (passEvent) {

View file

@ -48,7 +48,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); wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, m_sTouchData.touchFocusSurface, e->time_msec, e->touch_id, local.x, local.y);
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); g_pCompositor->notifyIdleActivity();
} }
void CInputManager::onTouchUp(wlr_touch_up_event* e) { void CInputManager::onTouchUp(wlr_touch_up_event* e) {