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

Add is_floating to StackSet. #306

Closed
2 of 6 tasks
codybloemhard opened this issue Aug 11, 2024 · 1 comment
Closed
2 of 6 tasks

Add is_floating to StackSet. #306

codybloemhard opened this issue Aug 11, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@codybloemhard
Copy link
Contributor

Please describe the change / addition you'd like to see made

I was digging through the docs and looking at the source of some methods to find out if I could figure out if a specific window is currently floating or not. I could not find it. Excuse me if I missed something.

This would give users the ability to toggle floating windows.
All it would require is to add this to StackSet:

pub fn is_floating(&mut self, client: &C) -> bool {
    self.floating.contains_key(client)
}

With that, I can write an action like this (not final):

pub fn toggle_float_focused<X: XConn>() -> Box<dyn KeyEventHandler<X>> {
    key_handler(|state, x: &X| {
        let id = match state.client_set.current_client() {
            Some(&id) => id,
            None => return Ok(()),
        };

        let r = x.client_geometry(id)?;

        x.modify_and_refresh(state, |cs| {
            if cs.is_floating(&id) {
                cs.sink(&id);
            } else if let Err(err) = cs.float(id, r) {
                // if this action where to be included in penrose
                // error!(%err, %id, "unable to float requested client window");
            }
        })
    })
}

I can open a pull request if this functionality is desirable.

  • Is this completely new functionality, or an enhancement to existing functionality?

Just enhancing the existing code for dealing with floating windows.

  • What kind of feature is it that you are requesting?
    • Changes to core
    • A new layout
    • A hook implementation
    • A custom extension
    • New X interactions
    • Other

Is this a feature you have seen in other window managers?

i3 does have a floating toggle (eg. bindsym $mod+Shift+f floating toggle).

@codybloemhard codybloemhard added the enhancement New feature or request label Aug 11, 2024
@sminez
Copy link
Owner

sminez commented Aug 12, 2024

I'd be happy to get this added if you are up for writing the PR @codybloemhard? I think it should also include toggle_floating (or maybe toggle_floating_state?) as a method directly on StackSet rather than users having to write the conditional behaviour themselves.

codybloemhard added a commit to codybloemhard/penrose that referenced this issue Aug 12, 2024
sminez pushed a commit that referenced this issue Aug 15, 2024
* feat: toggle_floating_state and is_floating (#306)

* fix: remove unnecessary mut;

* fix: apply cargo fmt;

* fix: remove mutable borrow from is_floating; refactor: toggle_floating_state; testcase: floating_client_status tests is_floating;

* test: toggle_floating_state

* fix: apply cargo fmt;
@sminez sminez closed this as completed Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants