mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-26 13:09:48 +01:00
warp cursor on login to center
This commit is contained in:
parent
af37a3895f
commit
61c9e50bcd
3 changed files with 11 additions and 3 deletions
|
@ -2021,14 +2021,14 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void CCompositor::warpCursorTo(const Vector2D& pos) {
|
||||
void CCompositor::warpCursorTo(const Vector2D& pos, bool force) {
|
||||
|
||||
// warpCursorTo should only be used for warps that
|
||||
// should be disabled with no_cursor_warps
|
||||
|
||||
static auto* const PNOWARPS = &g_pConfigManager->getConfigValuePtr("general:no_cursor_warps")->intValue;
|
||||
|
||||
if (*PNOWARPS)
|
||||
if (*PNOWARPS && !force)
|
||||
return;
|
||||
|
||||
wlr_cursor_warp(m_sWLRCursor, m_sSeat.mouse->mouse, pos.x, pos.y);
|
||||
|
|
|
@ -167,7 +167,7 @@ class CCompositor {
|
|||
void addToFadingOutSafe(SLayerSurface*);
|
||||
void addToFadingOutSafe(CWindow*);
|
||||
CWindow* getWindowByRegex(const std::string&);
|
||||
void warpCursorTo(const Vector2D&);
|
||||
void warpCursorTo(const Vector2D&, bool force = false);
|
||||
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
||||
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
||||
void closeWindow(CWindow*);
|
||||
|
|
|
@ -44,6 +44,9 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
|||
// new monitor added, let's accomodate for that.
|
||||
const auto OUTPUT = (wlr_output*)data;
|
||||
|
||||
// for warping the cursor on launch
|
||||
static bool firstLaunch = true;
|
||||
|
||||
if (!OUTPUT->name) {
|
||||
Debug::log(ERR, "New monitor has no name?? Ignoring");
|
||||
return;
|
||||
|
@ -89,6 +92,11 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
|||
|
||||
g_pConfigManager->m_bWantsMonitorReload = true;
|
||||
g_pCompositor->scheduleFrameForMonitor(PNEWMONITOR);
|
||||
|
||||
if (firstLaunch) {
|
||||
firstLaunch = false;
|
||||
g_pCompositor->warpCursorTo(PNEWMONITOR->vecPosition + PNEWMONITOR->vecSize / 2.f, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Events::listener_monitorFrame(void* owner, void* data) {
|
||||
|
|
Loading…
Reference in a new issue