1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| function TGtk2WidgetSet.X11GetActiveWindow: HWND;
var
Display: PDisplay;
RootWin, ResultWindow: TWindow;
WMAtom: TAtom;
ActualTypeReturn: TAtom;
format_ret: integer;
nitems_ret: culong;
bytes_after_ret: culong;
prop: Pcuchar;
// ActualFormatReturn: LongInt;
// NItemsReturn, BytesAfterReturn: Cardinal;
// Ptr: PByte;
ActualFormatReturn: integer;
NItemsReturn, BytesAfterReturn: culong;
Ptr: Pcuchar;
Valid: Boolean;
begin
Result := 0;
Display := gdk_x11_get_default_xdisplay;
if Display = nil then Exit;
RootWin := gdk_x11_get_default_root_xwindow;
WMAtom := XInternAtom(Display,'_NET_ACTIVE_WINDOW', False);
Valid:=XGetWindowProperty(Display, RootWin, WMAtom, 0, 1, False,
AnyPropertyType, @ActualTypeReturn,
@ActualFormatReturn, @NItemsReturn,
@BytesAfterReturn, @Ptr)=0;
if Valid then
try
if (ActualTypeReturn = None) or (ActualFormatReturn <> 32) or not Assigned(Ptr) then
Valid := False;
if Valid then ResultWindow := PWindow(Ptr)^;
finally
if Assigned(Ptr) then XFree(Ptr);
end;
if Valid then Result := {%H-}HWND(gdk_window_foreign_new(ResultWindow));
end; |
Partager