Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use layoutmsg dispatcher #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,18 +534,18 @@ pub(crate) fn gen_dispatch_str(cmd: DispatchType, dispatch: bool) -> crate::Resu
SetCursor(theme, size) => format!("{theme} {}", *size),
FocusUrgentOrLast => "focusurgentorlast".to_string(),
FocusCurrentOrLast => "focuscurrentorlast".to_string(),
ToggleSplit => "togglesplit".to_string(),
SwapWithMaster(param) => format!("swapwithmaster{sep}{param}"),
FocusMaster(param) => format!("focusmaster{sep}{param}"),
AddMaster => "addmaster".to_string(),
RemoveMaster => "removemaster".to_string(),
OrientationLeft => "orientationleft".to_string(),
OrientationRight => "orientationright".to_string(),
OrientationTop => "orientationtop".to_string(),
OrientationBottom => "orientationbottom".to_string(),
OrientationCenter => "orientationcenter".to_string(),
OrientationNext => "orientationnext".to_string(),
OrientationPrev => "orientationprev".to_string(),
ToggleSplit => "layoutmsg togglesplit".to_string(),
SwapWithMaster(param) => format!("layoutmsg swapwithmaster{sep}{param}"),
FocusMaster(param) => format!("layoutmsg focusmaster{sep}{param}"),
Comment on lines +538 to +539
Copy link
Member

Choose a reason for hiding this comment

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

I just want to ask if you could make sure this works with the binding code found in config.rs:

dispatcher = gen_dispatch_str(binding.dispatcher, false)?

Since it adds a sep (,). Which when using regular IPC isn't added. This is weird, but it saves a lot of boilerplate.

hyprland-rs/src/dispatch.rs

Lines 468 to 470 in a8ca325

pub(crate) fn gen_dispatch_str(cmd: DispatchType, dispatch: bool) -> crate::Result<CommandContent> {
use DispatchType::*;
let sep = if dispatch { " " } else { "," };

Copy link
Author

Choose a reason for hiding this comment

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

I've tried the following with different all the available params:

Dispatch::call(DispatchType::SwapWithMaster(
           hyprland::dispatch::SwapWithMasterParam::Child
         )).unwrap();

and

Dispatch::call(DispatchType::FocusMaster(
          hyprland::dispatch::FocusMasterParam::Master
        )).unwrap();

Both seem to work fine, though I haven't figured difference between child, master and auto while running my tests from a terminal.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but I mean creating a keybind with hyprland-rs, as it uses the same dispatcher code, just replaces the formatting because IPC and binds have a different format.

Copy link
Author

Choose a reason for hiding this comment

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

I'm sorry, I've tried to test it with bindings but was not able to get even the binding from the example working:

hyprland::bind!(SUPER, Key, "t" => ToggleFloating, None).unwrap();

It returns Ok(()) but there is nothing new in hyprctl binds or an actual behavior.

Copy link
Member

Choose a reason for hiding this comment

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

I'm sorry, I've tried to test it with bindings but was not able to get even the binding from the example working:

hyprland::bind!(SUPER, Key, "t" => ToggleFloating, None).unwrap();

It returns Ok(()) but there is nothing new in hyprctl binds or an actual behavior.

I'm sorry if this is too much to ask, but could you maybe add a println to check the command it's generating, and trying it with hyprctl since I'm not on hyprland at the moment. I really only want to merge this, if the binding works, as binding layout commands is pretty essential imo.

AddMaster => "layoutmsg addmaster".to_string(),
RemoveMaster => "layoutmsg removemaster".to_string(),
OrientationLeft => "layoutmsg orientationleft".to_string(),
OrientationRight => "layoutmsg orientationright".to_string(),
OrientationTop => "layoutmsg orientationtop".to_string(),
OrientationBottom => "layoutmsg orientationbottom".to_string(),
OrientationCenter => "layoutmsg orientationcenter".to_string(),
OrientationNext => "layoutmsg orientationnext".to_string(),
OrientationPrev => "layoutmsg orientationprev".to_string(),
ToggleGroup => "togglegroup".to_string(),
ChangeGroupActive(dir) => format!("changegroupactive{sep}{dir}"),
LockGroups(how) => format!("lockgroups{sep}{how}"),
Expand Down