dspdfviewer
dspdfviewer copied to clipboard
Improve i3 support, and generalize desktop support in the process
Motivation: I use it myself
What should it do
- Query RANDR outputs via i3 ipc
i3-msg -t get_outputsgives JSON- Only check active:true and hope it's two of them
- The one with primary will likely be the laptop screen
- Use i3's IPC mechanism to send "Move window id to output name
This can be generalized to "Desktop environment support modules", and move the Window-Movement code away from the PDFViewerWindow class.
DE Support Modules should support the following functions:
- Is this my environment?
- Outputs unsigned value of how good the module is for the current DE
- 0 this is definitly not my environment. Do not call other functions on this handler
- 1 for the generic handler, meaning the current X11 handler
- 10 if the OS matches (move the current WIN32 handler here)
- 100 or for specific handlers that can detect their special environment is active (such as an i3 handler)
- Enumerate outputs
- Returns vector of unique_ptr to handler-specific structure
- Get primary output
- Can throw "Cannot figure out which is the primary"
- If exception ignored, picks the numerically first
- Can throw "Cannot figure out which is the primary"
- Get secondary output (parametrize to ignore errors)
- Can throw "Only one screen"
- If not called to ignore errors, will throw "Cannot figure out which is the secondary"
- If not called to ignore errors, will throw "Too many screens"
- If errors ignored, outputs second screen
- Move window to output $handle
Make sure the interface is clean, that is near-impossible to use incorrectly. (No raw pointers etc.)
May I question why this is here? It probably makes sense for other DEs, but for i3 specifically, this is trivial to do:
I simply assign workspace 10 to always be on the output I use for presentations, and assign the dspdfviewer window to always be on that workspace. Job done, literally 2 lines, one of which I had already before using dspdfviewer. Has the nice advantage that it doesn't break if I open dspdfviewer before connecting to the projector :)
workspace $ws10 output DP2 # VGA output
assign [title="DS PDF Viewer - Audience Window"] $ws10