Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly types monitor pointers #132

Merged
merged 2 commits into from
Oct 20, 2024
Merged

Conversation

PedroMAdorno4
Copy link
Contributor

This PR fixes some type inconsistencies regarding monitor pointers that ensued with Hyprland updates. Now successfully builds using following commits:

  • hyprland: 08cc063e175e48cea44d26b7e3762f4b8611f0c5
  • hyprutils: fd4be8b9ca932f7384e454bcd923c5451ef2aa85
  • hyprlang: f054f2e44d6a0b74607a6bc0f52dba337a3db38e
  • aquamarine: 9874e08eec85b5542ca22494e127b0cdce46b786

@zjeffer zjeffer self-requested a review October 20, 2024 09:11
@zjeffer zjeffer self-assigned this Oct 20, 2024
@zjeffer zjeffer added the build error The plugin couldn't be built property label Oct 20, 2024
@zjeffer
Copy link
Collaborator

zjeffer commented Oct 20, 2024

Looks like it changed in this PR: hyprwm/Hyprland#8178

Thanks for the PR! I'll let the CI/CD run and I'll merge when it succeeds.

@zjeffer
Copy link
Collaborator

zjeffer commented Oct 20, 2024

@PedroMAdorno4 Can you make the following changes?

diff --git a/src/main.cpp b/src/main.cpp
index 8c4ef14..00c35e8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -63,7 +63,7 @@ int getParamValue(const char* paramName)
     return **paramPtr;
 }
 
-const std::string& getWorkspaceFromMonitor(PHLMONITOR monitor, const std::string& workspace)
+const std::string& getWorkspaceFromMonitor(const PHLMONITOR& monitor, const std::string& workspace)
 {
     // if the workspace is "empty", we expect the new ID to be the first available ID on the given monitor (not the first ID in the global list)
     if (workspace == "empty") {
@@ -210,7 +210,7 @@ void splitChangeMonitor(const std::string& value)
     changeMonitor(false, value);
 }
 
-void mapMonitor(PHLMONITOR monitor) // NOLINT(readability-convert-member-functions-to-static)
+void mapMonitor(const PHLMONITOR& monitor) // NOLINT(readability-convert-member-functions-to-static)
 {
     if (monitor->activeMonitorRule.disabled) {
         Debug::log(INFO, "[split-monitor-workspaces] Skipping disabled monitor {}", monitor->szName);
@@ -254,7 +254,7 @@ void mapMonitor(PHLMONITOR monitor) // NOLINT(readability-convert-member-functio
     }
 }
 
-void unmapMonitor(PHLMONITOR monitor)
+void unmapMonitor(const PHLMONITOR& monitor)
 {
     int workspaceIndex = monitor->ID * g_workspaceCount + 1;
 
@@ -314,7 +314,7 @@ void reload()
 
 void monitorAddedCallback(void* /*unused*/, SCallbackInfo& /*unused*/, std::any param)
 { // NOLINT(performance-unnecessary-value-param)
-    PHLMONITOR monitor = std::any_cast<PHLMONITOR>(param);
+    auto monitor = std::any_cast<PHLMONITOR>(param);
     if (monitor == nullptr) {
         Debug::log(WARN, "[split-monitor-workspaces] Monitor added callback called with nullptr?");
         return;
@@ -324,7 +324,7 @@ void monitorAddedCallback(void* /*unused*/, SCallbackInfo& /*unused*/, std::any
 
 void monitorRemovedCallback(void* /*unused*/, SCallbackInfo& /*unused*/, std::any param) // NOLINT(performance-unnecessary-value-param)
 {
-    PHLMONITOR monitor = std::any_cast<PHLMONITOR>(param);
+    auto monitor = std::any_cast<PHLMONITOR>(param);
     if (monitor == nullptr) {
         Debug::log(WARN, "[split-monitor-workspaces] Monitor removed callback called with nullptr?");
         return;

I would push it myself but I don't have write access to your branch ;)

@PedroMAdorno4
Copy link
Contributor Author

Thanks for the patch! Its applied

@zjeffer zjeffer merged commit 131bc5b into Duckonaut:main Oct 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build error The plugin couldn't be built property
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants