From 78af57e1816ac45658ca5fb7b5d510f83370d9b1 Mon Sep 17 00:00:00 2001 From: Wizzup? Date: Fri, 18 Dec 2009 13:39:36 +0000 Subject: [PATCH] When the window selector hovers over a window that can be made transparent, it will make it transparent. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@287 3f818213-9676-44b0-a9b4-5e4c4e03d09d --- Units/MMLAddon/windowselector.pas | 33 ++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/Units/MMLAddon/windowselector.pas b/Units/MMLAddon/windowselector.pas index f4dae8a..2f2fbce 100644 --- a/Units/MMLAddon/windowselector.pas +++ b/Units/MMLAddon/windowselector.pas @@ -34,7 +34,7 @@ uses controls, graphics, forms, - {$IFNDEF MSWINDOWS}x, xlib + {$IFNDEF MSWINDOWS}x, xlib,xatom {$ELSE} windows {$ENDIF} @@ -87,17 +87,27 @@ var x, y : cint; Old_Handler : TXErrorHandler; + window_opacity: TAtom; + opacity_75: culong; + opacity_100: culong; + begin Old_Handler := XSetErrorHandler(@MufasaXErrorHandler); Result := 0; + window_opacity:=XInternAtom(Window.XDisplay,PChar('_NET_WM_WINDOW_OPACITY'), False); + opacity_75 := cuint($ffffffff * 0.75); + opacity_100 := cuint($ffffffff); + repeat + // get pointer pos + current window we are at. XQueryPointer(Window.XDisplay, Window.DesktopWindow, @root, @Tempwindow, @x_root, @y_root, @x, @y, @xmask); subwindow:= Tempwindow; + // find the most `child' window. while subwindow <> 0 do begin Tempwindow := subwindow; @@ -105,16 +115,33 @@ begin @subwindow, @x_root, @y_root, @x, @y, @xmask); end; + + + if Result <> Tempwindow then begin - WriteLn('Changing Window to: ' + IntToStr(Tempwindow)); + writeln('Making ' + inttostr(tempwindow) + ' transparent'); + XChangeProperty(Window.XDisplay, tempwindow, window_opacity, XA_CARDINAL, 32, PropModeReplace, @opacity_75, 1); + + writeln('Resetting ' + inttostr(Result)); + if result <> 0 then + XChangeProperty(Window.XDisplay, Result, window_opacity, XA_CARDINAL, 32, PropModeReplace, @opacity_100, 1); + WriteLn('Changing Window from: ' + Inttostr(result) +' to: ' + IntToStr(Tempwindow)); + // XChangeProperty(Window.XDisplay, tempwindow, window_opacity, XA_CARDINAL, 32, PropModeReplace, @opacity_50, 1); + Result := Tempwindow; end; - + XFlush(Window.XDisplay); Sleep(16); + //if we are selecting for a long time, we must still process other messages + Application.ProcessMessages; + until (xmask and Button1Mask) = 0; + XChangeProperty(Window.XDisplay, Result, window_opacity, XA_CARDINAL, 32, PropModeReplace, @opacity_100, 1); + XFlush(Window.XDisplay); + XSetErrorHandler(Old_handler); end;