Skip to content

Conversation

WShad
Copy link

@WShad WShad commented Jul 19, 2025

Adds language widget displaying current keyboard layout language.
2025-07-20_00:47:10

@WShad WShad marked this pull request as ready for review July 19, 2025 21:33
@WShad
Copy link
Author

WShad commented Jul 29, 2025

Implemented IPC-client + language widget based on it

@WShad
Copy link
Author

WShad commented Aug 1, 2025

@ammen99, better?))

@NamorNiradnug
Copy link
Collaborator

NamorNiradnug commented Aug 1, 2025

Hi! I haven't checked the PR carefully yet but I suppose it should use yyjson instead of nlohmann_json because wayfire uses the former. Could you please fix that?

UPD: also please fix the formatting.

int inotify_css_fd;
wf::config::config_manager_t config;
zwf_shell_manager_v2 *wf_shell_manager = nullptr;
WayfireIPC *ipc = nullptr;
Copy link
Collaborator

@NamorNiradnug NamorNiradnug Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest making WayfireIPC a singleton so that it won't be initialized until needed.

I usually do it like this:

  • WayfireIPC doesn't have a public ctor
  • has private static std::weak_ptr<WayfireIPC> instance_
  • has public static std::shared_ptr<WayfireIPC> Instance() which simply returns instance_.lock()
  • has public static std::shared_ptr<WayfireIPC> Open() (or something, maybe you will come up with a better name) which initialize the instance_ if it's expired

Instance() should be called in reload_widgets so that we don't close-and-open the socket on every reload.

Probably Lock() would be a better name for Instance(), but I would still call it Instance for consistency with existing singletons.

See https://github.com/WayfireWM/wf-shell/blob/master/src/panel/widgets/tray/watcher.hpp#L18-L31 and https://github.com/WayfireWM/wf-shell/blob/master/src/panel/panel.cpp#L268.


class WayfireIPC
{
int socket_fd;
Copy link
Collaborator

@NamorNiradnug NamorNiradnug Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered using Gio's SocketClient instead of handling it manually? I believe it would simplify the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants