mirror of
https://github.com/hyprwm/hyprpaper.git
synced 2024-11-16 22:25:59 +01:00
Various improvements considering the modern C++ practices
This commit is contained in:
parent
034a663dbb
commit
1df6080535
18 changed files with 164 additions and 52 deletions
114
.clang-format
Normal file
114
.clang-format
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
Standard: Auto
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: DontAlign
|
||||||
|
AlignArrayOfStructures: None
|
||||||
|
AlignConsecutiveAssignments: None
|
||||||
|
AlignConsecutiveBitFields: Consecutive
|
||||||
|
AlignConsecutiveDeclarations: None
|
||||||
|
AlignConsecutiveMacros: None
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: DontAlign
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: false
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: false
|
||||||
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BitFieldColonSpacing: Both
|
||||||
|
BreakAfterJavaFieldAnnotations: true
|
||||||
|
BreakBeforeBinaryOperators: NonAssignment
|
||||||
|
BreakBeforeConceptDeclarations: true
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializers: BeforeComma
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 0
|
||||||
|
CompactNamespaces: true
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 8
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
EmptyLineAfterAccessModifier: Never
|
||||||
|
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||||
|
FixNamespaceComments: false
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeIsMainRegex: (Test)?$
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentAccessModifiers: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentWidth: 4
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
LambdaBodyIndentation: Signature
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: All
|
||||||
|
PPIndentWidth: -1
|
||||||
|
PackConstructorInitializers: BinPack
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakOpenParenthesis: 0
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyIndentedWhitespace: 0
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Left
|
||||||
|
QualifierAlignment: Leave
|
||||||
|
ReferenceAlignment: Pointer
|
||||||
|
ReflowComments: true
|
||||||
|
RemoveBracesLLVM: false
|
||||||
|
SeparateDefinitionBlocks: Leave
|
||||||
|
ShortNamespaceLines: 1
|
||||||
|
SortIncludes: CaseSensitive
|
||||||
|
SortJavaStaticImport: Before
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceAroundPointerQualifiers: Default
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCaseColon: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
SpaceInEmptyBlock: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: Never
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
TabWidth: 4
|
||||||
|
UseCRLF: false
|
||||||
|
UseTab: Never
|
||||||
|
...
|
6
.clang-tidy
Normal file
6
.clang-tidy
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
Checks: '-*,clang-diagnostic-*,bugprone-*,cert-*,misc-*,modernize-*,performance-*,readability-*,hicpp-exception-baseclass,hicpp-avoid-goto,-clang-diagnostic-address-of-packed-member,-cert-dcl16-c,-cert-dcl21-cpp,-cert-err58-cpp,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-modernize-avoid-c-arrays,-modernize-concat-nested-namespaces,-modernize-raw-string-literal,-modernize-use-default-member-init,-modernize-use-nodiscard,-modernize-use-override,-modernize-use-trailing-return-type,-readability-else-after-return,-readability-identifier-naming,-readability-implicit-bool-cast,-readability-implicit-bool-conversion,-readability-magic-numbers,-readability-named-parameter,-readability-qualified-auto,-readability-redundant-access-specifiers,-readability-redundant-member-init,-readability-uppercase-literal-suffix'
|
||||||
|
WarningsAsErrors: '*'
|
||||||
|
HeaderFilterRegex: ''
|
||||||
|
FormatStyle: none
|
||||||
|
...
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -12,6 +12,7 @@ _deps
|
||||||
build/
|
build/
|
||||||
result
|
result
|
||||||
/.vscode/
|
/.vscode/
|
||||||
|
/.idea
|
||||||
|
|
||||||
*.o
|
*.o
|
||||||
*-protocol.c
|
*-protocol.c
|
||||||
|
@ -22,4 +23,4 @@ hyprctl/hyprctl
|
||||||
|
|
||||||
gmon.out
|
gmon.out
|
||||||
*.out
|
*.out
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "Hyprpaper.hpp"
|
#include "Hyprpaper.hpp"
|
||||||
|
|
||||||
CHyprpaper::CHyprpaper() { }
|
CHyprpaper::CHyprpaper() = default;
|
||||||
|
|
||||||
void CHyprpaper::init() {
|
void CHyprpaper::init() {
|
||||||
|
|
||||||
|
@ -9,12 +9,11 @@ void CHyprpaper::init() {
|
||||||
g_pConfigManager = std::make_unique<CConfigManager>();
|
g_pConfigManager = std::make_unique<CConfigManager>();
|
||||||
g_pIPCSocket = std::make_unique<CIPCSocket>();
|
g_pIPCSocket = std::make_unique<CIPCSocket>();
|
||||||
|
|
||||||
m_sDisplay = (wl_display *)wl_display_connect(NULL);
|
m_sDisplay = (wl_display *)wl_display_connect(nullptr);
|
||||||
|
|
||||||
if (!m_sDisplay) {
|
if (!m_sDisplay) {
|
||||||
Debug::log(CRIT, "No wayland compositor running!");
|
Debug::log(CRIT, "No wayland compositor running!");
|
||||||
exit(1);
|
exit(1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
preloadAllWallpapersFromConfig();
|
preloadAllWallpapersFromConfig();
|
||||||
|
@ -35,7 +34,7 @@ void CHyprpaper::init() {
|
||||||
m_bShouldExit = true;
|
m_bShouldExit = true;
|
||||||
}).detach();
|
}).detach();
|
||||||
|
|
||||||
while (1) { // we also tick every 1ms for socket and other shit's updates
|
while (true) { // we also tick every 1ms for socket and other shit's updates
|
||||||
tick(false);
|
tick(false);
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||||
|
@ -352,7 +351,7 @@ void CHyprpaper::createBuffer(SPoolBuffer* pBuffer, int32_t w, int32_t h, uint32
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DATA = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, FD, 0);
|
const auto DATA = mmap(nullptr, SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, FD, 0);
|
||||||
const auto POOL = wl_shm_create_pool(g_pHyprpaper->m_sSHM, FD, SIZE);
|
const auto POOL = wl_shm_create_pool(g_pHyprpaper->m_sSHM, FD, SIZE);
|
||||||
pBuffer->buffer = wl_shm_pool_create_buffer(POOL, 0, w, h, STRIDE, format);
|
pBuffer->buffer = wl_shm_pool_create_buffer(POOL, 0, w, h, STRIDE, format);
|
||||||
wl_shm_pool_destroy(POOL);
|
wl_shm_pool_destroy(POOL);
|
||||||
|
@ -470,4 +469,4 @@ void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,4 +60,4 @@ private:
|
||||||
bool m_bShouldExit = false;
|
bool m_bShouldExit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CHyprpaper> g_pHyprpaper;
|
inline std::unique_ptr<CHyprpaper> g_pHyprpaper;
|
||||||
|
|
|
@ -5,7 +5,7 @@ CConfigManager::CConfigManager() {
|
||||||
// init the entire thing
|
// init the entire thing
|
||||||
|
|
||||||
std::string configPath;
|
std::string configPath;
|
||||||
if (g_pHyprpaper->m_szExplicitConfigPath == "") {
|
if (g_pHyprpaper->m_szExplicitConfigPath.empty()) {
|
||||||
const char *const ENVHOME = getenv("HOME");
|
const char *const ENVHOME = getenv("HOME");
|
||||||
configPath = ENVHOME + (std::string) "/.config/hypr/hyprpaper.conf";
|
configPath = ENVHOME + (std::string) "/.config/hypr/hyprpaper.conf";
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ CConfigManager::CConfigManager() {
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
Debug::log(CRIT, "Hyprpaper was not provided a config!");
|
Debug::log(CRIT, "Hyprpaper was not provided a config!");
|
||||||
exit(1);
|
exit(1);
|
||||||
return; //jic
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string line = "";
|
std::string line = "";
|
||||||
|
@ -36,7 +35,7 @@ CConfigManager::CConfigManager() {
|
||||||
parseError += "Config error at line " + std::to_string(linenum) + ": Line parsing error.";
|
parseError += "Config error at line " + std::to_string(linenum) + ": Line parsing error.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseError != "" && parseError.find("Config error at line") != 0) {
|
if (!parseError.empty() && parseError.find("Config error at line") != 0) {
|
||||||
parseError = "Config error at line " + std::to_string(linenum) + ": " + parseError;
|
parseError = "Config error at line " + std::to_string(linenum) + ": " + parseError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ CConfigManager::CConfigManager() {
|
||||||
ifs.close();
|
ifs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parseError != "") {
|
if (!parseError.empty()) {
|
||||||
Debug::log(CRIT, "Exiting because of config parse errors!\n%s", parseError.c_str());
|
Debug::log(CRIT, "Exiting because of config parse errors!\n%s", parseError.c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -11,7 +11,7 @@ public:
|
||||||
std::deque<std::string> m_dRequestedPreloads;
|
std::deque<std::string> m_dRequestedPreloads;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string parseError = "";
|
std::string parseError;
|
||||||
|
|
||||||
void parseLine(std::string&);
|
void parseLine(std::string&);
|
||||||
std::string removeBeginEndSpacesTabs(std::string in);
|
std::string removeBeginEndSpacesTabs(std::string in);
|
||||||
|
@ -24,4 +24,4 @@ private:
|
||||||
friend class CIPCSocket;
|
friend class CIPCSocket;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CConfigManager> g_pConfigManager;
|
inline std::unique_ptr<CConfigManager> g_pConfigManager;
|
||||||
|
|
|
@ -14,4 +14,4 @@ enum LogLevel {
|
||||||
|
|
||||||
namespace Debug {
|
namespace Debug {
|
||||||
void log(LogLevel level, const char* fmt, ...);
|
void log(LogLevel level, const char* fmt, ...);
|
||||||
};
|
}
|
||||||
|
|
|
@ -26,4 +26,4 @@ namespace Events {
|
||||||
inline const zwlr_layer_surface_v1_listener layersurfaceListener = { .configure = ls_configure };
|
inline const zwlr_layer_surface_v1_listener layersurfaceListener = { .configure = ls_configure };
|
||||||
|
|
||||||
inline const struct wl_registry_listener registryListener = { .global = handleGlobal, .global_remove = handleGlobalRemove };
|
inline const struct wl_registry_listener registryListener = { .global = handleGlobal, .global_remove = handleGlobalRemove };
|
||||||
};
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ cairo_surface_t* JPEG::createSurfaceFromJPEG(const std::string& path) {
|
||||||
|
|
||||||
void* imageRawData;
|
void* imageRawData;
|
||||||
|
|
||||||
struct stat fileInfo;
|
struct stat fileInfo = {};
|
||||||
|
|
||||||
const auto FD = open(path.c_str(), O_RDONLY);
|
const auto FD = open(path.c_str(), O_RDONLY);
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ cairo_surface_t* JPEG::createSurfaceFromJPEG(const std::string& path) {
|
||||||
|
|
||||||
// now the JPEG is in the memory
|
// now the JPEG is in the memory
|
||||||
|
|
||||||
jpeg_decompress_struct decompressStruct;
|
jpeg_decompress_struct decompressStruct = {};
|
||||||
jpeg_error_mgr errorManager;
|
jpeg_error_mgr errorManager = {};
|
||||||
|
|
||||||
decompressStruct.err = jpeg_std_error(&errorManager);
|
decompressStruct.err = jpeg_std_error(&errorManager);
|
||||||
jpeg_create_decompress(&decompressStruct);
|
jpeg_create_decompress(&decompressStruct);
|
||||||
|
@ -72,4 +72,4 @@ cairo_surface_t* JPEG::createSurfaceFromJPEG(const std::string& path) {
|
||||||
jpeg_destroy_decompress(&decompressStruct);
|
jpeg_destroy_decompress(&decompressStruct);
|
||||||
|
|
||||||
return cairoSurface;
|
return cairoSurface;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ Vector2D::Vector2D(double xx, double yy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D::Vector2D() { x = 0; y = 0; }
|
Vector2D::Vector2D() { x = 0; y = 0; }
|
||||||
Vector2D::~Vector2D() {}
|
Vector2D::~Vector2D() = default;
|
||||||
|
|
||||||
double Vector2D::normalize() {
|
double Vector2D::normalize() {
|
||||||
// get max abs
|
// get max abs
|
||||||
|
@ -18,6 +18,6 @@ double Vector2D::normalize() {
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D Vector2D::floor() {
|
Vector2D Vector2D::floor() const {
|
||||||
return Vector2D((int)x, (int)y);
|
return {static_cast<int>(x), static_cast<int>(y)};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
|
|
||||||
class Vector2D {
|
class Vector2D {
|
||||||
public:
|
public:
|
||||||
|
@ -35,5 +35,5 @@ class Vector2D {
|
||||||
return a.x != x || a.y != y;
|
return a.x != x || a.y != y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D floor();
|
Vector2D floor() const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
|
|
||||||
#define class _class
|
#define class _class
|
||||||
#define namespace _namespace
|
#define namespace _namespace
|
||||||
|
@ -27,13 +27,13 @@ extern "C" {
|
||||||
|
|
||||||
#include <GLES3/gl32.h>
|
#include <GLES3/gl32.h>
|
||||||
#include <GLES3/gl3ext.h>
|
#include <GLES3/gl3ext.h>
|
||||||
#include <assert.h>
|
#include <cassert>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <cairo/cairo.h>
|
#include <cairo/cairo.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
#include "../Hyprpaper.hpp"
|
#include "../Hyprpaper.hpp"
|
||||||
|
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
|
|
||||||
void CIPCSocket::initialize() {
|
void CIPCSocket::initialize() {
|
||||||
std::thread([&]() {
|
std::thread([&]() {
|
||||||
|
@ -40,7 +40,7 @@ void CIPCSocket::initialize() {
|
||||||
// 10 max queued.
|
// 10 max queued.
|
||||||
listen(SOCKET, 10);
|
listen(SOCKET, 10);
|
||||||
|
|
||||||
sockaddr_in clientAddress;
|
sockaddr_in clientAddress = {};
|
||||||
socklen_t clientSize = sizeof(clientAddress);
|
socklen_t clientSize = sizeof(clientAddress);
|
||||||
|
|
||||||
char readBuffer[1024] = {0};
|
char readBuffer[1024] = {0};
|
||||||
|
@ -104,7 +104,7 @@ bool CIPCSocket::mainThreadParseRequest() {
|
||||||
|
|
||||||
g_pConfigManager->parseKeyword(copy.substr(0, copy.find_first_of(' ')), copy.substr(copy.find_first_of(' ') + 1));
|
g_pConfigManager->parseKeyword(copy.substr(0, copy.find_first_of(' ')), copy.substr(copy.find_first_of(' ') + 1));
|
||||||
|
|
||||||
if (g_pConfigManager->parseError != "") {
|
if (!g_pConfigManager->parseError.empty()) {
|
||||||
m_szReply = g_pConfigManager->parseError;
|
m_szReply = g_pConfigManager->parseError;
|
||||||
m_bReplyReady = true;
|
m_bReplyReady = true;
|
||||||
m_bRequestReady = false;
|
m_bRequestReady = false;
|
||||||
|
@ -123,4 +123,4 @@ bool CIPCSocket::mainThreadParseRequest() {
|
||||||
m_bRequestReady = false;
|
m_bRequestReady = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ CLayerSurface::CLayerSurface(SMonitor* pMonitor) {
|
||||||
if (!pSurface) {
|
if (!pSurface) {
|
||||||
Debug::log(CRIT, "The compositor did not allow hyprpaper a surface!");
|
Debug::log(CRIT, "The compositor did not allow hyprpaper a surface!");
|
||||||
exit(1);
|
exit(1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PINPUTREGION = wl_compositor_create_region(g_pHyprpaper->m_sCompositor);
|
const auto PINPUTREGION = wl_compositor_create_region(g_pHyprpaper->m_sCompositor);
|
||||||
|
@ -18,7 +17,6 @@ CLayerSurface::CLayerSurface(SMonitor* pMonitor) {
|
||||||
if (!PINPUTREGION) {
|
if (!PINPUTREGION) {
|
||||||
Debug::log(CRIT, "The compositor did not allow hyprpaper a region!");
|
Debug::log(CRIT, "The compositor did not allow hyprpaper a region!");
|
||||||
exit(1);
|
exit(1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_surface_set_input_region(pSurface, PINPUTREGION);
|
wl_surface_set_input_region(pSurface, PINPUTREGION);
|
||||||
|
@ -28,7 +26,6 @@ CLayerSurface::CLayerSurface(SMonitor* pMonitor) {
|
||||||
if (!pLayerSurface) {
|
if (!pLayerSurface) {
|
||||||
Debug::log(CRIT, "The compositor did not allow hyprpaper a layersurface!");
|
Debug::log(CRIT, "The compositor did not allow hyprpaper a layersurface!");
|
||||||
exit(1);
|
exit(1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zwlr_layer_surface_v1_set_size(pLayerSurface, 0, 0);
|
zwlr_layer_surface_v1_set_size(pLayerSurface, 0, 0);
|
||||||
|
@ -47,4 +44,4 @@ CLayerSurface::~CLayerSurface() {
|
||||||
zwlr_layer_surface_v1_destroy(pLayerSurface);
|
zwlr_layer_surface_v1_destroy(pLayerSurface);
|
||||||
|
|
||||||
wl_display_flush(g_pHyprpaper->m_sDisplay);
|
wl_display_flush(g_pHyprpaper->m_sDisplay);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,11 @@ struct SMonitor;
|
||||||
|
|
||||||
class CLayerSurface {
|
class CLayerSurface {
|
||||||
public:
|
public:
|
||||||
CLayerSurface(SMonitor*);
|
explicit CLayerSurface(SMonitor*);
|
||||||
~CLayerSurface();
|
~CLayerSurface();
|
||||||
|
|
||||||
SMonitor* m_pMonitor = nullptr;
|
SMonitor* m_pMonitor = nullptr;
|
||||||
|
|
||||||
zwlr_layer_surface_v1* pLayerSurface = nullptr;
|
zwlr_layer_surface_v1* pLayerSurface = nullptr;
|
||||||
wl_surface* pSurface = nullptr;
|
wl_surface* pSurface = nullptr;
|
||||||
|
};
|
||||||
bool m_bCurrent = false;
|
|
||||||
};
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ void CWallpaperTarget::create(const std::string& path) {
|
||||||
} else {
|
} else {
|
||||||
Debug::log(CRIT, "unrecognized image %s", path.c_str());
|
Debug::log(CRIT, "unrecognized image %s", path.c_str());
|
||||||
exit(1);
|
exit(1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cairo_surface_status(CAIROSURFACE) != CAIRO_STATUS_SUCCESS) {
|
if (cairo_surface_status(CAIROSURFACE) != CAIRO_STATUS_SUCCESS) {
|
||||||
|
@ -33,4 +32,4 @@ void CWallpaperTarget::create(const std::string& path) {
|
||||||
Debug::log(LOG, "Preloaded target %s in %.2fms -> Pixel size: [%i, %i]", path.c_str(), MS, (int)m_vSize.x, (int)m_vSize.y);
|
Debug::log(LOG, "Preloaded target %s in %.2fms -> Pixel size: [%i, %i]", path.c_str(), MS, (int)m_vSize.x, (int)m_vSize.y);
|
||||||
|
|
||||||
m_pCairoSurface = CAIROSURFACE;
|
m_pCairoSurface = CAIROSURFACE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ public:
|
||||||
~CWallpaperTarget();
|
~CWallpaperTarget();
|
||||||
|
|
||||||
void create(const std::string& path);
|
void create(const std::string& path);
|
||||||
void render();
|
|
||||||
|
|
||||||
std::string m_szPath;
|
std::string m_szPath;
|
||||||
|
|
||||||
|
@ -18,4 +17,4 @@ public:
|
||||||
bool m_bHasAlpha = true;
|
bool m_bHasAlpha = true;
|
||||||
|
|
||||||
cairo_surface_t* m_pCairoSurface;
|
cairo_surface_t* m_pCairoSurface;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue