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
16 changes: 16 additions & 0 deletions packages/hyprland/0003-output-send-the-whole-state-with-done.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- a/src/protocols/core/Output.cpp
+++ b/src/protocols/core/Output.cpp
@@ -194,7 +194,12 @@
if UNLIKELY (m_defunct)
return;

+ // A done closes a batch of changes, and a transform change comes only
+ // this way (xdg-output's update schedules it): the mode stays the same,
+ // so modeChanged and updateState never run and wl_output.geometry kept
+ // the old transform for clients bound before the rotation. Send the whole
+ // state, geometry included, which ends with the done.
for (auto const& r : m_outputs) {
- r->m_resource->sendDone();
+ r->updateState();
}
}
215 changes: 215 additions & 0 deletions packages/hyprland/0004-input-bring-the-keyboard-up-on-a-touch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -1,5 +1,6 @@
#pragma once

+#include <chrono>
#include "../../defines.hpp"
#include <list>
#include <any>
@@ -229,6 +230,10 @@

// for hiding cursor on touch
bool m_lastInputTouch = false;
+ // when a finger or a button last went down or up (OMAMOBILE_IME_ON_TOUCH)
+ std::chrono::steady_clock::time_point m_lastPressTime = {};
+ // the surface that finger or button went down on (OMAMOBILE_IME_ON_TOUCH)
+ WP<CWLSurfaceResource> m_lastPressSurface;

// for hiding cursor on tablet
bool m_lastInputTablet = false;
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -718,6 +718,12 @@
}

void CInputManager::onMouseButton(IPointer::SButtonEvent e, SP<IPointer> mouse) {
+ m_lastPressTime = std::chrono::steady_clock::now();
+ if (e.state == WL_POINTER_BUTTON_STATE_PRESSED)
+ m_lastPressSurface = g_pSeatManager->m_state.pointerFocus;
+ if (e.state == WL_POINTER_BUTTON_STATE_RELEASED)
+ textInputPressEnded();
+
Event::SCallbackInfo info;
Event::bus()->m_events.input.mouse.button.emit(e, info);
if (info.cancelled)
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -16,6 +16,9 @@

void CInputManager::onTouchDown(ITouch::SDownEvent e) {
m_lastInputTouch = true;
+ // set below once the touch reaches a surface; a touch that returns early counts on none
+ m_lastPressTime = std::chrono::steady_clock::now();
+ m_lastPressSurface.reset();

static auto PSWIPETOUCH = CConfigValue<Config::INTEGER>("gestures:workspace_swipe_touch");
static auto PGAPSOUTDATA = CConfigValue<Config::IComplexConfigValue>("general:gaps_out");
@@ -149,11 +152,14 @@
} else
return; // oops, nothing found.

+ m_lastPressSurface = m_touchData.touchFocusSurface;
g_pSeatManager->sendTouchDown(m_touchData.touchFocusSurface.lock(), e.timeMs, e.touchID, local);
}

