Closed ramirezmike closed 3 years ago
add configuration of how pinned windows look (should allow hiding title bar?)
Can you still move the window by using the mouse when hiding the title bar?
Edit:
Then again even if this would be a shit idea ux wise, we could easily support this if make the configuration flexible enough. Have you thought about how we could allow easy customization of the pinned window?
An idea I have is that the user could just get the currently focused window via our provided API and modify the window to their liking and then manually pin the window.
A few ideas:
local win = nog.win_get_focused()
nog.win_configure(win, {
disable_title_bar = true
})
nog.win_toggle_pin(win)
local win = nog.win_get_focused()
nog.win_configure(win, {
disable_title_bar = true,
pinned = true
})
local win = nog.win_get_focused()
nog.win_hide_title_bar(win)
nog.win_toggle_pin(win)
Can you still move the window by using the mouse when hiding the title bar?
No, you'd have to unpin and move it and then repin. I suspect an approach we could look into is something like... making it so if you have the alt key held down and you click within a pinned window, it acts as if you're moving the window, but I'm not sure how easy that is. I think it's possible though. A "round one" implementation would just be to not have that piece in yet.
That said, I do like the configuration ideas. Would be more flexible.
So, I pretty much finished this and then re-read the comments and realized I forgot about this whole thing 🤦♂️
local win = nog.win_get_focused()
nog.win_hide_title_bar(win)
nog.win_toggle_pin(win)
I think I'm gonna go with something like the above. I don't believe we have a "win_get_focused" yet, right? I see... get_current_win returns the focused window on the current grid get_focused_win_of_display returns the focused window of the grid on a specific display
but win_get_focused would be like.. getting whatever window that the operating system currently has focused, right?
I started implementing what I mentioned above but I'm not sure how user friendly it is
nog.nbind("alt+shift+o", function ()
local id = nog.get_focused_win()
nog.win_pin_to_ws(id)
nog.win_hide_title_bar(id)
end)
I got this to work but it would need more functions that gets the state of the window. "pin_to_ws" behaves like a toggle (like toggle_floating) but hide_title_bar and show_title_bar are distinct functions..
You'd end up with something like
nog.nbind("alt+shift+o", function ()
local id = nog.get_focused_win()
nog.win_pin_to_ws(id)
if nog.win_has_title_bar(id) then
nog.win_hide_title_bar(id)
else
nog.win_show_title_bar(id)
end)
which is a little verbose.. What do you think? @TimUntersberger
I got this to work but it would need more functions that gets the state of the window
I created a function for workspace that is called ws_get_info
(I think?) that returns a table of information about the workspace. We could do the same with windows.
In the future I'd like to play a bit more with metatables so that we maybe could create a Window and Workspace proxy similar to the config.
What it could look like
local win = nog.get_focused_win()
print(win.title, win.width, win.height, ...)
win.add_titlebar()
win.remove_titlebar()
win.has_titlebar()
...
local ws = nog.get_focused_ws()
ws.add(win)
...
which is a little verbose.. What do you think? @TimUntersberger
The verbosity is not a problem for now, because we can always extract functionality into the runtime.lua
file for this.
So as long as it is possible on the lua side it should be fine.
I added a couple items to the public API but I also saw you're making some changes so let me know if I should remove some of these. Also, I added the ability to pin to specific workspaces which I call a "workspace pin" but I don't know what to call non-workspace pin... Would "global pin" be confusing?
nog.toggle_view_pinned() -- toggles visibility of globally pinned windows
nog.has_pinned() -- returns whether there are any globally pinned windows
nog.get_focused_win() -- returns the window ID of the operating-system focused window
nog.win_hide_title_bar(win_id) -- hides the title bar of the given window
nog.win_show_title_bar(win_id) -- shows the title bar of the given window
nog.win_hide_border(win_id) -- hides the border of the given window
nog.win_show_border(win_id) -- shows the border of the given window
nog.win_toggle_pin(win_id) -- toggles global pin of the given window
nog.win_toggle_ws_pin(win_id) -- toggles pin of the given window on the current workspace
nog.win_is_pinned(win_id) -- returns whether the given window is pinned
nog.ws_toggle_view_pinned() -- toggles the visibility of pinned windows on the active workspace
nog.ws_has_pinned(ws_id) -- returns whether the given workspace has pinned windows
Also, I'm thinking of pulling the pinning code into a separate file. Is "pinned" or "pinning" going to be confusing with Rust's concept of Pin?
@TimUntersberger
I added a couple items to the public API but I also saw you're making some changes so let me know if I should remove some of these
My API pr is currently just experimental.
Also, I added the ability to pin to specific workspaces which I call a "workspace pin" but I don't know what to call non-workspace pin... Would "global pin" be confusing?
Global should be fine I think
Also, I'm thinking of pulling the pinning code into a separate file. Is "pinned" or "pinning" going to be confusing with Rust's concept of Pin?
I don't think so, since pinning has a special meaning in our domain and we don't use rust pins.
I think this PR is finally in a state that it can be reviewed. I'd recommend filtering on just .md/.rs files.
Let me know what you think @TimUntersberger , I'm open to suggestions.
I added usage notes in the issue #255
LGTM! Thank you for your hard work!
255
TODO