// Generated with hyprwayland-scanner 0.4.6. Made with vaxry's keyboard and ❤️.
// hyprland_lock_notify_v1

/*
 This protocol's authors' copyright notice is:


    Copyright © 2025 Maximilian Seidler
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:

    1. Redistributions of source code must retain the above copyright notice, this
       list of conditions and the following disclaimer.

    2. Redistributions in binary form must reproduce the above copyright notice,
       this list of conditions and the following disclaimer in the documentation
       and/or other materials provided with the distribution.

    3. Neither the name of the copyright holder nor the names of its
       contributors may be used to endorse or promote products derived from
       this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
*/

#define private public
#define HYPRWAYLAND_SCANNER_NO_INTERFACES
#include "hyprland-lock-notify-v1.hpp"
#undef private
#define F std::function

static const wl_interface* hyprlandLockNotifyV1_dummyTypes[] = { nullptr };

// Reference all other interfaces.
// The reason why this is in snake is to
// be able to cooperate with existing
// wayland_scanner interfaces (they are interop)
extern const wl_interface hyprland_lock_notifier_v1_interface;
extern const wl_interface hyprland_lock_notification_v1_interface;

static const void* _CCHyprlandLockNotifierV1VTable[] = {
    nullptr,
};

void CCHyprlandLockNotifierV1::sendDestroy() {
    if (!pResource)
        return;
    destroyed = true;

    auto proxy = wl_proxy_marshal_flags(pResource, 0, nullptr, wl_proxy_get_version(pResource), 1);
    proxy;
}

wl_proxy* CCHyprlandLockNotifierV1::sendGetLockNotification() {
    if (!pResource)
        return nullptr;

    auto proxy = wl_proxy_marshal_flags(pResource, 1, &hyprland_lock_notification_v1_interface, wl_proxy_get_version(pResource), 0, nullptr);

    return proxy;
}
static const wl_interface* _CHyprlandLockNotifierV1GetLockNotificationTypes[] = {
    &hyprland_lock_notification_v1_interface,
};

static const wl_message _CHyprlandLockNotifierV1Requests[] = {
    { .name = "destroy", .signature = "", .types = hyprlandLockNotifyV1_dummyTypes + 0},
    { .name = "get_lock_notification", .signature = "n", .types = _CHyprlandLockNotifierV1GetLockNotificationTypes + 0},
};

const wl_interface hyprland_lock_notifier_v1_interface = {
    .name = "hyprland_lock_notifier_v1", .version = 1,
    .method_count = 2, .methods = _CHyprlandLockNotifierV1Requests,
    .event_count = 0, .events = nullptr,
};

CCHyprlandLockNotifierV1::CCHyprlandLockNotifierV1(wl_proxy* resource) : pResource(resource) {

    if (!pResource)
        return;

    wl_proxy_add_listener(pResource, (void (**)(void))&_CCHyprlandLockNotifierV1VTable, this);
}

CCHyprlandLockNotifierV1::~CCHyprlandLockNotifierV1() {
    if (!destroyed)
        sendDestroy();
}

static void _CHyprlandLockNotificationV1Locked(void* data, void* resource) {
    const auto PO = (CCHyprlandLockNotificationV1*)data;
    if (PO && PO->requests.locked)
        PO->requests.locked(PO);
}

static void _CHyprlandLockNotificationV1Unlocked(void* data, void* resource) {
    const auto PO = (CCHyprlandLockNotificationV1*)data;
    if (PO && PO->requests.unlocked)
        PO->requests.unlocked(PO);
}

static const void* _CCHyprlandLockNotificationV1VTable[] = {
    (void*)_CHyprlandLockNotificationV1Locked,
    (void*)_CHyprlandLockNotificationV1Unlocked,
};

void CCHyprlandLockNotificationV1::sendDestroy() {
    if (!pResource)
        return;
    destroyed = true;

    auto proxy = wl_proxy_marshal_flags(pResource, 0, nullptr, wl_proxy_get_version(pResource), 1);
    proxy;
}

static const wl_message _CHyprlandLockNotificationV1Requests[] = {
    { .name = "destroy", .signature = "", .types = hyprlandLockNotifyV1_dummyTypes + 0},
};

static const wl_message _CHyprlandLockNotificationV1Events[] = {
    { .name = "locked", .signature = "", .types = hyprlandLockNotifyV1_dummyTypes + 0},
    { .name = "unlocked", .signature = "", .types = hyprlandLockNotifyV1_dummyTypes + 0},
};

const wl_interface hyprland_lock_notification_v1_interface = {
    .name = "hyprland_lock_notification_v1", .version = 1,
    .method_count = 1, .methods = _CHyprlandLockNotificationV1Requests,
    .event_count = 2, .events = _CHyprlandLockNotificationV1Events,
};

CCHyprlandLockNotificationV1::CCHyprlandLockNotificationV1(wl_proxy* resource) : pResource(resource) {

    if (!pResource)
        return;

    wl_proxy_add_listener(pResource, (void (**)(void))&_CCHyprlandLockNotificationV1VTable, this);
}

CCHyprlandLockNotificationV1::~CCHyprlandLockNotificationV1() {
    if (!destroyed)
        sendDestroy();
}

void CCHyprlandLockNotificationV1::setLocked(F<void(CCHyprlandLockNotificationV1*)> &&handler) {
    requests.locked = std::move(handler);
}

void CCHyprlandLockNotificationV1::setUnlocked(F<void(CCHyprlandLockNotificationV1*)> &&handler) {
    requests.unlocked = std::move(handler);
}

#undef F
