Skip to content

Commit

Permalink
touch up the clang format and format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Dec 20, 2022
1 parent 3e2785b commit 4fd9014
Show file tree
Hide file tree
Showing 15 changed files with 337 additions and 328 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ AllowShortEnumsOnASingleLine: false
BraceWrapping:
AfterEnum: false

AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
AlignConsecutiveDeclarations: AcrossEmptyLines

NamespaceIndentation: All
83 changes: 51 additions & 32 deletions hyprctl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args]
--batch -> execute a batch of commands, separated by ';'
)#";

void request(std::string arg, int minArgs = 0) {
void request(std::string arg, int minArgs = 0) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);

const auto ARGS = std::count(arg.begin(), arg.end(), ' ');
Expand All @@ -59,7 +59,6 @@ void request(std::string arg, int minArgs = 0) {
return;
}


// get the instance signature
auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");

Expand All @@ -71,7 +70,7 @@ void request(std::string arg, int minArgs = 0) {
std::string instanceSigStr = std::string(instanceSig);

sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
serverAddress.sun_family = AF_UNIX;

std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.socket.sock";

Expand All @@ -89,8 +88,8 @@ void request(std::string arg, int minArgs = 0) {
return;
}

std::string reply = "";
char buffer[8192] = {0};
std::string reply = "";
char buffer[8192] = {0};

sizeWritten = read(SERVERSOCKET, buffer, 8192);

Expand Down Expand Up @@ -134,7 +133,7 @@ void requestHyprpaper(std::string arg) {
std::string instanceSigStr = std::string(instanceSig);

sockaddr_un serverAddress = {0};
serverAddress.sun_family = AF_UNIX;
serverAddress.sun_family = AF_UNIX;

std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.hyprpaper.sock";

Expand Down Expand Up @@ -176,7 +175,7 @@ int dispatchRequest(int argc, char** argv) {

std::string rq = "/dispatch";

for(int i = 2; i < argc; i++) {
for (int i = 2; i < argc; i++) {
if (!strcmp(argv[i], "--"))
continue;
rq += " " + std::string(argv[i]);
Expand All @@ -195,7 +194,7 @@ int keywordRequest(int argc, char** argv) {

std::string rq = "/keyword";

for(int i = 2; i < argc; i++)
for (int i = 2; i < argc; i++)
rq += " " + std::string(argv[i]);

request(rq);
Expand Down Expand Up @@ -265,7 +264,7 @@ bool isNumber(const std::string& str, bool allowfloat) {
}

int main(int argc, char** argv) {
int bflag = 0, sflag = 0, index, c;
int bflag = 0, sflag = 0, index, c;
bool parseArgs = true;

if (argc < 2) {
Expand All @@ -274,8 +273,8 @@ int main(int argc, char** argv) {
}

std::string fullRequest = "";
std::string fullArgs = "";
const auto ARGS = splitArgs(argc, argv);
std::string fullArgs = "";
const auto ARGS = splitArgs(argc, argv);

for (auto i = 0; i < ARGS.size(); ++i) {
if (ARGS[i] == "--") {
Expand Down Expand Up @@ -308,29 +307,49 @@ int main(int argc, char** argv) {
fullRequest.pop_back(); // remove trailing space

fullRequest = fullArgs + "/" + fullRequest;

int exitStatus = 0;

if (fullRequest.contains("/--batch")) batchRequest(fullRequest);
else if (fullRequest.contains("/monitors")) request(fullRequest);
else if (fullRequest.contains("/clients")) request(fullRequest);
else if (fullRequest.contains("/workspaces")) request(fullRequest);
else if (fullRequest.contains("/activewindow")) request(fullRequest);
else if (fullRequest.contains("/layers")) request(fullRequest);
else if (fullRequest.contains("/version")) request(fullRequest);
else if (fullRequest.contains("/kill")) request(fullRequest);
else if (fullRequest.contains("/splash")) request(fullRequest);
else if (fullRequest.contains("/devices")) request(fullRequest);
else if (fullRequest.contains("/reload")) request(fullRequest);
else if (fullRequest.contains("/getoption")) request(fullRequest);
else if (fullRequest.contains("/cursorpos")) request(fullRequest);
else if (fullRequest.contains("/switchxkblayout")) request(fullRequest, 2);
else if (fullRequest.contains("/output")) exitStatus = outputRequest(argc, argv);
else if (fullRequest.contains("/setcursor")) exitStatus = setcursorRequest(argc, argv);
else if (fullRequest.contains("/dispatch")) exitStatus = dispatchRequest(argc, argv);
else if (fullRequest.contains("/keyword")) exitStatus = keywordRequest(argc, argv);
else if (fullRequest.contains("/hyprpaper")) exitStatus = hyprpaperRequest(argc, argv);
else if (fullRequest.contains("/--help")) printf("%s", USAGE.c_str());
if (fullRequest.contains("/--batch"))
batchRequest(fullRequest);
else if (fullRequest.contains("/monitors"))
request(fullRequest);
else if (fullRequest.contains("/clients"))
request(fullRequest);
else if (fullRequest.contains("/workspaces"))
request(fullRequest);
else if (fullRequest.contains("/activewindow"))
request(fullRequest);
else if (fullRequest.contains("/layers"))
request(fullRequest);
else if (fullRequest.contains("/version"))
request(fullRequest);
else if (fullRequest.contains("/kill"))
request(fullRequest);
else if (fullRequest.contains("/splash"))
request(fullRequest);
else if (fullRequest.contains("/devices"))
request(fullRequest);
else if (fullRequest.contains("/reload"))
request(fullRequest);
else if (fullRequest.contains("/getoption"))
request(fullRequest);
else if (fullRequest.contains("/cursorpos"))
request(fullRequest);
else if (fullRequest.contains("/switchxkblayout"))
request(fullRequest, 2);
else if (fullRequest.contains("/output"))
exitStatus = outputRequest(argc, argv);
else if (fullRequest.contains("/setcursor"))
exitStatus = setcursorRequest(argc, argv);
else if (fullRequest.contains("/dispatch"))
exitStatus = dispatchRequest(argc, argv);
else if (fullRequest.contains("/keyword"))
exitStatus = keywordRequest(argc, argv);
else if (fullRequest.contains("/hyprpaper"))
exitStatus = hyprpaperRequest(argc, argv);
else if (fullRequest.contains("/--help"))
printf("%s", USAGE.c_str());
else {
printf("%s\n", USAGE.c_str());
return 1;
Expand Down
4 changes: 2 additions & 2 deletions src/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW
double subx, suby;

// calc for oversized windows... fucking bullshit, again.
wlr_box geom;
wlr_box geom;
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);

const auto PFOUND = wlr_xdg_surface_surface_at(PSURFACE, pos.x - pWindow->m_vRealPosition.vec().x + geom.x, pos.y - pWindow->m_vRealPosition.vec().y + geom.y, &subx, &suby);
Expand Down Expand Up @@ -1690,7 +1690,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
const bool SWITCHINGISACTIVE = POLDMON->activeWorkspace == pWorkspace->m_iID;

// fix old mon
int nextWorkspaceOnMonitorID = -1;
int nextWorkspaceOnMonitorID = -1;
for (auto& w : m_vWorkspaces) {
if (w->m_iMonitorID == POLDMON->ID && w->m_iID != pWorkspace->m_iID) {
nextWorkspaceOnMonitorID = w->m_iID;
Expand Down
12 changes: 2 additions & 10 deletions src/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,7 @@ void CWindow::createToplevelHandle() {

// handle events
hyprListener_toplevelActivate.initCallback(
&m_phForeignToplevel->events.request_activate,
[&](void* owner, void* data) {
g_pCompositor->focusWindow(this);
},
this, "Toplevel");
&m_phForeignToplevel->events.request_activate, [&](void* owner, void* data) { g_pCompositor->focusWindow(this); }, this, "Toplevel");

hyprListener_toplevelFullscreen.initCallback(
&m_phForeignToplevel->events.request_fullscreen,
Expand All @@ -150,11 +146,7 @@ void CWindow::createToplevelHandle() {
this, "Toplevel");

hyprListener_toplevelClose.initCallback(
&m_phForeignToplevel->events.request_close,
[&](void* owner, void* data) {
g_pCompositor->closeWindow(this);
},
this, "Toplevel");
&m_phForeignToplevel->events.request_close, [&](void* owner, void* data) { g_pCompositor->closeWindow(this); }, this, "Toplevel");

m_iLastToplevelMonitorID = m_iMonitorID;
}
Expand Down
112 changes: 56 additions & 56 deletions src/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ struct SWindowSpecialRenderData {
int64_t inactiveBorderColor = -1; // -1 means unset

// set by the layout
bool rounding = true;
bool border = true;
bool decorate = true;
bool rounding = true;
bool border = true;
bool decorate = true;
};

struct SWindowAdditionalConfigData {
Expand Down Expand Up @@ -88,110 +88,110 @@ class CWindow {
} m_uSurface;

// this is the position and size of the "bounding box"
Vector2D m_vPosition = Vector2D(0, 0);
Vector2D m_vSize = Vector2D(0, 0);
Vector2D m_vPosition = Vector2D(0, 0);
Vector2D m_vSize = Vector2D(0, 0);

// this is the real position and size used to draw the thing
CAnimatedVariable m_vRealPosition;
CAnimatedVariable m_vRealSize;
CAnimatedVariable m_vRealPosition;
CAnimatedVariable m_vRealSize;

// for not spamming the protocols
Vector2D m_vReportedPosition;
Vector2D m_vReportedSize;
Vector2D m_vReportedPosition;
Vector2D m_vReportedSize;

// for restoring floating statuses
Vector2D m_vLastFloatingSize;
Vector2D m_vLastFloatingPosition;
Vector2D m_vLastFloatingSize;
Vector2D m_vLastFloatingPosition;

// this is used for pseudotiling
bool m_bIsPseudotiled = false;
Vector2D m_vPseudoSize = Vector2D(0, 0);
bool m_bIsPseudotiled = false;
Vector2D m_vPseudoSize = Vector2D(0, 0);

uint64_t m_iTags = 0;
bool m_bIsFloating = false;
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bIsFullscreen = false;
uint64_t m_iMonitorID = -1;
std::string m_szTitle = "";
int m_iWorkspaceID = -1;
uint64_t m_iTags = 0;
bool m_bIsFloating = false;
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bIsFullscreen = false;
uint64_t m_iMonitorID = -1;
std::string m_szTitle = "";
int m_iWorkspaceID = -1;

bool m_bIsMapped = false;
bool m_bIsMapped = false;

bool m_bRequestsFloat = false;
bool m_bRequestsFloat = false;

// This is for fullscreen apps
bool m_bCreatedOverFullscreen = false;
bool m_bCreatedOverFullscreen = false;

// XWayland stuff
bool m_bIsX11 = false;
bool m_bMappedX11 = false;
CWindow* m_pX11Parent = nullptr;
uint64_t m_iX11Type = 0;
bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false;
bool m_bX11ShouldntFocus = false;
bool m_bIsX11 = false;
bool m_bMappedX11 = false;
CWindow* m_pX11Parent = nullptr;
uint64_t m_iX11Type = 0;
bool m_bIsModal = false;
bool m_bX11DoesntWantBorders = false;
bool m_bX11ShouldntFocus = false;
//

// For nofocus
bool m_bNoFocus = false;
bool m_bNoInitialFocus = false;
bool m_bNoFocus = false;
bool m_bNoInitialFocus = false;

// initial fullscreen and fullscreen disabled
bool m_bWantsInitialFullscreen = false;
bool m_bNoFullscreenRequest = false;
bool m_bWantsInitialFullscreen = false;
bool m_bNoFullscreenRequest = false;

SSurfaceTreeNode* m_pSurfaceTree = nullptr;
SSurfaceTreeNode* m_pSurfaceTree = nullptr;

// Animated border
CGradientValueData m_cRealBorderColor = {0};
CGradientValueData m_cRealBorderColorPrevious = {0};
CAnimatedVariable m_fBorderAnimationProgress;
CGradientValueData m_cRealBorderColor = {0};
CGradientValueData m_cRealBorderColorPrevious = {0};
CAnimatedVariable m_fBorderAnimationProgress;

// Fade in-out
CAnimatedVariable m_fAlpha;
bool m_bFadingOut = false;
bool m_bReadyToDelete = false;
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
Vector2D m_vOriginalClosedSize; // drawing the closing animations
CAnimatedVariable m_fAlpha;
bool m_bFadingOut = false;
bool m_bReadyToDelete = false;
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
Vector2D m_vOriginalClosedSize; // drawing the closing animations

// For pinned (sticky) windows
bool m_bPinned = false;
bool m_bPinned = false;

// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
CWindow* m_pLastCycledWindow = nullptr;
CWindow* m_pLastCycledWindow = nullptr;

// Foreign Toplevel proto
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;

// Window decorations
std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;

// Special render data, rules, etc
SWindowSpecialRenderData m_sSpecialRenderData;
SWindowAdditionalConfigData m_sAdditionalConfigData;
SWindowSpecialRenderData m_sSpecialRenderData;
SWindowAdditionalConfigData m_sAdditionalConfigData;

// for alpha
CAnimatedVariable m_fActiveInactiveAlpha;
CAnimatedVariable m_fActiveInactiveAlpha;

// animated shadow color
CAnimatedVariable m_cRealShadowColor;
CAnimatedVariable m_cRealShadowColor;

// animated tint
CAnimatedVariable m_fDimPercent;
CAnimatedVariable m_fDimPercent;

// swallowing
CWindow* m_pSwallowed = nullptr;
CWindow* m_pSwallowed = nullptr;

// for toplevel monitor events
uint64_t m_iLastToplevelMonitorID = -1;
uint64_t m_iLastSurfaceMonitorID = -1;
uint64_t m_iLastToplevelMonitorID = -1;
uint64_t m_iLastSurfaceMonitorID = -1;

// for idle inhibiting windows
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;

// For the list lookup
bool operator==(const CWindow& rhs) {
bool operator==(const CWindow& rhs) {
return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize &&
m_bFadingOut == rhs.m_bFadingOut;
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/ConfigDataValues.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CGradientValueData : public ICustomConfigValueData {
/* Float corresponding to the angle (rad) */
float m_fAngle = 0;

bool operator==(const CGradientValueData& other) {
bool operator==(const CGradientValueData& other) {
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
return false;

Expand Down
Loading

0 comments on commit 4fd9014

Please sign in to comment.