pull: Added a lot of fixes from pull requests

This commit is contained in:
Kaley, Fischer 2023-11-24 13:33:42 +01:00
parent 35ac2ef505
commit 32636aac4c
10 changed files with 85 additions and 59 deletions

View file

@ -23,39 +23,49 @@
#include <filesystem>
#include <stdarg.h>
const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args]
commands:
monitors
workspaces
activeworkspace
workspacerules
clients
activewindow
layers
devices
binds
dispatch
keyword
version
kill
splash
hyprpaper
reload
setcursor
getoption
cursorpos
switchxkblayout
seterror
setprop
plugin
notify
globalshortcuts
instances
layouts
flags:
const std::string USAGE = R"#(usage: hyprctl [flags] [<command> [args]]
hyprctl --batch {<command 1> [args] ; <command 2> [args] ; ...}
LISTING COMMANDS:
monitors: List outputs
workspaces: List all workspaces
activeworkspace: Get currently active workspace
clients: List clients (e.g. windows)
activewindow: Get currently active window
layers: List layers
animations: List animations and bezier curves in use
devices: List devices
binds: List registered binds
instances: List running Hyprland instances
layouts: List layouts
globalshortcuts: List global shortcuts
version: Print hyprland version
CONFIGURATION COMMANDS:
keyword <keyword> [args]: Execute a keyword
getoption <option>: Get value of <option>
reload: Reload configurations
PLUGIN:
plugin list: List loaded plugins
plugin load <path>: Load plugin from <path>
plugin unload <path>: Unload plugin at <path>
THEMING:
hyprpaper <keywords> Issue hyprpaper keywords using IPC
splash: Prints the current random splash
cursorpos: Get the current cursor position in global layout coordinates
setcursor <theme> <size>: Set cursor theme and size, (except for GTK)
ADDITIONAL COMMANDS:
dispatch <name> [args]: Run a dispatcher
kill: Enter kill mode, where you can kill an app by clicking on it,
use ESCAPE to quit kill mode
switchxkblayout <args>: Sets the xkb layout index for a keyboard, see wiki for details
setprop <window> <prop>: Set window property, see wiki for details
seterror <color> <msg>: Display <msg> as a error message, will reset upon reloading config
seterror disable: Clear error message
notify <icon> <time_ms> <color> <message>:
Sends a notification using the built-in Hyprland notification system.
output <args>: Add and remove fake outputs to specified backend, see wiki for details.
FLAGS:
-j -> output in JSON
--help -> display this help
--batch -> execute a batch of commands, separated by ';'
--instance (-i) -> use a specific instance. Can be either signature or index in hyprctl instances (0, 1, etc)
)#";

View file

@ -519,15 +519,14 @@ void CCompositor::startCompositor() {
signal(SIGPIPE, SIG_IGN);
if (m_sWLRSession /* Session-less Hyprland usually means a nest, don't update the env in that case */ && fork() == 0)
execl(
"/bin/sh", "/bin/sh", "-c",
if (m_sWLRSession /* Session-less Hyprland usually means a nest, don't update the env in that case */) {
const auto CMD =
#ifdef USES_SYSTEMD
"systemctl --user import-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP && hash dbus-update-activation-environment 2>/dev/null && "
#endif
"dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE",
nullptr);
"dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE";
g_pKeybindManager->spawn(CMD);
}
Debug::log(LOG, "Running on WAYLAND_DISPLAY: {}", m_szWLDisplaySocket);
if (!wlr_backend_start(m_sWLRBackend)) {
@ -1125,6 +1124,21 @@ CWindow* CCompositor::getWindowFromHandle(uint32_t handle) {
return nullptr;
}
SIMEPopup* CCompositor::vectorToIMEPopup(const Vector2D& pos, std::list<SIMEPopup>* popups) {
for (auto& popup : *popups) {
auto surface = popup.pSurface->surface;
CBox box{
popup.realX,
popup.realY,
surface->current.width,
surface->current.height,
};
if (box.containsPoint(pos))
return &popup;
}
return nullptr;
}
CWindow* CCompositor::getWindowFromZWLRHandle(wl_resource* handle) {
for (auto& w : m_vWindows) {
if (!w->m_bIsMapped || w->isHidden() || !w->m_phForeignToplevel)

View file

@ -139,6 +139,7 @@ class CCompositor {
CWindow* vectorToWindowIdeal(const Vector2D&, CWindow* pIgnoreWindow = nullptr); // used only for finding a window to focus on, basically a "findFocusableWindow"
CWindow* vectorToWindowTiled(const Vector2D&);
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
SIMEPopup* vectorToIMEPopup(const Vector2D& pos, std::list<SIMEPopup>* popups);
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
Vector2D vectorToSurfaceLocal(const Vector2D&, CWindow*, wlr_surface*);
CWindow* windowFromCursor();

View file

@ -271,6 +271,7 @@ void CConfigManager::setDefaultVars() {
configValues["xwayland:use_nearest_neighbor"].intValue = 1;
configValues["xwayland:force_zero_scaling"].intValue = 0;
configValues["xwayland:enabled"].intValue = 1;
configValues["autogenerated"].intValue = 0;
}

View file

@ -754,10 +754,7 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
#ifdef LEGACY_RENDERER
result += "legacyrenderer\n";
#endif
#ifndef NDEBUG
result += "debug\n";
#endif
#ifdef HYPRLAND_DEBUG
#ifndef ISDEBUG
result += "debug\n";
#endif
#ifdef NO_XWAYLAND
@ -779,10 +776,7 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
#ifdef LEGACY_RENDERER
result += "\"legacyrenderer\",";
#endif
#ifndef NDEBUG
result += "\"debug\",";
#endif
#ifdef HYPRLAND_DEBUG
#ifndef ISDEBUG
result += "\"debug\",";
#endif
#ifdef NO_XWAYLAND

View file

@ -101,8 +101,7 @@ int main(int argc, char** argv) {
g_pCompositor->initServer();
if (!getenv("HYPRLAND_NO_RT") || configStringToInt(std::string(getenv("HYPRLAND_NO_RT"))) == 0)
Init::gainRealTime();
Init::gainRealTime();
Debug::log(LOG, "Hyprland init finished.");

View file

@ -641,11 +641,6 @@ void CKeybindManager::spawn(std::string args) {
args = args.substr(args.find_first_of(']') + 1);
}
if (g_pXWaylandManager->m_sWLRXWayland)
args = "WAYLAND_DISPLAY=" + std::string(g_pCompositor->m_szWLDisplaySocket) + " DISPLAY=" + std::string(g_pXWaylandManager->m_sWLRXWayland->display_name) + " " + args;
else
args = "WAYLAND_DISPLAY=" + std::string(g_pCompositor->m_szWLDisplaySocket) + " " + args;
const uint64_t PROC = spawnRaw(args);
if (!RULES.empty()) {
@ -735,11 +730,10 @@ void CKeybindManager::clearKeybinds() {
void CKeybindManager::toggleActiveFloating(std::string args) {
CWindow* PWINDOW = nullptr;
if (args != "" && args != "active" && args.length() > 1) {
if (args != "" && args != "active" && args.length() > 1)
PWINDOW = g_pCompositor->getWindowByRegex(args);
} else {
else
PWINDOW = g_pCompositor->m_pLastWindow;
}
if (!PWINDOW)
return;

View file

@ -9,6 +9,10 @@
CHyprXWaylandManager::CHyprXWaylandManager() {
#ifndef NO_XWAYLAND
static auto* const XWAYLANDENABLED = &g_pConfigManager->getConfigValuePtr("xwayland:enabled")->intValue;
if (!*XWAYLANDENABLED)
return;
m_sWLRXWayland = wlr_xwayland_create(g_pCompositor->m_sWLDisplay, g_pCompositor->m_sWLRCompositor, 1);
if (!m_sWLRXWayland) {

View file

@ -233,10 +233,20 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
surfacePos = PMONITOR->vecPosition;
}
// overlay is above fullscreen
// overlay are above fullscreen
if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords, &pFoundLayerSurface);
// also IME popups
if (!foundSurface) {
auto popup = g_pCompositor->vectorToIMEPopup(mouseCoords, &m_sIMERelay.m_lIMEPopups);
if (popup) {
foundSurface = popup->pSurface->surface;
surfacePos = Vector2D(popup->realX, popup->realY);
}
}
// also top layers
if (!foundSurface)
foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface);
@ -471,7 +481,6 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
}
void CInputManager::processMouseRequest(wlr_seat_pointer_request_set_cursor_event* e) {
if (!e->surface)
g_pHyprRenderer->m_bWindowRequestedCursorHide = true;
else

View file

@ -418,7 +418,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
// if window is floating and we have a slide animation, clip it to its full bb
if (!ignorePosition && pWindow->m_bIsFloating && !pWindow->m_bIsFullscreen && PWORKSPACE->m_vRenderOffset.isBeingAnimated()) {
CRegion rg = pWindow->getFullWindowBoundingBox().translate(-pMonitor->vecPosition);
CRegion rg = pWindow->getFullWindowBoundingBox().translate(-pMonitor->vecPosition + PWORKSPACE->m_vRenderOffset.vec()).scale(pMonitor->scale);
rg.add(CBox{0, 0, pMonitor->vecSize.x, pMonitor->vecSize.y});
g_pHyprOpenGL->m_RenderData.clipBox = rg.getExtents();
}