I have been looking pretty closely at the c code in wmctrl. Its nice clean C, not C++ so understandable even by me. So, I reasoned, following just the "mv window here" path might be a good approach.
https://github.com/Conservatory/wmctrl/blob/master/main.cEverything I need does seem to be available in the x, xlib, ctypes, xatom bindings.
It does not use XChangeProperty(), it posts an event to X in some manner. It does use XGetWindowProperty() with its 12 parameters, to read specific properties from the window (much line env vars as Mark mentioned). You call it, tell it which property you are interested in and it comes back with a heap of data. Including, I am guessing, the Workspace number if you ask for the right property.
So far, all I can get is an AV when I call XGetWindowProperty() and it late here ! Going to bed.
Davo
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls {$ifdef LINUX}, x, xlib, ctypes, xatom, process {$endif};
....
const Max_Property_Value_Len = 4096;
procedure TForm1.MoveWindow();
var
Disp : PDisplay;
Prop : cint;
Win : TWindow;
xa_prop_name : TAtom;
xa_ret_type : PAtom;
ret_format : Pcint;
ret_nitems, ret_bytes_after, tmp_size : Pculong;
ret_prop : PPcuchar;
begin
Disp := XOpenDisplay(Nil);
if Disp = nil then begin
Memo1.Append('Nope, unable to open Disp');
end else begin
xa_prop_name := XInternAtom(disp, '_NET_CLIENT_LIST', False);
Win := DefaultRootWindow(disp);
Prop := XGetWindowProperty(Disp, Win, xa_prop_name, 0, MAX_PROPERTY_VALUE_LEN div 4,
False, XA_WINDOW, xa_ret_type, ret_format, ret_nitems, ret_bytes_after, ret_prop);
end;
XCloseDisplay(disp);
end;
(* C code looks like this -
Window *client_list;
if ((client_list = (Window * )get_property(disp, DefaultRootWindow(disp),
XA_WINDOW, "_NET_CLIENT_LIST", size)) == NULL) {
if ((client_list = (Window * )get_property(disp, DefaultRootWindow(disp),
XA_CARDINAL, "_WIN_CLIENT_LIST", size)) == NULL)
Pascal -
function XGetWindowProperty(para1:PDisplay; para2:TWindow; para3:TAtom; para4:clong; para5:clong;
para6:TBool; para7:TAtom; para8:PAtom; para9:Pcint; para10:Pculong;
para11:Pculong; para12:PPcuchar):cint;cdecl;external libX11; *)