void CInputManager::onTouchUp(ITouch::SUpEvent e, SP<ITouch> device) {
m_lastInputTouch = true;
+ m_lastPressTime = std::chrono::steady_clock::now();
+ textInputPressEnded();

Event::SCallbackInfo info;
Event::bus()->m_events.input.touch.up.emit(e, info);
--- a/src/managers/input/TextInput.hpp
+++ b/src/managers/input/TextInput.hpp
@@ -28,6 +28,7 @@
void onDisabled();
void onCommit();
void onReset();
+ void activateDeferredIME();

bool isEnabled();
bool hasCursorRectangle();
@@ -43,6 +44,9 @@

WP<CWLSurfaceResource> m_focusedSurface;
int m_enterLocks = 0;
+ // enabled with no touch or click just before it: the input method waits
+ // for one (OMAMOBILE_IME_ON_TOUCH)
+ bool m_imeDeferred = false;
WP<CTextInputV3> m_v3Input;
WP<CTextInputV1> m_v1Input;

@@ -56,3 +60,6 @@
CHyprSignalListener surfaceDestroy;
} m_listeners;
};
+
+// a touch or a click ended (OMAMOBILE_IME_ON_TOUCH)
+void textInputPressEnded();
--- a/src/managers/input/TextInput.cpp
+++ b/src/managers/input/TextInput.cpp
@@ -5,6 +5,68 @@
#include "../../protocols/TextInputV3.hpp"
#include "../../protocols/InputMethodV2.hpp"
#include "../../protocols/core/Compositor.hpp"
+#include "../eventLoop/EventLoopManager.hpp"
+#include "../eventLoop/EventLoopTimer.hpp"
+#include <chrono>
+#include <cstdlib>
+#include <string_view>
+
+// OMAMOBILE_IME_ON_TOUCH=1 (read once): a text field that takes focus on its
+// own, as Chromium's address bar does when a window opens, does not bring up
+// the on-screen keyboard; it comes up when the field is touched, as on
+// Android. A field enabled within 800 ms of a touch or click activates the
+// input method at once. One enabled without it waits: 200 ms after the next
+// touch or click ends, if it is still the focused, enabled field (the tap was
+// on it, not on a link that took the focus away), it activates. Clients such
+// as Chromium send no text-input request after that tap until the input
+// method is active, so the compositor has to decide. Only a touch or click on
+// the field's own client counts: a back gesture or a tap on a recent app's
+// card (the shell's surfaces) that brings an app forward leaves it down.
+static bool imeOnTouch() {
+ static const bool ON = [] {
+ const char* e = std::getenv("OMAMOBILE_IME_ON_TOUCH");
+ return e && std::string_view{e} == "1";
+ }();
+ return ON;
+}
+
+static bool pressedOn(SP<CWLSurfaceResource> surface) {
+ const auto PRESSED = g_pInputManager->m_lastPressSurface.lock();
+ return surface && PRESSED && PRESSED->client() == surface->client();
+}
+
+static bool pressedRecentlyOn(SP<CWLSurfaceResource> surface) {
+ return std::chrono::steady_clock::now() - g_pInputManager->m_lastPressTime < std::chrono::milliseconds(800) && pressedOn(surface);
+}
+
+void CTextInput::activateDeferredIME() {
+ if (!m_imeDeferred || !isEnabled() || !pressedOn(focusedSurface()))
+ return;
+
+ LOG(Log::DEBUG, "TI touched: activating the input method");
+ m_imeDeferred = false;
+ g_pInputManager->m_relay.activateIME(this);
+}
+
+void textInputPressEnded() {
+ if (!imeOnTouch())
+ return;
+
+ static SP<CEventLoopTimer> timer;
+ if (!timer) {
+ timer = makeShared<CEventLoopTimer>(
+ std::nullopt,
+ [](SP<CEventLoopTimer> self, void* data) {
+ const auto TI = g_pInputManager->m_relay.getFocusedTextInput();
+ if (TI)
+ TI->activateDeferredIME();
+ },
+ nullptr);
+ g_pEventLoopManager->addTimer(timer);
+ }
+
+ timer->updateTimeout(std::chrono::milliseconds(200));
+}

CTextInput::CTextInput(WP<CTextInputV1> ti) : m_v1Input(ti) {
initCallbacks();
@@ -63,6 +125,13 @@
enter(surfV1);
}

+ if (imeOnTouch() && !pressedRecentlyOn(focusedSurface())) {
+ LOG(Log::DEBUG, "TI ENABLE with no touch: the input method waits for one");
+ m_imeDeferred = true;
+ return;
+ }
+
+ m_imeDeferred = false;
g_pInputManager->m_relay.activateIME(this);
}

@@ -72,6 +141,10 @@
return;
}

+ // never activated: nothing to deactivate (a keyboard shown by hand stays)
+ const bool WASDEFERRED = m_imeDeferred;
+ m_imeDeferred = false;
+
if (!isV3())
leave();

@@ -85,6 +158,9 @@
if (!PFOCUSEDTI || PFOCUSEDTI != this)
return;

+ if (WASDEFERRED)
+ return;
+
g_pInputManager->m_relay.deactivateIME(this);
}

@@ -92,6 +168,9 @@
if (g_pInputManager->m_relay.m_inputMethod.expired())
return;

+ if (m_imeDeferred)
+ return;
+
if (!focusedSurface())
return;

@@ -114,6 +193,9 @@
return;
}

+ if (m_imeDeferred)
+ return;
+
g_pInputManager->m_relay.commitIMEState(this);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/src/managers/input/InputMethodRelay.cpp
+++ b/src/managers/input/InputMethodRelay.cpp
@@ -121,6 +121,12 @@
m_inputMethod->deactivate();
if (shouldCommit)
commitIMEState(pInput);
+ else if (!pInput)
+ // No text input will commit a state after this one (its owner is gone),
+ // so send the done that applies the deactivation. Without it the input
+ // method stayed active: squeekboard kept a keyboard hidden by hand
+ // hidden for every later text field, until it was restarted.
+ m_inputMethod->done();
}

