aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDarksome <[email protected]>2022-08-20 13:26:31 +0300
committerDarksome <[email protected]>2022-08-20 13:26:31 +0300
commit776750ee3473fd0ca44969a9a1c79679e5805a0f (patch)
tree48166008a3a2dabb7ffcd8dadcf869dab580f214
parent37e1450a4d028d974a7d38742a7bc5b093efa263 (diff)
parent4af95d42537e32805e4f679715dc3e763c15e328 (diff)
downloadHyprland-776750ee3473fd0ca44969a9a1c79679e5805a0f.tar.gz
Hyprland-776750ee3473fd0ca44969a9a1c79679e5805a0f.zip
Merge branch 'main' of github.com:xDarksome/Hyprland
-rw-r--r--src/debug/HyprCtl.cpp8
-rw-r--r--src/helpers/WLClasses.hpp3
-rw-r--r--src/managers/input/InputManager.cpp45
-rw-r--r--src/managers/input/InputManager.hpp3
-rw-r--r--src/managers/input/Touch.cpp21
-rw-r--r--src/render/Renderer.cpp16
6 files changed, 77 insertions, 19 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 7b36a6ce..2f5660df 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -310,7 +310,8 @@ R"#( {
"layout": "%s",
"variant": "%s",
"options": "%s",
- "active_keymap": "%s"
+ "active_keymap": "%s",
+ "main": %s
},)#",
&k,
escapeJSONStrings(k.keyboard->name).c_str(),
@@ -319,7 +320,8 @@ R"#( {
escapeJSONStrings(k.currentRules.layout).c_str(),
escapeJSONStrings(k.currentRules.variant).c_str(),
escapeJSONStrings(k.currentRules.options).c_str(),
- escapeJSONStrings(KM).c_str()
+ escapeJSONStrings(KM).c_str(),
+ (k.active ? "true" : "false")
);
}
@@ -386,7 +388,7 @@ R"#( {
for (auto& k : g_pInputManager->m_lKeyboards) {
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
- result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n", &k, k.keyboard->name, k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str(), KM.c_str());
+ result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k, k.keyboard->name, k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str(), KM.c_str(), (k.active ? "yes" : "no"));
}
result += "\n\nTablets:\n";
diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp
index 31a24793..6b0787bb 100644
--- a/src/helpers/WLClasses.hpp
+++ b/src/helpers/WLClasses.hpp
@@ -94,11 +94,14 @@ struct SKeyboard {
DYNLISTENER(keyboardMod);
DYNLISTENER(keyboardKey);
+ DYNLISTENER(keyboardKeymap);
DYNLISTENER(keyboardDestroy);
bool isVirtual = false;
bool active = false;
+ xkb_layout_index_t activeLayout = 0;
+
std::string name = "";
SStringRuleNames currentRules;
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 95b30587..f8899f62 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -441,10 +441,19 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
- if (m_pActiveKeyboard)
- m_pActiveKeyboard->active = false;
+ PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
+ const auto PKEYBOARD = (SKeyboard*)owner;
+
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+
+ }, PNEWKEYBOARD, "Keyboard");
+
+ disableAllKeyboards(false);
+
m_pActiveKeyboard = PNEWKEYBOARD;
+ PNEWKEYBOARD->active = true;
+
applyConfigToKeyboard(PNEWKEYBOARD);
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard));
@@ -467,11 +476,19 @@ void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
+ PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
+ const auto PKEYBOARD = (SKeyboard*)owner;
+
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+
+ }, PNEWKEYBOARD, "Keyboard");
+
+ disableAllKeyboards(true);
- if (m_pActiveKeyboard)
- m_pActiveKeyboard->active = false;
m_pActiveKeyboard = PNEWKEYBOARD;
+ PNEWKEYBOARD->active = true;
+
applyConfigToKeyboard(PNEWKEYBOARD);
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(keyboard));
@@ -582,6 +599,8 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
xkb_keymap_unref(KEYMAP);
xkb_context_unref(CONTEXT);
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," +getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
+
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name);
}
@@ -735,6 +754,14 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard));
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers);
}
+
+ const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
+
+ if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
+ pKeyboard->activeLayout = PWLRKB->modifiers.group;
+
+ g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
+ }
}
void CInputManager::refocus() {
@@ -906,3 +933,13 @@ std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
return "none";
}
+
+void CInputManager::disableAllKeyboards(bool virt) {
+
+ for (auto& k : m_lKeyboards) {
+ if (k.isVirtual != virt)
+ continue;
+
+ k.active = false;
+ }
+} \ No newline at end of file
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 6f472521..9ced0e8d 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -14,6 +14,7 @@ enum eClickBehaviorMode {
struct STouchData {
CWindow* touchFocusWindow = nullptr;
+ Vector2D touchSurfaceOrigin;
};
class CInputManager {
@@ -106,6 +107,8 @@ private:
void processMouseDownNormal(wlr_pointer_button_event* e);
void processMouseDownKill(wlr_pointer_button_event* e);
+ void disableAllKeyboards(bool virt = false);
+
uint32_t m_uiCapabilities = 0;
void mouseMoveUnified(uint32_t, bool refocus = false);
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index 0b3c8961..daf34200 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -10,9 +10,16 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
m_sTouchData.touchFocusWindow = nullptr;
if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) {
- wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, g_pCompositor->m_pLastFocus, e->time_msec, e->touch_id,
- e->x * g_pCompositor->m_pLastMonitor->vecSize.x + g_pCompositor->m_pLastMonitor->vecPosition.x - g_pCompositor->m_pLastWindow->m_vRealPosition.vec().x,
- e->y * g_pCompositor->m_pLastMonitor->vecSize.y + g_pCompositor->m_pLastMonitor->vecPosition.y - g_pCompositor->m_pLastWindow->m_vRealPosition.vec().y);
+ Vector2D local;
+ if (g_pCompositor->m_pLastWindow->m_bIsX11) {
+ local = g_pInputManager->getMouseCoordsInternal() - g_pCompositor->m_pLastWindow->m_vRealPosition.goalv();
+ } else {
+ g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), g_pCompositor->m_pLastWindow, local);
+ }
+
+ m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
+
+ wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, g_pCompositor->m_pLastFocus, e->time_msec, e->touch_id, local.x, local.y);
m_sTouchData.touchFocusWindow = g_pCompositor->m_pLastWindow;
}
@@ -29,10 +36,10 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e){
if (g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID);
- wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id,
- e->x * PMONITOR->vecSize.x + PMONITOR->vecPosition.x - m_sTouchData.touchFocusWindow->m_vRealPosition.vec().x,
- e->y * PMONITOR->vecSize.y + PMONITOR->vecPosition.y - m_sTouchData.touchFocusWindow->m_vRealPosition.vec().y);
-
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
+
+ const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
+
+ wlr_seat_touch_notify_motion(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id, local.x, local.y);
}
} \ No newline at end of file
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index cc21c1bb..71440dc7 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -79,16 +79,22 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor) {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID) {
- if (!(!PWORKSPACE->m_bHasFullscreenWindow || pWindow->m_bIsFullscreen || (pWindow->m_bIsFloating && pWindow->m_bCreatedOverFullscreen)))
- return false;
+ if (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated()) {
+ return true;
+ } else {
+ if (!(!PWORKSPACE->m_bHasFullscreenWindow || pWindow->m_bIsFullscreen || (pWindow->m_bIsFloating && pWindow->m_bCreatedOverFullscreen)))
+ return false;
+ }
}
if (pWindow->m_iWorkspaceID == pMonitor->activeWorkspace)
return true;
- // if not, check if it maybe is active on a different monitor. vvv might be animation in progress
- if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && PWORKSPACE->m_bForceRendering) || (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
- return true;
+ // if not, check if it maybe is active on a different monitor.
+ if (g_pCompositor->isWorkspaceVisible(pWindow->m_iWorkspaceID) ||
+ (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && PWORKSPACE->m_bForceRendering) || // vvvv might be in animation progress vvvvv
+ (PWORKSPACE && PWORKSPACE->m_iMonitorID == pMonitor->ID && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated())))
+ return !pWindow->m_bIsFullscreen; // Do not draw fullscreen windows on other monitors
if (pMonitor->specialWorkspaceOpen && pWindow->m_iWorkspaceID == SPECIAL_WORKSPACE_ID)
return true;