Outlining the framework I sent earlier, I wrote out some more detailed 
instructions on how to do a similar operation on a Wayland backend here 
<https://groups.google.com/g/qtile-dev/c/PDjUtChnd3s/m/9M1VtHWGAgAJ>.
The only needed modification is to add in some math on how to get the 
window centered to the screen and getting the dimensions of the screen 
itself (though if you see an example of that in the source code for the 
"place" method 
<https://github.com/qtile/qtile/blob/9e8f9b7d8d28f16e002c83f319da62d9d9ba9f91/libqtile/backend/wayland/window.py#L508-L511>).
 
I'm sure the process is fairly similar for X11.

@David, if you figured out a solution, it'd be great if you could include 
it in this chain, for posterities sake.

On Monday, December 6, 2021 at 1:52:29 PM UTC-5 elParaguayo wrote:

> That feels like something that we could potentially expose as a command so 
> that you could then do something like "lazy.window.centre()".
>
> On Monday, 6 December 2021 at 16:43:36 UTC [email protected] wrote:
>
>> Yeah, there is. It's have to be a custom function (though one that 
>> could/should be added to core qtile).
>>
>> Basically, you'll need to:
>> - get the coordinates/dimension of the current window
>> - calculate the center of the screen, 
>> - get the dimensions of the current window
>> - calculate the required displacement (note that window position is based 
>> on one of the corners of the window. I believe top left, but don't quote me 
>> on it)
>> - move the currently active window to move it to the center of the 
>> current screen. Should be a method of the active window.
>>
>> Unfortunately I don't remember the actual commands for doing everything 
>> above. One of these days I'll actually make a video/write up about how I 
>> hack in qtile so I can just point to that.
>>
>> Regardless, if you have any questions on the above, let me know.
>>
>> On Sat, Dec 4, 2021, 15:40 David Budzynski <[email protected]> wrote:
>>
>>> Is there a way to assign a key binding so a floating window goes to the 
>>> center of the screen?
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "qtile-dev" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/qtile-dev/ec547e3f-d2b7-40f9-8bf4-96331061b455n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/qtile-dev/ec547e3f-d2b7-40f9-8bf4-96331061b455n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/303ba015-1759-4d07-a764-653045b1c8e2n%40googlegroups.com.

Reply via email to