Less duplicated code.

svn path=/trunk/kdebase/kwin/; revision=333547
This commit is contained in:
Luboš Luňák 2004-07-28 15:49:54 +00:00
parent 044fec7186
commit 19d92946a2

View file

@ -55,32 +55,6 @@ void DetectDialog::detect( WId window )
readWindow( window ); readWindow( window );
} }
static QCString getStringProperty(WId w, Atom prop, char separator=0)
{
Atom type;
int format, status;
unsigned long nitems = 0;
unsigned long extra = 0;
unsigned char *data = 0;
QCString result = "";
status = XGetWindowProperty( qt_xdisplay(), w, prop, 0, 10000,
FALSE, XA_STRING, &type, &format,
&nitems, &extra, &data );
if ( status == Success)
{
if (data && separator)
{
for (int i=0; i<(int)nitems; i++)
if (!data[i] && i+1<(int)nitems)
data[i] = separator;
}
if (data)
result = (const char*) data;
XFree(data);
}
return result;
}
void DetectDialog::readWindow( WId w ) void DetectDialog::readWindow( WId w )
{ {
if( w == 0 ) if( w == 0 )
@ -89,24 +63,23 @@ void DetectDialog::readWindow( WId w )
return; return;
} }
KXErrorHandler err; KXErrorHandler err;
XClassHint hint; KWin::WindowInfo info = KWin::windowInfo( w,
XGetClassHint( qt_xdisplay(), w, &hint ); NET::WMName | NET::WMWindowType,
Atom wm_role = XInternAtom( qt_xdisplay(), "WM_WINDOW_ROLE", False ); NET::WM2WindowClass | NET::WM2WindowRole | NET::WM2ClientMachine );
KWin::WindowInfo info = KWin::windowInfo( w );
if( !info.valid()) if( !info.valid())
{ {
emit detectionDone( false ); emit detectionDone( false );
return; return;
} }
wmclass_class = hint.res_class; wmclass_class = info.windowClassClass();
wmclass_name = hint.res_name; wmclass_name = info.windowClassName();
role = getStringProperty( w, wm_role ); role = info.windowRole();
type = info.windowType( NET::NormalMask | NET::DesktopMask | NET::DockMask type = info.windowType( NET::NormalMask | NET::DesktopMask | NET::DockMask
| NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask | NET::OverrideMask | NET::TopMenuMask
| NET::UtilityMask | NET::SplashMask ); | NET::UtilityMask | NET::SplashMask );
title = info.name(); title = info.name();
extrarole = ""; // TODO extrarole = ""; // TODO
machine = getStringProperty( w, XA_WM_CLIENT_MACHINE ); machine = info.clientMachine();
if( err.error( true )) if( err.error( true ))
{ {
emit detectionDone( false ); emit detectionDone( false );