From a9517d38c2d94020d1dfb12eaa9da41e57e2c594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 4 Aug 2004 11:00:40 +0000 Subject: [PATCH] Pre-fill geometry, state etc. to inactive settings in order to make it simpler to have an equivalent of 3.2's Save window settings. svn path=/trunk/kdebase/kwin/; revision=335931 --- kcmkwin/kwinrules/detectwidget.cpp | 4 +-- kcmkwin/kwinrules/detectwidget.h | 10 +++++++- kcmkwin/kwinrules/ruleswidget.cpp | 40 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/kcmkwin/kwinrules/detectwidget.cpp b/kcmkwin/kwinrules/detectwidget.cpp index 853e220490..4acc84faca 100644 --- a/kcmkwin/kwinrules/detectwidget.cpp +++ b/kcmkwin/kwinrules/detectwidget.cpp @@ -61,9 +61,7 @@ void DetectDialog::readWindow( WId w ) emit detectionDone( false ); return; } - KWin::WindowInfo info = KWin::windowInfo( w, - NET::WMName | NET::WMWindowType, - NET::WM2WindowClass | NET::WM2WindowRole | NET::WM2ClientMachine ); + info = KWin::windowInfo( w, -1U, -1U ); // read everything if( !info.valid()) { emit detectionDone( false ); diff --git a/kcmkwin/kwinrules/detectwidget.h b/kcmkwin/kwinrules/detectwidget.h index 42de589e64..57668645b7 100644 --- a/kcmkwin/kwinrules/detectwidget.h +++ b/kcmkwin/kwinrules/detectwidget.h @@ -23,7 +23,7 @@ #include "detectwidgetbase.h" #include -#include +#include #include "../../rules.h" @@ -53,6 +53,7 @@ class DetectDialog QString selectedTitle() const; Rules::StringMatch titleMatch() const; QCString selectedMachine() const; + const KWin::WindowInfo& windowInfo() const; signals: void detectionDone( bool ); protected: @@ -71,8 +72,15 @@ class DetectDialog QCString machine; DetectWidget* widget; QDialog* grabber; + KWin::WindowInfo info; }; +inline +const KWin::WindowInfo& DetectDialog::windowInfo() const + { + return info; + } + } // namespace #endif diff --git a/kcmkwin/kwinrules/ruleswidget.cpp b/kcmkwin/kwinrules/ruleswidget.cpp index 24accdf859..5df8ec7c6d 100644 --- a/kcmkwin/kwinrules/ruleswidget.cpp +++ b/kcmkwin/kwinrules/ruleswidget.cpp @@ -506,6 +506,16 @@ bool RulesWidget::setWindow( WId w ) return detect_dlg_ok; } +#define GENERIC_PREFILL( var, func, info, uimethod ) \ + if( !enable_##var->isChecked()) \ + { \ + var->uimethod( func( info )); \ + } + +#define CHECKBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setChecked ) +#define LINEEDIT_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setText ) +#define COMBOBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setCurrentItem ) + void RulesWidget::detected( bool ok ) { if( ok ) @@ -540,12 +550,42 @@ void RulesWidget::detected( bool ok ) machine->setText( detect_dlg->selectedMachine()); machine_match->setCurrentItem( Rules::UnimportantMatch ); machineMatchChanged(); + // prefill values from to window to settings which already set + const KWin::WindowInfo& info = detect_dlg->windowInfo(); + LINEEDIT_PREFILL( position, positionToStr, info.frameGeometry().topLeft() ); + LINEEDIT_PREFILL( size, sizeToStr, info.frameGeometry().size() ); + COMBOBOX_PREFILL( desktop, desktopToCombo, info.desktop() ); + CHECKBOX_PREFILL( maximizehoriz,, info.state() & NET::MaxHoriz ); + CHECKBOX_PREFILL( maximizevert,, info.state() & NET::MaxVert ); + CHECKBOX_PREFILL( minimize,, info.isMinimized() ); + CHECKBOX_PREFILL( shade,, info.state() & NET::Shaded ); + CHECKBOX_PREFILL( fullscreen,, info.state() & NET::FullScreen ); + //COMBOBOX_PREFILL( placement, placementToCombo ); + CHECKBOX_PREFILL( above,, info.state() & NET::KeepAbove ); + CHECKBOX_PREFILL( below,, info.state() & NET::KeepBelow ); + // noborder is only internal KWin information, so let's guess + CHECKBOX_PREFILL( noborder,, info.frameGeometry() == info.geometry() ); + CHECKBOX_PREFILL( skiptaskbar,, info.state() & NET::SkipTaskbar ); + CHECKBOX_PREFILL( skippager,, info.state() & NET::SkipPager ); + //CHECKBOX_PREFILL( acceptfocus, ); + //CHECKBOX_PREFILL( closeable, ); + //COMBOBOX_PREFILL( fsplevel, ); + //COMBOBOX_PREFILL( moveresizemode, moveresizeToCombo ); + COMBOBOX_PREFILL( type, typeToCombo, info.windowType( SUPPORTED_WINDOW_TYPES_MASK ) ); + //CHECKBOX_PREFILL( ignoreposition, ); + LINEEDIT_PREFILL( minsize, sizeToStr, info.frameGeometry().size() ); + LINEEDIT_PREFILL( maxsize, sizeToStr, info.frameGeometry().size() ); } delete detect_dlg; detect_dlg = NULL; detect_dlg_ok = ok; } +#undef GENERIC_PREFILL +#undef CHECKBOX_PREFILL +#undef LINEEDIT_PREFILL +#undef COMBOBOX_PREFILL + bool RulesWidget::finalCheck() { if( description->text().isEmpty())