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
31 changes: 20 additions & 11 deletions emain/emain-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,18 +516,27 @@ export class WaveBrowserWindow extends BaseWindow {
this.finalizePositioning();
}

// something is causing the new tab to lose focus so it requires manual refocusing
tabView.webContents.focus();
setTimeout(() => {
if (tabView.webContents && this.activeTabView == tabView && !tabView.webContents.isFocused()) {
tabView.webContents.focus();
}
}, 10);
setTimeout(() => {
if (tabView.webContents && this.activeTabView == tabView && !tabView.webContents.isFocused()) {
tabView.webContents.focus();
const focusTab = () => {
if (this.isDestroyed() || tabView.isDestroyed || this.activeTabView !== tabView) {
return;
}
}, 30);
tabView.webContents.focus();
// The new tab sometimes loses focus immediately after switching.
const retryFocus = () => {
if (!tabView.isDestroyed && this.activeTabView === tabView && !tabView.webContents.isFocused()) {
tabView.webContents.focus();
}
};
setTimeout(retryFocus, 10);
setTimeout(retryFocus, 30);
};
// Let Windows activate the HWND before Chromium assigns the initial text-input focus.
// Focusing a hidden tab leaves the TSF composition window anchored at the screen origin.
if (process.platform === "win32" && !this.isVisible()) {
this.once("focus", focusTab);
} else {
focusTab();
}
}

private finalizePositioning() {
Expand Down
7 changes: 6 additions & 1 deletion frontend/app/view/term/termwrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
WOS,
} from "@/store/global";
import * as services from "@/store/services";
import { PLATFORM, PlatformMacOS } from "@/util/platformutil";
import { isWindows, PLATFORM, PlatformMacOS } from "@/util/platformutil";
import { base64ToArray, fireAndForget } from "@/util/util";
import { FitAddon } from "@xterm/addon-fit";
import { SearchAddon } from "@xterm/addon-search";
Expand Down Expand Up @@ -272,6 +272,11 @@ export class TermWrap {
this.heldData = [];
this.handleResize_debounced = debounce(50, this.handleResize.bind(this));
this.terminal.open(this.connectElem);
if (isWindows()) {
// Give Windows IME a usable anchor inside the terminal before xterm positions the
// hidden textarea on the first cursor movement.
this.terminal.textarea?.classList.add("wave-windows-ime-anchor");
}

const dragoverHandler = (e: DragEvent) => {
e.preventDefault();
Expand Down
7 changes: 7 additions & 0 deletions frontend/app/view/term/xterm.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
resize: none;
}

.xterm .xterm-helper-textarea.wave-windows-ime-anchor {
/* Give Windows IME a usable anchor before xterm positions the textarea on cursor movement. */
left: 0;
min-width: 1px;
min-height: 1px;
}

.xterm .composition-view {
/* TODO: Composition position got messed up somewhere */
background: #000;
Expand Down