From 8cad518738339efbdc3594b83d6949b695f1c083 Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 21 Jan 2014 17:44:17 +0200 Subject: [PATCH] 'mplayer hack' now works with mpv --- jrugr.pro | 2 +- src/jrugr.cpp | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/jrugr.pro b/jrugr.pro index 4f2d0a7..7455447 100644 --- a/jrugr.pro +++ b/jrugr.pro @@ -35,7 +35,7 @@ RCC_DIR = _build/rcc //DEFINES = QT_NO_DEBUG_OUTPUT LIBS += -lxkbfile -lX11 -DEFINES += JRUGR_VERSION=\\\"0.4.6\\\" +DEFINES += JRUGR_VERSION=\\\"0.4.7\\\" include(src/main.pri) diff --git a/src/jrugr.cpp b/src/jrugr.cpp index 8758be4..b922814 100644 --- a/src/jrugr.cpp +++ b/src/jrugr.cpp @@ -12,6 +12,21 @@ static Atom //////////////////////////////////////////////////////////////////////////////// +static inline bool isMPlayer (const QString &name) { + return ( + name.startsWith("mplayer", Qt::CaseInsensitive) || + name.startsWith("mplayer2", Qt::CaseInsensitive) || + name.startsWith("mpv", Qt::CaseInsensitive) + ); +} + + +static inline bool isMPlayerClass (const QString &name) { + return (name == "xv" || name == "gl"); +} + + +//////////////////////////////////////////////////////////////////////////////// static bool makeFacehugger (Window w) { //WARNING! this WILL NOT work as expected on our own windows! return XSelectInput(QX11Info::display(), w, /*SubstructureNotifyMask |*/ StructureNotifyMask) == Success; @@ -562,9 +577,9 @@ void Jrugr::actionsActivate (QAction *action) { #ifdef K8_MPLAYER_HACK static bool isMPlayer (Window w) { if (w != None) { - if (X11Tools::windowDesktop(w) == -1 && X11Tools::windowClass(w) == "xv") { + if (X11Tools::windowDesktop(w) == -1 && isMPlayerClass(X11Tools::windowClass(w))) { QString name = X11Tools::windowName(w).toLower(); - if (name == "mplayer" || name == "mplayer2") return true; + if (isMPlayer(name)) return true; } } return false; @@ -591,9 +606,9 @@ static QX11WindowList getPossibleActives (Window mpw) { sl.indexOf("_NET_WM_STATE_ABOVE") < 0 && sl.indexOf("_NET_WM_STATE_BELOW") < 0) { QString cls(X11Tools::windowClass(w)); - if (cls == "xv") { + if (isMPlayerClass(cls)) { QString name(X11Tools::windowName(w).toLower()); - if (name == "mplayer" || name == "mplayer2") continue; + if (isMPlayer(name)) continue; } if (wine == None && cls == "explorer.exe") { wine = w; @@ -623,9 +638,9 @@ bool Jrugr::deactivateMPlayer () { bool changeFocus = false; // if (aw != None) { - if (X11Tools::windowDesktop(aw) == -1 && X11Tools::windowClass(aw) == "xv") { + if (X11Tools::windowDesktop(aw) == -1 && isMPlayerClass(X11Tools::windowClass(aw))) { QString name = X11Tools::windowName(aw).toLower(); - if (name == "mplayer" || name == "mplayer2") { + if (isMPlayer(name)) { qDebug() << "MPlayer hack!"; changeFocus = true; } -- 2.11.4.GIT