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
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)_
```
yay -S hyprland-git

View File

@ -54,6 +54,7 @@ CCompositor::CCompositor() {
m_sWLRSubCompositor = wlr_subcompositor_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_screencopy_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;
}
if (m_pLastWindow == pWindow)
if (m_pLastWindow == pWindow && m_sSeat.seat->keyboard_state.focused_surface == pSurface)
return;
if (windowValidMapped(m_pLastWindow) && m_pLastWindow->m_bIsX11) {
@ -380,8 +381,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
g_pXWaylandManager->activateWindow(pWindow, true);
// do pointer focus too
wlr_seat_pointer_notify_enter(m_sSeat.seat, PWINDOWSURFACE, 0, 0);
// do pointer focus too
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;
}

View File

@ -50,6 +50,7 @@ public:
wlr_egl* m_sWLREGL;
int m_iDRMFD;
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();
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.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 refreshRate = 60;
int defaultWorkspaceID = -1;
bool disabled = false;
};
struct SWindowRule {

View File

@ -145,16 +145,18 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
}
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
if (layersurface->layerSurface->current.committed != 0) {
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
if (layersurface->layer != layersurface->layerSurface->current.layer) {
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface);
PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->current.layer].push_back(layersurface);
layersurface->layer = layersurface->layerSurface->current.layer;
if (layersurface->layer != layersurface->layerSurface->current.layer) {
PMONITOR->m_aLayerSurfaceLists[layersurface->layer].remove(layersurface);
PMONITOR->m_aLayerSurfaceLists[layersurface->layerSurface->current.layer].push_back(layersurface);
layersurface->layer = layersurface->layerSurface->current.layer;
}
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
}
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMONITOR->ID);
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
g_pHyprRenderer->damageBox(&layersurface->geometry);

View File

@ -45,6 +45,16 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
// new monitor added, let's accomodate for that.
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;
newMonitor.output = OUTPUT;
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);
// get monitor rule that matches
SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(OUTPUT->name);
wlr_output_set_scale(OUTPUT, 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
@ -138,7 +145,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
PNEWMONITOR->damage = wlr_output_damage_create(OUTPUT);
// 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);
const auto PNEWWORKSPACE = &g_pCompositor->m_lWorkspaces.back();

View File

@ -20,6 +20,7 @@
#include <mutex>
#include <thread>
#include <filesystem>
#include <climits>
#if true
@ -42,6 +43,7 @@ extern "C" {
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_data_device.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_idle.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 == "togglegroup") { toggleGroup(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;
}
@ -130,10 +133,28 @@ void CKeybindManager::toggleActivePseudo(std::string args) {
void CKeybindManager::changeworkspace(std::string args) {
int workspaceToChangeTo = 0;
try {
workspaceToChangeTo = stoi(args);
} catch (...) {
Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
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 {
workspaceToChangeTo = stoi(args);
} catch (...) {
Debug::log(ERR, "Invalid arg \"%s\" in changeWorkspace!", args.c_str());
return;
}
}
// 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);
// focus
g_pInputManager->refocus();
return;
}
@ -201,6 +225,9 @@ void CKeybindManager::changeworkspace(std::string args) {
// mark the monitor dirty
g_pHyprRenderer->damageMonitor(PMONITOR);
// focus (clears the last)
g_pInputManager->refocus();
Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo);
}