Skip to content

Commit f77c886

Browse files
Fix issue where terminal cursor blinking would not automatically start again if termux activity is started after device display timeout with double tap and not power button.
Fixes #2138
1 parent 5f2ccca commit f77c886

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

app/src/main/java/com/termux/app/terminal/TermuxTerminalViewClient.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ public void onResume() {
9898
setSoftKeyboardState(true, false);
9999

100100
mTerminalCursorBlinkerStateAlreadySet = false;
101+
102+
if (mActivity.getTerminalView().mEmulator != null) {
103+
// Start terminal cursor blinking if enabled
104+
// If emulator is already set, then start blinker now, otherwise wait for onEmulatorSet()
105+
// event to start it. This is needed since onEmulatorSet() may not be called after
106+
// TermuxActivity is started after device display timeout with double tap and not power button.
107+
setTerminalCursorBlinkerState(true);
108+
mTerminalCursorBlinkerStateAlreadySet = true;
109+
}
101110
}
102111

103112
/**

terminal-view/src/main/java/com/termux/view/TerminalView.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -881,13 +881,16 @@ public synchronized boolean setTerminalCursorBlinkerRate(int blinkRate) {
881881
* {@link #TERMINAL_CURSOR_BLINK_RATE_MIN} and {@link #TERMINAL_CURSOR_BLINK_RATE_MAX}.
882882
*
883883
* This should be called when the view holding this activity is resumed or stopped so that
884-
* cursor blinker does not run when activity is not visible. Ensure that {@link #mEmulator}
885-
* is set when you call this to start cursor blinking by waiting for {@link TerminalViewClient#onEmulatorSet()}
886-
* event after calling {@link #attachSession(TerminalSession)} for the first session added in the
887-
* activity, otherwise blinking will not start. Do not call this directly after
888-
* {@link #attachSession(TerminalSession)} since {@link #updateSize()} may return without
889-
* setting {@link #mEmulator} since width/height may be 0. Its called again in
890-
* {@link #onSizeChanged(int, int, int, int)}.
884+
* cursor blinker does not run when activity is not visible. If you call this on onResume()
885+
* to start cursor blinking, then ensure that {@link #mEmulator} is set, otherwise wait for the
886+
* {@link TerminalViewClient#onEmulatorSet()} event after calling {@link #attachSession(TerminalSession)}
887+
* for the first session added in the activity since blinking will not start if {@link #mEmulator}
888+
* is not set, like if activity is started again after exiting it with double back press. Do not
889+
* call this directly after {@link #attachSession(TerminalSession)} since {@link #updateSize()}
890+
* may return without setting {@link #mEmulator} since width/height may be 0. Its called again in
891+
* {@link #onSizeChanged(int, int, int, int)}. Calling on onResume() if emulator is already set
892+
* is necessary, since onEmulatorSet() may not be called after activity is started after device
893+
* display timeout with double tap and not power button.
891894
*
892895
* It should also be called on the
893896
* {@link com.termux.terminal.TerminalSessionClient#onTerminalCursorStateChange(boolean)}

0 commit comments

Comments
 (0)