luawindow-decoration

How to get window decorations pixel size in LUA


I am using rdesktop with seamlessrdp. This way I can open Windows apps on my Linux machines. Also I added devilspie2 to the mix so I could control the window decorations. devilspie2 uses lua as its config management. I made everything work. The only issue left is to move the opening (dialog) windows a couple of pixels because the VNC windows will appear as if they had decorations (but without them). I got the code working by hard coding the amount of pixels needed to move. The issue is we have more than one distros here and they have different pixel sizes for their window decorations.

What I want is to GET the decoration size in pixels instead of hard coding them so it will work perfectly for all my distros.

Here is the piece of code that does it atm:

if get_window_class()=="SeamlessRDP" then
    undecorate_window();

    --x-1 and y-28 works for one distro but for the other I need to use x-6 and y-27
    if get_window_type()=="WINDOW_TYPE_DIALOG" then
        x, y = xy();
        xy(x-1, y-28);
    end
end

As you can see from the script. It would be much better if I could somehow call the size of the window decorations and then use them rather than hard coded pixels.

EDIT (ANSWER):

Even though I found the answer before the following post, I wanted to accept it anyways because it did show the right path to follow. I am only further commenting here to show the full answer:

--get x and y's for decorated and non-decorated windows
x1, y1, width1, height1 = get_window_geometry();
x2, y2, width2, height2 = get_window_client_geometry();

--calculate pixels to slide window
xpixel = x2-x1;
ypixel = y2-y1;


--check if class is seamlessrdp
if get_window_class()=="SeamlessRDP" then
    undecorate_window();

    --if window is a dialog then move it
    if get_window_type()=="WINDOW_TYPE_DIALOG" then
        xy(x1-xpixel, y1-ypixel);
    end
end

Solution

  • devilspie2 provides only two ways to get the window size, get_window_geometry and get_window_client_geometry.

    Whereby the last one excludes the window borders. If this does not work for you, you can create a file with a table for all values to make them easily editable. You could also use the window class names as table keys if possible to make the use easier.