klange / toaruos

A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
https://toaruos.org/
University of Illinois/NCSA Open Source License
6.03k stars 475 forks source link

window minimization? #267

Closed Q-Dylan closed 1 year ago

Q-Dylan commented 1 year ago

Unlike Windows and Ubuntu, seems that we can only maximize and close the window in this OS. We can't minimize the window to the panel on top of the screen. Is it difficult to implement or just it isn't necessary?

klange commented 1 year ago

I apologize - I thought I had posted an answer to this question before, but I was mistaken.

The main reason ToaruOS lacks window minimization is simply that I don't tend to use it even on my host systems.

The main way I would envision implementing window minimization would be to simply mark the window to not be rendered or considered for input management. The window would still be advertised to clients that request window lists, if it is of the appropriate type, but it would not appear on-screen or receive mouse events. Sending a focus message, such as through the alt-tab window or clicking a minimized window in the task bar, would restore the window. We can also animate this switch between states, similar to opening and closing a window.

However, if we keep the window's surface around, it will continue to use memory, but the application can remain oblivious to its change in visibility and continue to draw itself behind the scenes. Alternatively, it can be resized to reduce space (sometimes called iconifying, especially in older OSes), but this then requires the application to be able to handle this change.

I think I had a branch in progress at some point to support simple minimization - I may revisit it.

klange commented 1 year ago

I have an initial prototype of window minimization here: https://github.com/klange/toaruos/tree/window-minimize

This branch includes a new special request and temporary keybindings in the compositor to minimize a window. This will start an animation, and when that animation is finished the window will be removed from the stacking order and hidden. It will be advertised to query clients (eg. the panel) with an additional flag to indicate the minimized status. When an attempt is made to focus the window again (via the panel, alt-tab, or other ways clients can request a particular window be focused), the window will be marked visible, returned to the top of the stacking order, and another animation will play. Additionally, the decoration library now supports an additional button in themes which will minimize a window, and this button has been added to the default theme.

I would still like to add a signal for applications to know they have been minimized, and am experimenting with other possibilities. I would like to explore more complex animation options, but the current scene rendering framework in the compositor limits animations to ones that do not exceed the bounds of the window's normal rendering area, so fancy effects like shrinking the icon towards its position on the panel are not yet possible.

klange commented 1 year ago

I have merged the window-minimize branch. There may still be some edge cases that are not well handled, but generally speaking Yutani now supports minimizing windows.