use hyprland command socket instead of spawning a hyprctl process
This commit is contained in:
@@ -92,7 +92,7 @@ void HyprlandService::bindHyprlandSocket() {
|
||||
return;
|
||||
}
|
||||
|
||||
struct sockaddr_un addr;
|
||||
struct sockaddr_un addr{};
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_UNIX;
|
||||
std::strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);
|
||||
|
||||
@@ -52,11 +52,11 @@ void NotificationController::showNotificationOnAllMonitors(NotifyMessage notify)
|
||||
timeout = DEFAULT_NOTIFICATION_TIMEOUT;
|
||||
}
|
||||
|
||||
notification->signal_close.connect([this, id = notification->getNotificationId()](int) {
|
||||
notification->getSignalClose().connect([this, id = notification->getNotificationId()](int) {
|
||||
closeNotification(id);
|
||||
});
|
||||
|
||||
notification->signal_hover_changed.connect([this, id = notification->getNotificationId()](bool hovered) {
|
||||
notification->getSignalHoverChanged().connect([this, id = notification->getNotificationId()](bool hovered) {
|
||||
updateHoverState(id, hovered);
|
||||
});
|
||||
|
||||
@@ -80,11 +80,11 @@ void NotificationController::showCopyNotification(NotifyMessage notify) {
|
||||
notification->show();
|
||||
notifications.push_back(notification);
|
||||
|
||||
notification->signal_close.connect([this, id = notification->getNotificationId()](int) {
|
||||
notification->getSignalClose().connect([this, id = notification->getNotificationId()](int) {
|
||||
closeNotification(id);
|
||||
});
|
||||
|
||||
notification->signal_hover_changed.connect([this, id = notification->getNotificationId()](bool hovered) {
|
||||
notification->getSignalHoverChanged().connect([this, id = notification->getNotificationId()](bool hovered) {
|
||||
updateHoverState(id, hovered);
|
||||
});
|
||||
notification->startAutoClose(DEFAULT_NOTIFICATION_TIMEOUT);
|
||||
@@ -103,11 +103,11 @@ void NotificationController::showSpotifyNotification(MprisPlayer2Message mpris)
|
||||
notification->show();
|
||||
notifications.push_back(notification);
|
||||
|
||||
notification->signal_close.connect([this, id = notification->getNotificationId()](int) {
|
||||
notification->getSignalClose().connect([this, id = notification->getNotificationId()](int) {
|
||||
closeNotification(id);
|
||||
});
|
||||
|
||||
notification->signal_hover_changed.connect([this, id = notification->getNotificationId()](bool hovered) {
|
||||
notification->getSignalHoverChanged().connect([this, id = notification->getNotificationId()](bool hovered) {
|
||||
updateHoverState(id, hovered);
|
||||
});
|
||||
|
||||
|
||||
@@ -41,17 +41,17 @@ BaseNotification::BaseNotification(uint64_t notificationId, std::shared_ptr<Gdk:
|
||||
return;
|
||||
}
|
||||
}
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->notificationId);
|
||||
});
|
||||
add_controller(window_click);
|
||||
|
||||
auto window_motion = Gtk::EventControllerMotion::create();
|
||||
window_motion->signal_enter().connect([this](double, double) {
|
||||
signal_hover_changed.emit(true);
|
||||
getSignalHoverChanged().emit(true);
|
||||
pause_auto_close();
|
||||
});
|
||||
window_motion->signal_leave().connect([this]() {
|
||||
signal_hover_changed.emit(false);
|
||||
getSignalHoverChanged().emit(false);
|
||||
resume_auto_close();
|
||||
});
|
||||
add_controller(window_motion);
|
||||
@@ -82,7 +82,7 @@ void BaseNotification::start_auto_close_timeout(int timeoutMs) {
|
||||
|
||||
autoCloseDeadline = std::chrono::steady_clock::now() + std::chrono::milliseconds(timeoutMs);
|
||||
autoCloseConnection = Glib::signal_timeout().connect([this]() {
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->notificationId);
|
||||
return false; // Don't repeat
|
||||
},
|
||||
timeoutMs);
|
||||
@@ -110,7 +110,7 @@ void BaseNotification::resume_auto_close() {
|
||||
|
||||
autoClosePaused = false;
|
||||
if (autoCloseRemainingMs <= 0) {
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->notificationId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
|
||||
copyToClipboard(this->copiedImage);
|
||||
spdlog::info("Copied image to clipboard");
|
||||
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->getNotificationId());
|
||||
});
|
||||
saveToClipboardButton->set_tooltip_text("Copy to Clipboard");
|
||||
saveToClipboardButton->add_css_class("notification-button");
|
||||
@@ -100,7 +100,6 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
|
||||
|
||||
auto saveToFileButton = Gtk::make_managed<IconButton>(Icon::SAVE);
|
||||
saveToFileButton->signal_clicked().connect([this]() {
|
||||
// xdg-pic/screenshot // use env
|
||||
auto xdgPicturesDir = Glib::get_user_special_dir(Glib::UserDirectory::PICTURES);
|
||||
auto dateStamp = Glib::DateTime::create_now_local().format("%Y%m%d_%H%M%S");
|
||||
auto filepath = xdgPicturesDir + "/screenshot";
|
||||
@@ -108,7 +107,7 @@ void CopyNotification::createImageNotification(NotifyMessage notify) {
|
||||
saveImageToFile(this->copiedImage, filepath, filename);
|
||||
spdlog::info("Saved image to {}", filepath.c_str());
|
||||
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->getNotificationId());
|
||||
});
|
||||
saveToFileButton->set_tooltip_text("Save to File");
|
||||
saveToFileButton->add_css_class("notification-button");
|
||||
@@ -134,7 +133,7 @@ void CopyNotification::createTextNotification(NotifyMessage notify) {
|
||||
auto copyToClipboardButton = Gtk::make_managed<IconButton>(Icon::CONTENT_COPY);
|
||||
copyToClipboardButton->signal_clicked().connect([this]() {
|
||||
copyToClipboard(this->copiedText);
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->getNotificationId());
|
||||
});
|
||||
copyToClipboardButton->set_tooltip_text("Copy to Clipboard");
|
||||
copyToClipboardButton->add_css_class("notification-icon-button");
|
||||
|
||||
@@ -91,7 +91,7 @@ NotificationWindow::NotificationWindow(uint64_t notificationId, std::shared_ptr<
|
||||
if (cb && guard && !*guard) {
|
||||
*guard = true;
|
||||
cb(action_id);
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->getNotificationId());
|
||||
}
|
||||
});
|
||||
actions_box->append(*btn);
|
||||
|
||||
@@ -66,7 +66,7 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
|
||||
backButton->signal_clicked().connect([this, mpris]() {
|
||||
if (mpris.previous) {
|
||||
mpris.previous();
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->getNotificationId());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ std::unique_ptr<Gtk::CenterBox> SpotifyNotification::createButtonBox(MprisPlayer
|
||||
nextButton->signal_clicked().connect([this, mpris]() {
|
||||
if (mpris.next) {
|
||||
mpris.next();
|
||||
this->signal_close.emit(this->notificationId);
|
||||
this->getSignalClose().emit(this->getNotificationId());
|
||||
}
|
||||
});
|
||||
buttonBox->set_start_widget(*backButton);
|
||||
|
||||
Reference in New Issue
Block a user