add move window to hyprland service

This commit is contained in:
2026-02-02 12:23:44 +01:00
parent 9404321249
commit da9f167747
12 changed files with 264 additions and 102 deletions

View File

@@ -9,7 +9,7 @@
#include "widgets/tray.hpp"
#include "widgets/volumeWidget.hpp"
#include "widgets/webWidget.hpp"
#include "widgets/controlCenter.hpp"
#include "widgets/controlCenter/controlCenter.hpp"
class Bar : public Gtk::Window {
public:

View File

@@ -14,7 +14,7 @@ struct MprisPlayer2Message {
std::string title;
std::string artist;
std::string artwork_url;
uint32_t length_ms;
int64_t length_ms;
std::function<void()> play_pause;
std::function<void()> next;

View File

@@ -12,12 +12,15 @@ class MprisController {
void toggle_play();
void next_song();
void previous_song();
void emit_seeked(int64_t position_us);
sigc::signal<void(const MprisPlayer2Message &)> &signal_mpris_updated();
private:
MprisController();
bool playerRunning = false;
Glib::RefPtr<Gio::DBus::Connection> m_connection;
Glib::RefPtr<Gio::DBus::Proxy> m_proxy;
sigc::signal<void(const MprisPlayer2Message &)> mprisUpdatedSignal;

View File

@@ -67,6 +67,7 @@ class HyprlandService {
ACTIVE_WINDOW,
OPEN_WINDOW,
CLOSE_WINDOW,
MOVE_WINDOW,
URGENT,
FOCUSED_MONITOR,
@@ -78,6 +79,7 @@ class HyprlandService {
{"activewindowv2", ACTIVE_WINDOW},
{"openwindow", OPEN_WINDOW},
{"closewindow", CLOSE_WINDOW},
{"movewindowv2", MOVE_WINDOW},
{"urgent", URGENT},
{"focusedmon", FOCUSED_MONITOR},
{"monitorremoved", MONITOR_REMOVED},
@@ -86,6 +88,7 @@ class HyprlandService {
void onFocusedMonitorChanged(std::string monitorData);
void onOpenWindow(std::string windowData);
void onCloseWindow(std::string windowData);
void onMoveWindow(std::string windowData);
void onUrgent(std::string windowAddress);
void onActiveWindowChanged(std::string windowAddress);
void onMonitorRemoved(std::string monitorName);

View File

@@ -1,46 +0,0 @@
#pragma once
#include <memory>
#include "components/popover.hpp"
#include "gtkmm/box.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
#include "gtkmm/picture.h"
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
#include "services/dbus/mpris.hpp"
class ControlCenter : public Popover {
public:
ControlCenter(std::string icon, std::string name);
private:
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
Gtk::Box container;
Gtk::Box spotifyContainer;
// image as background, artist, title
Gtk::Overlay topContainer;
Gtk::Picture backgroundImage;
Gtk::Box infoContainer;
Gtk::Label artistLabel;
Gtk::Label titleLabel;
//
Gtk::Box seekBarContainer;
Gtk::Label currentTimeLabel;
Gtk::Scale seekBar;
Gtk::Label totalTimeLabel;
// playback controls
Gtk::Box bottomContainer;
Gtk::Button previousButton;
Gtk::Button playPauseButton;
Gtk::Button nextButton;
Gtk::ScrolledWindow imageWrapper;
void onSpotifyMprisUpdated(const MprisPlayer2Message &message);
};

View File

@@ -0,0 +1,15 @@
#pragma once
#include "components/popover.hpp"
#include "gtkmm/box.h"
#include "widgets/controlCenter/mediaControl.hpp"
class ControlCenter : public Popover {
public:
ControlCenter(std::string icon, std::string name);
private:
Gtk::Box container;
MediaControlWidget mediaControlWidget;
};

View File

@@ -0,0 +1,52 @@
#pragma once
#include "gtkmm/box.h"
#include "gtkmm/button.h"
#include "gtkmm/label.h"
#include "gtkmm/overlay.h"
#include "gtkmm/picture.h"
#include "gtkmm/scale.h"
#include "gtkmm/scrolledwindow.h"
#include "services/dbus/mpris.hpp"
class MediaControlWidget : public Gtk::Box {
public:
MediaControlWidget();
private:
std::shared_ptr<MprisController> mprisController = MprisController::getInstance();
int64_t currentPositionUs = 0;
int64_t totalLengthUs = 0;
sigc::connection seekTimerConnection;
void setCurrentPosition(int64_t position_us);
void setTotalLength(int64_t length_us);
void resetSeekTimer(int64_t start_position_us);
bool onSeekTick();
Gtk::Box spotifyContainer;
// image as background, artist, title
Gtk::Overlay topContainer;
Gtk::Picture backgroundImage;
Gtk::Box infoContainer;
Gtk::Label artistLabel;
Gtk::Label titleLabel;
//
Gtk::Box seekBarContainer;
Gtk::Label currentTimeLabel;
Gtk::Scale seekBar;
Gtk::Label totalTimeLabel;
// playback controls
Gtk::Box bottomContainer;
Gtk::Button previousButton;
Gtk::Button playPauseButton;
Gtk::Button nextButton;
Gtk::ScrolledWindow imageWrapper;
void onSpotifyMprisUpdated(const MprisPlayer2Message &message);
};