Skip to content
Draft
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
43 changes: 15 additions & 28 deletions Services/Compositor/SwayService.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Item {
return;
try {
I3.refreshWorkspaces();
I3.dispatch('(["input"])');
Qt.callLater(() => {
safeUpdateWorkspaces();
safeUpdateWindows();
Expand Down Expand Up @@ -111,16 +110,6 @@ Item {
}
}

Timer {
id: keyboardLayoutUpdateTimer
interval: 1000
running: true
repeat: true
onTriggered: {
queryKeyboardLayout();
}
}

function queryKeyboardLayout() {
swayInputsProcess.running = true;
}
Expand Down Expand Up @@ -290,22 +279,17 @@ Item {

function handleInputEvent(ev) {
try {
let beforeParenthesis;
const parenthesisPos = ev.lastIndexOf('(');

if (parenthesisPos === -1) {
beforeParenthesis = ev;
} else {
beforeParenthesis = ev.substring(0, parenthesisPos);
const eventData = JSON.parse(ev);
if (eventData.change == "xkb_layout" && eventData.input != null) {
const input = eventData.input;
if (input.type == "keyboard" && input.xkb_active_layout_name != null) {
const layoutName = input.xkb_active_layout_name;
KeyboardLayoutService.setCurrentLayout(layoutName);
Logger.d("SwayService", "Keyboard layout switched:", layoutName);
}
}

const layoutNameStart = beforeParenthesis.lastIndexOf(',') + 1;
const layoutName = ev.substring(layoutNameStart);

KeyboardLayoutService.setCurrentLayout(layoutName);
Logger.d("HyprlandService", "Keyboard layout switched:", layoutName);
} catch (e) {
Logger.e("HyprlandService", "Error handling activelayout:", e);
Logger.e("SwayService", "Error handling input event:", e);
}
}

Expand Down Expand Up @@ -338,10 +322,13 @@ Item {
if (event.type === "output") {
Qt.callLater(queryDisplayScales);
}
}
}

if (event.type == "get_inputs") {
handleInputEvent(event.data);
}
I3IpcListener {
subscriptions: ["input"]
onIpcEvent: function (event) {
handleInputEvent(event.data);
}
}

Expand Down