Skip to main content

Module button

Module button 

Source
Expand description

The button in the panel, and the line between it and the window it opens.

Avestruz runs as two processes of the one program. The panel starts the first, which is this: an applet that is a button and nothing else. It starts the second, the same program told to be the window (WINDOW_FLAG), which is the whole client (see crate::app).

Two, because of who draws what. An applet’s surfaces are the panel’s: the panel is a compositor of its own, takes what its applets draw and hands it on, and takes no GPU buffers from them. An applet is therefore drawn by the CPU, which is plenty for a button and was the dearest thing about a list of pictures being scrolled. The window is no applet: it puts a surface of its own on the session’s compositor, and the GPU draws it.

flowchart LR
    subgraph panel["The panel, a compositor of its own"]
        button["The button: an applet, drawn by the CPU"]
    end
    window["The window: the client, drawn by the GPU"]
    compositor["The session's compositor"]
    button -->|"starts it, and says: toggle"| window
    window -->|"says: unread 1, unread 0"| button
    button -. "its surface is the panel's" .-> panel
    panel --> compositor
    window -->|"a surface of its own"| compositor

They talk over the window’s standard input and output, a line at a time. The button says TOGGLE when it is pressed. The window says UNREAD and 1 or 0: whether the account has been told of something it has not looked at, which the button shows as a dot. Nothing else goes over the line: the window logs to its standard error, which is the button’s, which the panel hands to the journal.

The window lives as long as the button does: when its input ends, it leaves. If it goes first, the button starts another.

The button is not the only one that can say TOGGLE. The window listens at a socket in the session’s runtime directory as well (socket_path), and the program started with TOGGLE_FLAG says it there and leaves: which is what a keyboard shortcut of the desktop’s runs, to open and close the popup without the mouse. One window listens there: this one, whenever no other does (see from_outside).

flowchart LR
    key["A key the desktop was told of"] -->|"runs"| said["The program, with --toggle"]
    said -->|"toggle, at the socket"| window["The window"]
    button["The button, pressed"] -->|"toggle, down the line"| window
    window --> popup["The popup opens, or closes"]

Structs§

Button
The button in the panel. See the module docs.
Listening 🔒
A socket the window listens at, and which file it was when the window began to: the path may come to name another’s socket, or nothing.

Enums§

Message
What happens to the button.

Constants§

CPU_RENDERER 🔒
DOT_INSET 🔒
How far in from the corner of the panel button the dot is that says there are new notifications.
LOOKED_AT_EVERY 🔒
How often the window looks whether the socket is still its own to listen at, and whether it has come to be nobody’s.
RENDERER 🔒
The variable by which iced is told what to draw with, and what the button is drawn with: the CPU renderer.
RESTART_AFTER 🔒
How long after the window went the button starts another.
SAID_WITHIN 🔒
How long whoever connects to the socket gets to say something.
SOCKET_NAME 🔒
What the socket the window listens at is called, in the session’s runtime directory.
TOGGLE
What the button says to the window when it is pressed.
TOGGLE_FLAG
What the program is started with to say TOGGLE to the window that is running, and leave.
UNREAD
What the window says to the button, before 1 or 0: whether there is something the account has not looked at.
WINDOW_FLAG
What the program is started with to be the window rather than the button.

Statics§

RENDERER_ASKED_FOR 🔒
What RENDERER said when the program started, before the button took it for itself: the window’s to go by.

Functions§

file_at 🔒
Which file is at path, as the file system tells files apart. None if none is.
from_button
What the button says to the window, as the window hears it: each toggle, and that the button is gone when its end of the line closes.
from_outside
What is said to the window from outside, at the socket path, as the window hears it: each toggle. Nothing, ever, if there is no path.
heard_at 🔒
from_outside, looking at the socket every looked_at_every.
next_at 🔒
Whoever connects next to the socket listened at. Nobody, ever, while none is; None if they could not be let in.
run
Run the program as the button: an applet, drawn by the CPU whatever the program was built to draw with.
say_toggle
Say TOGGLE to the window that listens at path. An error if none does.
socket_path
Where the window listens for what is said to it from outside: in the session’s runtime directory, which is its user’s alone. None if the session has none.
start_window 🔒
Start the program again as the window, on the session’s compositor rather than the panel’s: without the socket the panel gave the button, and drawn with what was asked for, which by default is the GPU.
tell_unread
Say to the button, from the window, whether there is something not looked at. To nobody, if the window was started by hand.
unread_said 🔒
What line, said by the window, means: whether there is something not looked at, if that is what it says.
window 🔒
The window, for as long as the button is there: started, told of each press, listened to, and started again if it goes.