void CInputMethodRelay::commitIMEState(CTextInput* pInput) {
39 changes: 35 additions & 4 deletions packages/hyprland/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,31 @@
# fading out over it on Android's alpha-out curve).
# Only with OMAMOBILE_ROTATION_HOLD=1 in Hyprland's environment, which
# device-panther sets; other phones rotate as before.
# - 0003-output-send-the-whole-state-with-done.patch: a rotation changes the
# transform but not the mode, so Hyprland sent wl_output.done without a new
# wl_output.geometry, and clients bound before the rotation kept the old
# transform. squeekboard, bound at login, then sized itself for portrait in
# landscape and covered the whole screen. Every done now carries the whole
# state. Drop it once upstream resends the geometry on a transform change.
# - 0004-input-bring-the-keyboard-up-on-a-touch.patch: a text field that
# takes focus on its own (Chromium's address bar when a window opens)
# brought up the on-screen keyboard over half the screen. With
# OMAMOBILE_IME_ON_TOUCH=1 in Hyprland's environment the input method is
# activated only for a field enabled within 800 ms of a touch or click, or
# 200 ms after a later touch ends while the field is still focused and
# enabled, as on Android. Off by default, read once at startup.
# - 0005-input-method-apply-a-deactivation-with-done.patch: when the window
# of a focused text field closed, the input method got deactivate with no
# done, so it stayed active; a keyboard hidden by hand then never came back
# for later fields until squeekboard was restarted. The done is sent now.
# - pkgrel 3.2: the higher of Omarchy's (0.57.0-2) and Arch Linux ARM's
# (0.57.0-3) release plus .1, so it sorts above both, and .2 for the
# rotation hold (3.1 is published); [omamobile] comes before [omarchy] and
# [extra] in pacman.conf, so pacman takes this build either way.
# - pkgrel 3.3: the rotation hold's half turn over Android's 383 ms and the
# old frame faded out on Android's alpha-out curve (3.2 is published).
# - pkgrel 3.4: the wl_output geometry after a rotation (3.3 is published).
# - pkgrel 3.5: the keyboard on a touch and the input method's done.
# - arch=(aarch64) only.
# - build() runs the two cmake steps of `make release` itself, with
# CMAKE_SKIP_RPATH (Arch's Makefile sed) and the job count from MAKEFLAGS
Expand All @@ -36,8 +55,8 @@

pkgname=(hyprland hyprpm)
pkgver=0.57.0
pkgrel=3.3
pkgdesc='a highly customizable dynamic tiling Wayland compositor (Omarchy Mobile: DPMS retry, rotation hold)'
pkgrel=3.5
pkgdesc='a highly customizable dynamic tiling Wayland compositor (Omarchy Mobile: DPMS retry, rotation hold, wl_output geometry on rotation, keyboard on a touch)'
arch=(aarch64)
url="https://github.com/hyprwm/Hyprland"
license=(BSD-3-Clause)
Expand Down Expand Up @@ -104,13 +123,19 @@ source=("$_archive.tar.gz::$url/releases/download/v$pkgver/source-v$pkgver.tar.g
wl-output-global-grace.patch
monitor-rule-vrr.patch
0001-dpms-keep-retrying-a-refused-dpms-commit.patch
0002-render-hold-the-last-frame-across-a-rotation.patch)
0002-render-hold-the-last-frame-across-a-rotation.patch
0003-output-send-the-whole-state-with-done.patch
0004-input-bring-the-keyboard-up-on-a-touch.patch
0005-input-method-apply-a-deactivation-with-done.patch)
sha256sums=('82d006ba9264fe67266c7d583c16f1a6c64d51424dbdc472c3e9c9d5ddfcd559'
'26d62139b8ae55e286bcdff1838a6bc01a021d8f1039b40b8fa523df83f61610'
'8fa0f57dc1b3246ab4e30ae81419150f4af7767fb31e739e36c824c6d99fab73'
'c14fb0ec02d97100bcfa4e5c8daaf524972fa5c665e04960619744ba01c73c39'
'a5670d9a6cdee3f3990a81cdecfd5e1f95771ebd1d7b1e2622ac7187684b8836'
'c69e64fe55a25a7baa2751ff795ae1f8a1ddfc1d162b9b35f9d821675be02bb7')
'c69e64fe55a25a7baa2751ff795ae1f8a1ddfc1d162b9b35f9d821675be02bb7'
'2537015f3a03419bfe540622f073c0c5377883f3305c503b80a546f98c106946'
'9cbc5cca5f0e95b18c7bbcf41dbf9367d01d722262f0aa953595797e29086784'
'e8c163b9adbfce75cf26af235dbb20bb7ab57016ab17ec2897254257f549421b')

