Merge branch 'main' into damage-tracking

This commit is contained in:
vaxerski 2022-04-17 11:52:54 +02:00 committed by GitHub
commit baa9e0caea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 70 additions and 18 deletions

View file

@ -51,6 +51,8 @@ Hyprland needs testers! Try it out and report bugs or suggestions!
# Installation # Installation
I do not maintain any packages, but some kind people have made them for me. If I missed any, please let me know. I do not maintain any packages, but some kind people have made them for me. If I missed any, please let me know.
**Warning:** since I am not the maintainer, I cannot guarantee that those packages will always work and be up to date. Use at your own disclosure. If they don't, try building manually.
_Arch (AUR, -git)_ _Arch (AUR, -git)_
``` ```
yay -S hyprland-git yay -S hyprland-git

View file

@ -54,6 +54,7 @@ CCompositor::CCompositor() {
m_sWLRSubCompositor = wlr_subcompositor_create(m_sWLDisplay); m_sWLRSubCompositor = wlr_subcompositor_create(m_sWLDisplay);
m_sWLRDataDevMgr = wlr_data_device_manager_create(m_sWLDisplay); m_sWLRDataDevMgr = wlr_data_device_manager_create(m_sWLDisplay);
m_sWLRDmabuf = wlr_linux_dmabuf_v1_create(m_sWLDisplay, m_sWLRRenderer);
wlr_export_dmabuf_manager_v1_create(m_sWLDisplay); wlr_export_dmabuf_manager_v1_create(m_sWLDisplay);
wlr_screencopy_manager_v1_create(m_sWLDisplay); wlr_screencopy_manager_v1_create(m_sWLDisplay);
wlr_data_control_manager_v1_create(m_sWLDisplay); wlr_data_control_manager_v1_create(m_sWLDisplay);
@ -366,7 +367,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
return; return;
} }
if (m_pLastWindow == pWindow) if (m_pLastWindow == pWindow && m_sSeat.seat->keyboard_state.focused_surface == pSurface)
return; return;
if (windowValidMapped(m_pLastWindow) && m_pLastWindow->m_bIsX11) { if (windowValidMapped(m_pLastWindow) && m_pLastWindow->m_bIsX11) {
@ -381,7 +382,8 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
g_pXWaylandManager->activateWindow(pWindow, true); g_pXWaylandManager->activateWindow(pWindow, true);
// do pointer focus too // do pointer focus too
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, 0, 0); const auto POINTERLOCAL = g_pInputManager->getMouseCoordsInternal() - pWindow->m_vRealPosition;
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, POINTERLOCAL.x, POINTERLOCAL.y);
m_pLastWindow = pWindow; m_pLastWindow = pWindow;
} }

View file

@ -50,6 +50,7 @@ public:
wlr_egl* m_sWLREGL; wlr_egl* m_sWLREGL;
int m_iDRMFD; int m_iDRMFD;
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr; wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
wlr_linux_dmabuf_v1* m_sWLRDmabuf;
// ------------------------------------------------- // // ------------------------------------------------- //

View file

@ -145,6 +145,14 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
nextItem(); nextItem();
if (curitem == "disable" || curitem == "disabled") {
newrule.disabled = true;
m_dMonitorRules.push_back(newrule);
return;
}
newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x'))); newrule.resolution.x = stoi(curitem.substr(0, curitem.find_first_of('x')));
newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@'))); newrule.resolution.y = stoi(curitem.substr(curitem.find_first_of('x') + 1, curitem.find_first_of('@')));

View file

@ -26,6 +26,7 @@ struct SMonitorRule {
float scale = 1; float scale = 1;
float refreshRate = 60; float refreshRate = 60;
int defaultWorkspaceID = -1; int defaultWorkspaceID = -1;
bool disabled = false;
}; };
struct SWindowRule { struct SWindowRule {

View file

@ -145,6 +145,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID); g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
} }
if (layersurface->layerSurface->current.committed != 0) {
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID); g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
if (layersurface->layer != layersurface->layerSurface->current.layer) { if (layersurface->layer != layersurface->layerSurface->current.layer) {
@ -154,6 +155,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
} }
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
}
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y); layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);

View file

