aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2023-11-03 15:51:33 +0000
committerVaxry <[email protected]>2023-11-03 15:51:43 +0000
commit93a2ac9de402830d301bdecdbf7aca52f88bd801 (patch)
tree3cee6aa56cce53728bb68de61f2a9a8bedca35ca
parent49fdffacea92bc99391da0a9347b34c27d1b4525 (diff)
downloadHyprland-93a2ac9de402830d301bdecdbf7aca52f88bd801.tar.gz
Hyprland-93a2ac9de402830d301bdecdbf7aca52f88bd801.zip
fractional-scale: post error on taken fs objects
fixes #3735
-rw-r--r--src/protocols/FractionalScale.cpp14
-rw-r--r--src/protocols/FractionalScale.hpp1
2 files changed, 14 insertions, 1 deletions
diff --git a/src/protocols/FractionalScale.cpp b/src/protocols/FractionalScale.cpp
index f659a63a..19e60295 100644
--- a/src/protocols/FractionalScale.cpp
+++ b/src/protocols/FractionalScale.cpp
@@ -76,7 +76,13 @@ static void handleAddonDestroy(wl_resource* resource) {
void CFractionalScaleProtocolManager::getFractionalScale(wl_client* client, wl_resource* resource, uint32_t id, wl_resource* surface) {
const auto PSURFACE = wlr_surface_from_resource(surface);
- const auto PADDON = getAddonForSurface(PSURFACE);
+
+ if (addonExists(PSURFACE)) {
+ wl_resource_post_error(resource, WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS, "Fractional scale exists.");
+ return;
+ }
+
+ const auto PADDON = getAddonForSurface(PSURFACE);
PADDON->pResource = wl_resource_create(client, &wp_fractional_scale_v1_interface, wl_resource_get_version(resource), id);
wl_resource_set_implementation(PADDON->pResource, &fractionalScaleAddonImpl, PADDON, handleAddonDestroy);
@@ -84,6 +90,12 @@ void CFractionalScaleProtocolManager::getFractionalScale(wl_client* client, wl_r
wp_fractional_scale_v1_send_preferred_scale(PADDON->pResource, (uint32_t)std::round(PADDON->preferredScale * 120.0));
}
+bool CFractionalScaleProtocolManager::addonExists(wlr_surface* surface) {
+ const auto IT = std::find_if(m_vFractionalScaleAddons.begin(), m_vFractionalScaleAddons.end(), [&](const auto& other) { return other->pSurface == surface; });
+
+ return IT != m_vFractionalScaleAddons.end();
+}
+
SFractionalScaleAddon* CFractionalScaleProtocolManager::getAddonForSurface(wlr_surface* surface) {
const auto IT = std::find_if(m_vFractionalScaleAddons.begin(), m_vFractionalScaleAddons.end(), [&](const auto& other) { return other->pSurface == surface; });
diff --git a/src/protocols/FractionalScale.hpp b/src/protocols/FractionalScale.hpp
index 71b2c858..99696319 100644
--- a/src/protocols/FractionalScale.hpp
+++ b/src/protocols/FractionalScale.hpp
@@ -30,6 +30,7 @@ class CFractionalScaleProtocolManager {
private:
SFractionalScaleAddon* getAddonForSurface(wlr_surface*);
+ bool addonExists(wlr_surface*);
std::vector<std::unique_ptr<SFractionalScaleAddon>> m_vFractionalScaleAddons;