From 8f03a5415dcc9847678e079254e2c36d170f813b Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 20 Dec 2011 23:49:24 +0200 Subject: [PATCH] seems that 'per app' and 'per window' modes are working ok --- src/jrugr.cpp | 296 +++++++++++++++++++++++++++++++++++++++------------- src/jrugr.h | 26 ++++- src/jrugrconfui.cpp | 40 +++++-- src/x11tools.cpp | 11 +- src/x11tools.h | 3 +- src/xkeyboard.cpp | 12 +-- 6 files changed, 291 insertions(+), 97 deletions(-) diff --git a/src/jrugr.cpp b/src/jrugr.cpp index c84a19f..7348506 100644 --- a/src/jrugr.cpp +++ b/src/jrugr.cpp @@ -8,6 +8,14 @@ //////////////////////////////////////////////////////////////////////////////// +static Atom + atomActWin = None, + atomClientList = None, + atomCurDesk = None; + + +//////////////////////////////////////////////////////////////////////////////// +/* static const char *x11EventNames[] = { "0", "1", @@ -52,6 +60,7 @@ static const char *x11EventName (const XEvent *ev) { if (ev->type < 0 || ev->type > 34) return x11EventNames[35]; return x11EventNames[ev->type]; } +*/ //////////////////////////////////////////////////////////////////////////////// @@ -88,20 +97,6 @@ static void dumpWindowStack () { } -static Window findGMRun () { - QX11WindowList wl = X11Tools::topLevelWindows(); - int desk = X11Tools::activeDesktop(); - // - for (int f = 0; f < wl.size(); ++f) { - Window w = wl[f]; - int wd = X11Tools::windowDesktop(w); - // - if ((wd < 0 || wd == desk) && X11Tools::windowClass(w) == "gmrun") return w; - } - return None; -} - - //////////////////////////////////////////////////////////////////////////////// static Window makeFacehugger (Window parent) { Window res; @@ -113,7 +108,7 @@ static Window makeFacehugger (Window parent) { attr.win_gravity = NorthWestGravity; res = XCreateWindow(dpy, parent, // display, parent - 0, 0, 20, 20, // x, y, width, height + -20, -20, 1, 1, // x, y, width, height 0, // border width CopyFromParent, // depth InputOnly, //class @@ -121,8 +116,9 @@ static Window makeFacehugger (Window parent) { CWWinGravity | CWOverrideRedirect, // valuemask &attr); // attrs - XSelectInput(dpy, parent, /*SubstructureNotifyMask | */StructureNotifyMask); - //XSelectInput(dpy, res, ExposureMask | ButtonPressMask | ButtonMotionMask | ButtonReleaseMask); + //WARNING! this WILL NOT work as expected on our own windows! + XSelectInput(dpy, parent, SubstructureNotifyMask | StructureNotifyMask); + XSelectInput(dpy, res, ExposureMask/* | ButtonPressMask | ButtonMotionMask | ButtonReleaseMask*/); //XMapRaised(dpy, res); switch (res) { case BadAlloc: @@ -141,13 +137,11 @@ static Window makeFacehugger (Window parent) { } -static Window fhWin = None, fhPWin = None; - - //////////////////////////////////////////////////////////////////////////////// static QAbstractEventDispatcher::EventFilter oldEventFilter = 0; +#if 0 static bool swEventFilter (void *msg) { #if 0 XEvent *ev = (XEvent *)msg; @@ -179,6 +173,7 @@ static bool swEventFilter (void *msg) { } return false; } +#endif //////////////////////////////////////////////////////////////////////////////// @@ -193,27 +188,33 @@ Jrugr::Jrugr (int &argc, char **argv) : mCfgForm(0), mDeskJustChanged(false) { + if (atomActWin == None) atomActWin = XInternAtom(QX11Info::display(), "_NET_ACTIVE_WINDOW", True); + if (atomClientList == None) atomClientList = XInternAtom(QX11Info::display(), "_NET_CLIENT_LIST", True); + if (atomCurDesk == None) atomCurDesk = XInternAtom(QX11Info::display(), "_NET_CURRENT_DESKTOP", True); + + setEventNames(); // mandatory to keep it running after closing about dialogs... setQuitOnLastWindowClosed(false); mXkb = new XKeyboard(); - setEventNames(); setWindowIcon(QIcon(":/about/jrugr.png")); + // mXkb->groupInfo(mGroupInfo); + // mActiveGroup = mXkb->activeGroup(); + mActiveWindow = X11Tools::activeWindow(); + mCurDesk = X11Tools::activeDesktop(); // + /* mEDisp = QAbstractEventDispatcher::instance(); if (mEDisp) { qDebug() << "setting system-wide event filter"; mEDisp->setEventFilter(swEventFilter); } - //dumpWinInfo("dump", X11Tools::activeWindow()); - dumpWindowStack(); + */ // - fhPWin = findGMRun(); - if (fhPWin != None) { - fhWin = makeFacehugger(fhPWin); - qDebug() << "facehugger:" << (int)fhWin << "parent:" << (int)fhPWin; - } + installFacehuggers(); + //dumpWinInfo("dump", X11Tools::activeWindow()); + //dumpWindowStack(); } @@ -234,6 +235,34 @@ void Jrugr::setEventNames () { } +void Jrugr::installFacehuggers () { + QX11WindowList wl = X11Tools::topLevelWindows(); + //int curLayout = mActiveGroup; + //QWidgetList twl = QApplication::topLevelWidgets(); + QWidgetList twl = QApplication::allWidgets(); + // + for (int f = 0; f < wl.size(); ++f) { + bool skipIt = false; + // + foreach (QWidget *wd, twl) { + if (wd->effectiveWinId() == wl[f]) { skipIt = true; break; } + } + if (skipIt) continue; + if (!mKnownWindows.contains(wl[f])) { + WinInfo wi; + // + wi.w = wl[f]; + wi.appWindow = X11Tools::appWindow(wi.w); + wi.facehugger = makeFacehugger(wi.w); + wi.layout = 0;//curLayout; + // + mKnownWindows[wi.w] = wi; + if (wi.appWindow == wi.w && !mKnownApps.contains(wi.w)) mKnownApps[wi.w] = wi; + } + } +} + + void Jrugr::setStartup () { // Display the config dialog only on first run. // It was really annoying to see it all time @@ -287,9 +316,25 @@ bool Jrugr::firstStart () { void Jrugr::init () { mXkb->groupInfo(mGroupInfo); if (jCfg->status == DONT_USE_XKB) return; - connect(mXkb, SIGNAL(groupChanged(int)), this, SLOT(groupChange(int))); - connect(mXkb, SIGNAL(layoutChanged()), this, SLOT(layoutChange())); - connect(this, SIGNAL(changeLayout(int)), this, SLOT(onChangeLayout(int))); + connect(mXkb, SIGNAL(groupChanged(int)), this, SLOT(groupChange(int)), Qt::QueuedConnection); + connect(mXkb, SIGNAL(layoutChanged()), this, SLOT(layoutChange()), Qt::QueuedConnection); + connect(this, SIGNAL(changeLayout(int)), this, SLOT(onChangeLayout(int)), Qt::QueuedConnection); + // + connect(this, SIGNAL(activeWindowChanged()), this, SLOT(doActiveWindowChanged()), Qt::QueuedConnection); + connect(this, SIGNAL(activeDesktopChanged()), this, SLOT(doActiveDesktopChanged()), Qt::QueuedConnection); + connect(this, SIGNAL(clientListChanged()), this, SLOT(onClientListChanged()), Qt::QueuedConnection); +} + + +void Jrugr::doActiveWindowChanged () { + qDebug() << "doActiveWindowChanged"; + onActiveWindowChanged(X11Tools::activeWindow()); +} + + +void Jrugr::doActiveDesktopChanged () { + qDebug() << "doActiveDesktopChanged"; + onActiveWindowChanged(X11Tools::activeDesktop()); } @@ -371,6 +416,37 @@ void Jrugr::groupChange (int index) { qDebug() << "Jrugr::groupChange: index:" << index; mActiveGroup = index; buildIcon(); + // + if (mActiveWindow != None) { + QWIHash::iterator i = mKnownWindows.find(mActiveWindow); + // + if (i == mKnownWindows.end()) { + installFacehuggers(); + i = mKnownWindows.find(mActiveWindow); + } + // + if (i != mKnownWindows.end()) { + qDebug() << "fixing window layout"; + i.value().layout = index; + if (jCfg->switching == APP_LAYOUT) { + i = mKnownApps.find(X11Tools::appWindow(mActiveWindow)); + if (i != mKnownApps.end()) { + qDebug() << "fixing app layout"; + i.value().layout = index; + } else { + qDebug() << "***SHIT!***"; + } + } + } + } + // + int desk = X11Tools::activeDesktop(); + if (desk >= 0 && desk < mDeskLangs.size()) { + mDeskLangs[desk] = mActiveGroup; + } else if (desk >= 0) { + while (mDeskLangs.size() <= desk) mDeskLangs << 0; + mDeskLangs[desk] = mActiveGroup; + } } @@ -464,7 +540,8 @@ void Jrugr::reconfigure () { } // if (diffGI || newConf->layouts != jCfg->layouts || newConf->showFlag != jCfg->showFlag || - newConf->showSingle != jCfg->showSingle || newConf->status != jCfg->status) { + newConf->showSingle != jCfg->showSingle || newConf->status != jCfg->status || + newConf->switching != jCfg->switching) { delete jCfg; jCfg = newConf; init(); @@ -507,7 +584,9 @@ void Jrugr::configureXkb () { void Jrugr::onChangeLayout (int index) { qDebug() << "Jrugr::changeLayout:" << index; - for (int f = 5; f > 0; --f) mXkb->setActiveGroup(index); // k8: don't even ask me why this loop is here + //mActiveGroup = index; + mXkb->setActiveGroup(index); + //for (int f = 5; f > 0; --f) mXkb->setActiveGroup(index); // k8: don't even ask me why this loop is here } @@ -543,17 +622,25 @@ void Jrugr::actionsActivate (QAction *action) { void Jrugr::configure () { +/* if (!mCfgForm) { mCfgForm = new JrugrConfigForm(); - jCfg->lockKeys = true; connect(mCfgForm, SIGNAL(saveConfig()), SLOT(reconfigure())); } - mCfgForm->exec(); + //mCfgForm->exec(); + qDebug() << "***000"; + mCfgForm->open(); + qDebug() << "***001"; +*/ + mCfgForm = new JrugrConfigForm(); + connect(mCfgForm, SIGNAL(saveConfig()), SLOT(reconfigure())); + mCfgForm->open(); } #ifdef K8_MPLAYER_HACK static bool deactivateMPlayer (void) { + qDebug() << "onActiveWindowChanged"; Window aw = X11Tools::activeWindow(); bool changeFocus = false; // @@ -606,9 +693,11 @@ static bool deactivateMPlayer (void) { #endif -void Jrugr::activeWindowChanged (Window w) { +void Jrugr::onActiveWindowChanged (Window w) { + qDebug() << "onActiveWindowChanged"; if (w == None) { mDeskJustChanged = false; + mActiveWindow = None; qDebug() << "new active window: NONE"; return; } @@ -620,61 +709,110 @@ void Jrugr::activeWindowChanged (Window w) { qDebug() << "*** mDeskJustChanged ***"; mDeskJustChanged = false; #ifdef K8_MPLAYER_HACK - deactivateMPlayer(); + if (deactivateMPlayer()) return; #endif } + // + if (jCfg->status != DONT_USE_XKB) { + QWIHash::iterator i = mKnownWindows.find(w); + QWIHash::const_iterator p = mKnownWindows.find(mActiveWindow); + // + if (i != mKnownWindows.end()) { + switch (jCfg->switching) { + case APP_LAYOUT: + if (p == mKnownWindows.end() || p.value().appWindow != i.value().appWindow) { + qDebug("application changed!"); + i = mKnownApps.find(i.value().appWindow); + if (i != mKnownWindows.end()) { + qDebug("enforcing layout %d", i.value().layout); + if (i.value().layout != mActiveGroup) emit changeLayout(i.value().layout); + } + } + break; + case WIN_LAYOUT: + if (i.value().layout != mActiveGroup) { + qDebug("enforcing layout %d", i.value().layout); + if (i.value().layout != mActiveGroup) emit changeLayout(i.value().layout); + } + break; + } + } else { + // new window + //WinInfo wi; + // + qDebug() << "new window"; + installFacehuggers(); + /* + wi.w = w; + wi.appWindow = X11Tools::appWindow(wi.w); + wi.facehugger = makeFacehugger(wi.w); + wi.layout = mActiveGroup; + // + mKnownWindows[wi.w] = wi; + // + if (wi.appWindow == wi.w) { + if (!mKnownApps.contains(wi.appWindow)) { + qDebug() << " new application"; + mKnownApps[wi.appWindow] = wi; + } + } + */ + } + } + mActiveWindow = w; +} + + +void Jrugr::onClientListChanged () { + qDebug() << "onClientListChanged"; + installFacehuggers(); } -void Jrugr::activeDesktopChanged (int desk) { +void Jrugr::onActiveDesktopChanged (int desk) { + qDebug() << "onActiveDesktopChanged"; qDebug() << "new desktop:" << desk; mDeskJustChanged = true; #ifdef K8_MPLAYER_HACK if (deactivateMPlayer()) mDeskJustChanged = false; #endif + if (jCfg->status != DONT_USE_XKB && jCfg->switching == DESK_LAYOUT) { + if (mCurDesk != desk) { + if (desk >= 0 && desk < mDeskLangs.size()) { + if (mDeskLangs.at(desk) != mActiveGroup) { + qDebug("enforce layout %d for desktop %d", mDeskLangs.at(desk), desk); + emit changeLayout(mDeskLangs.at(desk)); + } + } else if (desk >= 0) { + while (mDeskLangs.size() <= desk) mDeskLangs << 0; + } + } + } + mCurDesk = desk; } bool Jrugr::x11EventFilter (XEvent *event) { - static Atom - atomActWin = None, - atomClientList = None, - atomCurDesk = None; // //qDebug() << "Jrugr::x11EventFilter:" << x11EventName(event); switch (event->type) { -/* - case FocusIn: - case FocusOut: - qDebug() << x11EventName(event) << (int)(event->xfocus.window) << - "class:" << X11Tools::windowClass(event->xfocus.window) << - "name:" << X11Tools::windowName(event->xfocus.window) << - "pid:" << X11Tools::windowPID(event->xfocus.window); - break; - case DestroyNotify: - qDebug() << x11EventName(event) << (int)(event->xdestroywindow.window) << - "class:" << X11Tools::windowClass(event->xdestroywindow.window) << - "name:" << X11Tools::windowName(event->xdestroywindow.window) << - "pid:" << X11Tools::windowPID(event->xdestroywindow.window); - break; -*/ case DestroyNotify: - if (event->type == DestroyNotify && event->xany.window == fhPWin) { - fhPWin = None; - fhWin = None; // facehugger is already dead - qDebug("**************************** FACEHUGGER PARENT DIES ****************************"); - } - if (event->type == DestroyNotify && event->xany.window == fhWin) { - qDebug("**************************** FACEHUGGER DIES ****************************"); + if (event->type == DestroyNotify && event->xdestroywindow.window != None) { + QWIHash::iterator i = mKnownWindows.find(event->xdestroywindow.window); + if (i != mKnownWindows.end()) { + qDebug("**************************** FACEHUGGER PARENT DIES ****************************"); + WinInfo wi = mKnownWindows.take(i.key()); + if (wi.appWindow == wi.w) { + qDebug("*** APPLICATION ***"); + mKnownApps.remove(wi.w); + } + } } break; case PropertyNotify: - if (atomActWin == None) atomActWin = XInternAtom(QX11Info::display(), "_NET_ACTIVE_WINDOW", True); - if (atomClientList == None) atomClientList = XInternAtom(QX11Info::display(), "_NET_CLIENT_LIST", True); - if (atomCurDesk == None) atomCurDesk = XInternAtom(QX11Info::display(), "_NET_CURRENT_DESKTOP", True); // - if (false && - event->xproperty.atom != atomActWin && +/* + if (event->xproperty.atom != atomActWin && event->xproperty.atom != atomClientList && event->xproperty.atom != atomCurDesk) { qDebug() << "PropertyNotify:" << (int)(event->xproperty.window) << @@ -684,13 +822,25 @@ bool Jrugr::x11EventFilter (XEvent *event) { "atom:" << X11Tools::atomName(event->xproperty.atom) << "action:" << (event->xproperty.state == PropertyNewValue ? "changed" : "deleted"); } +*/ // - if (event->xproperty.atom == atomActWin && event->xproperty.state == PropertyNewValue) { - activeWindowChanged(X11Tools::activeWindow()); + //return false; + if (atomActWin != None && event->xproperty.atom == atomActWin && event->xproperty.state == PropertyNewValue) { + //onActiveWindowChanged(X11Tools::activeWindow()); + qDebug() << "emit: activeWindowChanged"; + emit activeWindowChanged(); + } + if (atomCurDesk != None && event->xproperty.atom == atomCurDesk && event->xproperty.state == PropertyNewValue) { + //onActiveDesktopChanged(X11Tools::activeDesktop()); + qDebug() << "emit: activeDesktopChanged"; + emit activeDesktopChanged(); } - if (event->xproperty.atom == atomCurDesk && event->xproperty.state == PropertyNewValue) { - activeDesktopChanged(X11Tools::activeDesktop()); + if (atomClientList != None && event->xproperty.atom == atomClientList && event->xproperty.state == PropertyNewValue) { + //onClientListChanged(); + qDebug() << "emit: clientListChanged"; + emit clientListChanged(); } + //qDebug() << "PropertyNotify complete"; break; default: mXkb->processEvent(event); diff --git a/src/jrugr.h b/src/jrugr.h index 54b77e2..2264149 100644 --- a/src/jrugr.h +++ b/src/jrugr.h @@ -15,10 +15,14 @@ typedef struct { Window w; Window appWindow; - int groupId; // language for this window + Window facehugger; + int layout; // language for this window } WinInfo; +typedef QHash QWIHash; + + class Jrugr : public QApplication { Q_OBJECT @@ -32,6 +36,9 @@ public: signals: void changeLayout (int index); + void activeWindowChanged (); + void activeDesktopChanged (); + void clientListChanged (); public slots: void groupChange (int index); @@ -47,6 +54,10 @@ private slots: void actionsActivate (QAction *action); void onChangeLayout (int index); + void doActiveWindowChanged (); + void doActiveDesktopChanged (); + void onClientListChanged (); + protected: virtual bool x11EventFilter (XEvent *); @@ -60,8 +71,10 @@ private: void createMenu (); bool loadRules (); - void activeWindowChanged (Window w); - void activeDesktopChanged (int desk); + void onActiveWindowChanged (Window w); + void onActiveDesktopChanged (int desk); + + void installFacehuggers (); private: QAbstractEventDispatcher *mEDisp; @@ -77,10 +90,13 @@ private: JrugrCfg *jCfg; JrugrConfigForm *mCfgForm; // - QHash mKnownWindows; - QHash mKnownApps; + QWIHash mKnownWindows; + QWIHash mKnownApps; QList mDeskLangs; // + int mCurDesk; + Window mActiveWindow; + // bool mDeskJustChanged; }; diff --git a/src/jrugrconfui.cpp b/src/jrugrconfui.cpp index 110eddf..1dda8d1 100644 --- a/src/jrugrconfui.cpp +++ b/src/jrugrconfui.cpp @@ -5,6 +5,8 @@ JrugrConfigForm::JrugrConfigForm (QWidget *parent) : QDialog(parent) { + setAttribute(Qt::WA_DeleteOnClose); + // cfgUI.setupUi(this); // initialize the binding between list and stackedWidget cfgUI.listWidget->setCurrentRow(0); @@ -21,12 +23,24 @@ JrugrConfigForm::JrugrConfigForm (QWidget *parent) : QDialog(parent) { // mJCfg = X11Tools::loadXKBconf(); // + switch (mJCfg->switching) { + case GLOBAL_LAYOUT: cfgUI.rbPolicyGlobal->setChecked(true); break; + case APP_LAYOUT: cfgUI.rbPolicyApp->setChecked(true); break; + case WIN_LAYOUT: cfgUI.rbPolicyWin->setChecked(true); break; + case DESK_LAYOUT: cfgUI.rbPolicyDesk->setChecked(true); break; + } + // connect(cfgUI.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(cfgUI.buttonBox, SIGNAL(accepted()), SLOT(apply())); connect(cfgUI.rbUseXkb, SIGNAL(clicked(bool)), SLOT(statSelect(bool))); connect(cfgUI.rbIndicator, SIGNAL(clicked(bool)), SLOT(statSelect(bool))); connect(cfgUI.rbNoXkb, SIGNAL(clicked(bool)), SLOT(statSelect(bool))); // + connect(cfgUI.rbPolicyGlobal, SIGNAL(clicked(bool)), SLOT(statSwitching(bool))); + connect(cfgUI.rbPolicyApp, SIGNAL(clicked(bool)), SLOT(statSwitching(bool))); + connect(cfgUI.rbPolicyWin, SIGNAL(clicked(bool)), SLOT(statSwitching(bool))); + connect(cfgUI.rbPolicyDesk, SIGNAL(clicked(bool)), SLOT(statSwitching(bool))); + // cfgUI.btnAdd->setEnabled(false); cfgUI.btnAdd->setIcon(QIcon::fromTheme(QString("arrow-right"), QIcon(mTheme+"/add.png"))); // @@ -41,7 +55,6 @@ JrugrConfigForm::JrugrConfigForm (QWidget *parent) : QDialog(parent) { // if (!setStat()) return; initXKBTab(); - mJCfg->lockKeys = true; } @@ -109,14 +122,7 @@ void JrugrConfigForm::initXKBTab () { cfgUI.xkbOptionsTreeView->header()->hide(); cfgUI.xkbOptionsTreeView->expandAll(); // - switch (mJCfg->switching) { - case GLOBAL_LAYOUT: cfgUI.rbPolicyGlobal->setChecked(true); break; - case APP_LAYOUT: cfgUI.rbPolicyApp->setChecked(true); break; - case WIN_LAYOUT: cfgUI.rbPolicyWin->setChecked(true); break; - case DESK_LAYOUT: cfgUI.rbPolicyDesk->setChecked(true); break; - } - // - connect(cfgUI.srcTableView, SIGNAL(clicked (const QModelIndex &)), SLOT(srcClick(QModelIndex))); + connect(cfgUI.srcTableView, SIGNAL(clicked(const QModelIndex &)), SLOT(srcClick(QModelIndex))); connect(cfgUI.dstTableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), SLOT(dstClick())); connect(cfgUI.comboModel, SIGNAL(currentIndexChanged (int)) , SLOT(comboModelCh(int))); connect(cfgUI.comboVariant, SIGNAL(currentIndexChanged (int)), SLOT(comboVariantCh(int))); @@ -344,18 +350,30 @@ void JrugrConfigForm::xkbOptionsChanged (const QModelIndex &topLeft, const QMode void JrugrConfigForm::closeEvent (QCloseEvent *event) { - mJCfg->lockKeys = false; +/* hide(); event->ignore(); +*/ } -void JrugrConfigForm::statSwitching (bool /*checked*/) { +void JrugrConfigForm::statSwitching (bool checked) { //Q_UNUSED(checked) + qDebug() << "statSwitching"; + if (checked) { + QRadioButton *radio = qobject_cast(QObject::sender()); + if (radio == cfgUI.rbPolicyGlobal) mJCfg->switching = GLOBAL_LAYOUT; + if (radio == cfgUI.rbPolicyApp) mJCfg->switching = APP_LAYOUT; + if (radio == cfgUI.rbPolicyWin) mJCfg->switching = WIN_LAYOUT; + if (radio == cfgUI.rbPolicyDesk) mJCfg->switching = DESK_LAYOUT; + qDebug(" %d", mJCfg->switching); + } + /* if (cfgUI.rbPolicyGlobal->isChecked()) mJCfg->switching = GLOBAL_LAYOUT; if (cfgUI.rbPolicyApp->isChecked()) mJCfg->switching = APP_LAYOUT; if (cfgUI.rbPolicyWin->isChecked()) mJCfg->switching = WIN_LAYOUT; if (cfgUI.rbPolicyDesk->isChecked()) mJCfg->switching = DESK_LAYOUT; + */ } diff --git a/src/x11tools.cpp b/src/x11tools.cpp index 9998c6c..8c1c0dc 100644 --- a/src/x11tools.cpp +++ b/src/x11tools.cpp @@ -354,7 +354,6 @@ JrugrCfg *X11Tools::loadXKBconf () { Conf->showSingle = jrugr.value("showsingle").toBool(); Conf->switching = jrugr.value("switching").toInt(); Conf->useSU = jrugr.value("useSU", true).toBool(); - Conf->lockKeys = false; jrugr.endGroup(); return Conf; } @@ -715,6 +714,16 @@ QStringList X11Tools::windowStateNames (Window w) { } +Window X11Tools::appWindow (Window w) { + if (w == None) return None; + for (;;) { + Window p = windowTransientFor(w); + if (p == None) return w; + w = p; + } +} + + //////////////////////////////////////////////////////////////////////////////// /** * @brief Gets the single layout part of a layout(variant) string diff --git a/src/x11tools.h b/src/x11tools.h index 95ffb6d..fe9adf4 100644 --- a/src/x11tools.h +++ b/src/x11tools.h @@ -72,7 +72,6 @@ struct JrugrCfg { int switching; bool showFlag; bool showSingle; - bool lockKeys; bool useSU; }; @@ -141,6 +140,8 @@ public: static QX11WindowList topLevelWindows (); static QX11WindowList topLevelWindowStack (); + static Window appWindow (Window w); + static QRect trayPosition (); static QX11AtomList windowState (Window w); diff --git a/src/xkeyboard.cpp b/src/xkeyboard.cpp index 8728823..d607129 100644 --- a/src/xkeyboard.cpp +++ b/src/xkeyboard.cpp @@ -199,14 +199,14 @@ void XKeyboard::groupInfo (QXkbLayoutList &list) { void XKeyboard::processEvent (XEvent *ev) { // XKB event? if (ev->type == mEventCode) { - XkbEvent *xkb_ev = (XkbEvent *)ev; + XkbEvent *xkbEv = (XkbEvent *)ev; // - if (xkb_ev->any.xkb_type == XkbStateNotify) { + if (xkbEv->any.xkb_type == XkbStateNotify) { // state notify event, the current group has changed - emit groupChanged(xkb_ev->state.group); - } else if ((xkb_ev->any.xkb_type == XkbMapNotify && xkb_ev->map.changed & XkbKeySymsMask) || - (xkb_ev->any.xkb_type == XkbNamesNotify && xkb_ev->names.changed & XkbGroupNamesMask) || - (xkb_ev->any.xkb_type == XkbNewKeyboardNotify)) { + emit groupChanged(xkbEv->state.group); + } else if ((xkbEv->any.xkb_type == XkbMapNotify && (xkbEv->map.changed & XkbKeySymsMask)) || + (xkbEv->any.xkb_type == XkbNamesNotify && (xkbEv->names.changed & XkbGroupNamesMask)) || + (xkbEv->any.xkb_type == XkbNewKeyboardNotify)) { // keyboard layout has changed emit layoutChanged(); } -- 2.11.4.GIT