Improved window blacklist

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@229 b624d157-de02-0410-bad0-e51aec6abb33
master
sniperbeamer 16 years ago
parent 699befe618
commit f533ea45a7
  1. 2
      src/forms/TargetWindowDlg.ui
  2. 18
      src/lib/AutoType_X11.cpp

@ -5,7 +5,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>574</width> <width>525</width>
<height>145</height> <height>145</height>
</rect> </rect>
</property> </property>

@ -161,7 +161,8 @@ void AutoType::perform(IEntryHandle* entry, QString& err,bool hideWindow,int nr)
#ifdef GLOBAL_AUTOTYPE #ifdef GLOBAL_AUTOTYPE
Window windowRoot; Window windowRoot;
QStringList windowBlacklist; //QSet<QString> windowBlacklist;
QSet<QString> classBlacklist;
Atom wm_state; Atom wm_state;
void windowTitles(Window window, QStringList& titleList){ void windowTitles(Window window, QStringList& titleList){
@ -179,9 +180,17 @@ void windowTitles(Window window, QStringList& titleList){
int count; int count;
if (Xutf8TextPropertyToTextList(d, &textProp, &list, &count)>=0 && list){ if (Xutf8TextPropertyToTextList(d, &textProp, &list, &count)>=0 && list){
QString title = QString::fromUtf8(list[0]); QString title = QString::fromUtf8(list[0]);
QString className;
XClassHint* wmClass = XAllocClassHint();
if (XGetClassHint(d, window, wmClass)!=0 && wmClass->res_name!=NULL)
className = QString::fromLocal8Bit(wmClass->res_name);
XFree(wmClass);
if (window!=windowRoot && window!=AutoType::MainWin->winId() && if (window!=windowRoot && window!=AutoType::MainWin->winId() &&
(QApplication::activeWindow()==NULL || window!=QApplication::activeWindow()->winId()) && (QApplication::activeWindow()==NULL || window!=QApplication::activeWindow()->winId()) &&
!windowBlacklist.contains(title) // !windowBlacklist.contains(title) &&
(className.isNull() || !classBlacklist.contains(className))
){ ){
titleList.append(title); titleList.append(title);
} }
@ -207,7 +216,10 @@ void AutoType::init(){
Display* d = QX11Info::display(); Display* d = QX11Info::display();
wm_state = XInternAtom(d, "WM_STATE", true); wm_state = XInternAtom(d, "WM_STATE", true);
windowRoot = XRootWindow(d, MainWin->x11Info().screen()); windowRoot = XRootWindow(d, MainWin->x11Info().screen());
windowBlacklist << "kicker" << "KDE Desktop"; //windowBlacklist << "kicker" << "KDE Desktop";
classBlacklist << "desktop_window" << "gnome-panel"; // Gnome
classBlacklist << "kdesktop" << "kicker"; // KDE 3
classBlacklist << "xfdesktop" << "xfce4-panel"; // Xfce 4
} }
QStringList AutoType::getAllWindowTitles(){ QStringList AutoType::getAllWindowTitles(){