prepare() {
ln -sf hyprland-source "$_archive"
Expand All @@ -125,6 +150,12 @@ prepare() {
patch -Np1 --fuzz=0 -i "$srcdir/0001-dpms-keep-retrying-a-refused-dpms-commit.patch"
# Omarchy Mobile: hold the last frame across a rotation until the layers have drawn, then turn it in as Android does
patch -Np1 --fuzz=0 -i "$srcdir/0002-render-hold-the-last-frame-across-a-rotation.patch"
# Omarchy Mobile: send wl_output's whole state, geometry and transform included, with every done
patch -Np1 --fuzz=0 -i "$srcdir/0003-output-send-the-whole-state-with-done.patch"
# Omarchy Mobile: with OMAMOBILE_IME_ON_TOUCH=1, bring the keyboard up for a touched text field only
patch -Np1 --fuzz=0 -i "$srcdir/0004-input-bring-the-keyboard-up-on-a-touch.patch"
# Omarchy Mobile: send the done that applies an input method deactivation when the text input is gone
patch -Np1 --fuzz=0 -i "$srcdir/0005-input-method-apply-a-deactivation-with-done.patch"
sed -i -e '/find_package.glaze/s/7...<8 //' {.,hyprpm,start}/CMakeLists.txt
}

Expand Down
30 changes: 29 additions & 1 deletion packages/hyprland/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ reported the screen off, but the CRTC never turned off. See
| `nvidia-egl-teardown.patch`, `wl-output-global-grace.patch`, `monitor-rule-vrr.patch` | Omarchy's patches from the same commit, unchanged (what they fix: their comments in `prepare()`) |
| `0001-dpms-keep-retrying-a-refused-dpms-commit.patch` | The Omarchy Mobile change to `src/output/Monitor.cpp` |
| `0002-render-hold-the-last-frame-across-a-rotation.patch` | The Omarchy Mobile change to `src/render/Renderer.cpp` and `src/render/OpenGL.cpp` (the rotation hold, below) |
| `0003-output-send-the-whole-state-with-done.patch` | The Omarchy Mobile change to `src/protocols/core/Output.cpp` (wl_output's geometry after a rotation, below) |
| `0004-input-bring-the-keyboard-up-on-a-touch.patch` | The Omarchy Mobile change to `src/managers/input/` (the keyboard on a touch, below) |
| `0005-input-method-apply-a-deactivation-with-done.patch` | The Omarchy Mobile change to `src/managers/input/InputMethodRelay.cpp` (below) |

## What differs from Omarchy's `hyprland` 0.57.0-2

Expand All @@ -32,11 +35,36 @@ reported the screen off, but the CRTC never turned off. See
Hyprland's environment (read once at startup): `omamobile-device-panther`
sets it in `environment.d`, and the other phones rotate as before until
it has run on them.
- wl_output's geometry after a rotation (0003). A rule that only turns the
screen goes through `applyMonitorRuleSoft()` and emits no `modeChanged`,
so `CWLOutputResource::updateState()` never ran: clients bound before the
turn got a `wl_output.done` (from xdg-output's update) but no new
`wl_output.geometry`, and kept the old transform. squeekboard, bound at
login, sized itself for portrait in landscape and covered the screen.
Every done now sends the whole state first (scale, mode, geometry), which
is what updateState already sent on a mode change. On a Pixel 7, Chromium
in landscape with the keyboard up went from -18 px tall to 107, and
squeekboard's horizontal scale setting takes effect again.
- The keyboard on a touch (0004), with `OMAMOBILE_IME_ON_TOUCH=1` in
Hyprland's environment (read once at startup; off, nothing changes). A
field enabled within 800 ms of a touch or click activates the input method
at once, as before. One enabled with no touch (Chromium's address bar as a
window opens, a GTK text view) waits: 200 ms after the next touch or click
ends, if it is still the focused, enabled field, it activates. A tap on a
link or elsewhere takes the focus away first, so the keyboard stays down.
Chromium and GTK send no text-input request after that tap until the input
method is active, so the compositor decides. A keyboard brought up by hand
still types (squeekboard falls back to its virtual keyboard).
- The input method's done (0005). Closing the window of a focused text field
deactivated the input method without a done, so it never applied:
squeekboard stayed active, and a keyboard hidden by hand stayed hidden for
every later field until it was restarted.
- `pkgrel=3.3`: the higher of Omarchy's (0.57.0-2) and Arch Linux ARM's
(`extra/hyprland` 0.57.0-3, a rebuild for aquamarine 0.16.0 and
hyprgraphics 0.6.0) release, plus `.1`, so it sorts above both; `.2` for
the rotation hold, since 3.1 is published; `.3` for the half turn's
383 ms and the alpha-out curve, since 3.2 is published.
383 ms and the alpha-out curve, since 3.2 is published; `.4` for the
wl_output geometry; `.5` for the keyboard on a touch and the done.
- `arch=(aarch64)` only.
- `build()` runs the two cmake steps of `make release` itself:
- with Arch's `-DCMAKE_SKIP_RPATH=ON` (Arch's PKGBUILD seds it into the
Expand Down