@ -45,6 +45,16 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
// new monitor added, let's accomodate for that. // new monitor added, let's accomodate for that.
const auto OUTPUT = (wlr_output*)data; const auto OUTPUT = (wlr_output*)data;
// get monitor rule that matches
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name);
// if it's disabled, disable and ignore
if (monitorRule.disabled) {
wlr_output_enable(OUTPUT, 0);
wlr_output_commit(OUTPUT);
return;
}
SMonitor newMonitor; SMonitor newMonitor;
newMonitor.output = OUTPUT; newMonitor.output = OUTPUT;
newMonitor.ID = g_pCompositor->m_lMonitors.size(); newMonitor.ID = g_pCompositor->m_lMonitors.size();
@ -52,9 +62,6 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
wlr_output_init_render(OUTPUT, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer); wlr_output_init_render(OUTPUT, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer);
// get monitor rule that matches
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name);
wlr_output_set_scale(OUTPUT, monitorRule.scale); wlr_output_set_scale(OUTPUT, monitorRule.scale);
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, monitorRule.scale); wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, monitorRule.scale);
wlr_output_set_transform(OUTPUT, WL_OUTPUT_TRANSFORM_NORMAL); // TODO: support other transforms wlr_output_set_transform(OUTPUT, WL_OUTPUT_TRANSFORM_NORMAL); // TODO: support other transforms
@ -138,7 +145,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
PNEWMONITOR->damage = wlr_output_damage_create(OUTPUT); PNEWMONITOR->damage = wlr_output_damage_create(OUTPUT);
// Workspace // Workspace
const auto WORKSPACEID = monitorRule.defaultWorkspaceID == -1 ? g_pCompositor->m_lWorkspaces.size() : monitorRule.defaultWorkspaceID; const auto WORKSPACEID = monitorRule.defaultWorkspaceID == -1 ? g_pCompositor->m_lWorkspaces.size() + 1 /* Cuz workspaces doesnt have the new one yet and we start with 1 */ : monitorRule.defaultWorkspaceID;
g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID); g_pCompositor->m_lWorkspaces.emplace_back(newMonitor.ID);
const auto PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back(); const auto PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back();

View file

@ -20,6 +20,7 @@
#include <mutex> #include <mutex>
#include <thread> #include <thread>
#include <filesystem> #include <filesystem>
#include <climits>
#if true #if true
@ -42,6 +43,7 @@ extern "C" {
#include <wlr/types/wlr_data_control_v1.h> #include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h> #include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>

View file

@ -56,6 +56,9 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
else if (k.handler == "movefocus") { moveFocusTo(k.arg); } else if (k.handler == "movefocus") { moveFocusTo(k.arg); }
else if (k.handler == "togglegroup") { toggleGroup(k.arg); } else if (k.handler == "togglegroup") { toggleGroup(k.arg); }
else if (k.handler == "changegroupactive") { changeGroupActive(k.arg); } else if (k.handler == "changegroupactive") { changeGroupActive(k.arg); }
else {
Debug::log(ERR, "Inavlid handler in a keybind! (handler %s does not exist)", k.handler.c_str());
}
found = true; found = true;
} }
@ -130,10 +133,28 @@ void CKeybindManager::toggleActivePseudo(std::string args) {
void CKeybindManager::changeworkspace(std::string args) { void CKeybindManager::changeworkspace(std::string args) {
int workspaceToChangeTo = 0; int workspaceToChangeTo = 0;
if (args.find_first_of("+") == 0) {
try {
workspaceToChangeTo = g_pCompositor->m_pLastMonitor->activeWorkspace + std::stoi(args.substr(1));
} catch (...) {
Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
return;
}
} else if (args.find_first_of("-") == 0) {
try {
workspaceToChangeTo = std::clamp(g_pCompositor->m_pLastMonitor->activeWorkspace - std::stoi(args.substr(1)), 1, INT_MAX);
} catch (...) {
Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
return;
}
} else {
try { try {
workspaceToChangeTo = stoi(args); workspaceToChangeTo = stoi(args);
} catch (...) { } catch (...) {
Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str()); Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
return;
}
} }
// if it exists, we warp to it // if it exists, we warp to it
@ -171,6 +192,9 @@ void CKeybindManager::changeworkspace(std::string args) {
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
// focus
g_pInputManager->refocus();
return; return;
} }
@ -201,6 +225,9 @@ void CKeybindManager::changeworkspace(std::string args) {
// mark the monitor dirty // mark the monitor dirty
g_pHyprRenderer->damageMonitor(PMONITOR); g_pHyprRenderer->damageMonitor(PMONITOR);
// focus (clears the last)
g_pInputManager->refocus();
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
} }