Interface steals focus when finished saving

Everything related to MakeMKV
Post Reply
fawtytoo
Posts: 5
Joined: Thu Nov 25, 2021 3:24 pm

Interface steals focus when finished saving

Post by fawtytoo »

I use MakeMKV on Linux. I have no issues with the software's functionality per se, but the interface does have an annoying "feature".

When it's finished saving titles, it shows a popup, a panel notification, and steals focus. The biggest problem is that it steals focus. If I'm using another program on another workspace, it will not only appear above the other program (potentially ruining other work I'm doing) but will also switch to that workspace.

Is it possible to address this?
Woodstock
Posts: 10327
Joined: Sun Jul 24, 2011 11:21 pm

Re: Interface steals focus when finished saving

Post by Woodstock »

Can you disable notifications for MakeMKV?
fawtytoo
Posts: 5
Joined: Thu Nov 25, 2021 3:24 pm

Re: Interface steals focus when finished saving

Post by fawtytoo »

I know of no way to disable the notification. I found out how to add MakeMKV to Gnome's list so I could turn them off, but I guess the way MakeMKV invokes them ignores that setting.

Stealing focus is the main concern really. This may be a window manager issue, but there is no way to change this in Gnome. Perhaps to disable the popup in MakeMKV might do it.
Reiver
Posts: 23
Joined: Wed Jul 26, 2017 8:45 am

Re: Interface steals focus when finished saving

Post by Reiver »

If you're building MakeMKV on Gentoo then I wrote the following patch which you can plonk (after fixing any forum white space mangling) in /etc/portage/patches/media-video/makemkv/makemkv-disable-notification.patch (still applies to current 1.16.5 version) as I found the notifications quite annoying too.

Code: Select all

diff -ur makemkv-oss-1.15.3/makemkvgui/src/notify_linux.cpp makemkv-oss-1.15.3-disablenotification/makemkvgui/src/notify_linux.cpp
--- makemkv-oss-1.15.3/makemkvgui/src/notify_linux.cpp	2020-10-01 14:59:25.000000000 +0100
+++ makemkv-oss-1.15.3-disablenotification/makemkvgui/src/notify_linux.cpp	2020-10-06 21:49:36.241610149 +0100
@@ -14,40 +14,10 @@
 */
 #include "qtapp.h"
 #include "notify.h"
-#include <QtDBus/QDBusInterface>
 #include <lgpl/sysabi.h>

-static QDBusInterface*  notifyInterface = NULL;
-
 void notifyInit()
 {
-    QDBusMessage msgServerInformation;
-
-    notifyInterface = new QDBusInterface(
-        QLatin1String("org.freedesktop.Notifications"),
-        QLatin1String("/org/freedesktop/Notifications"),
-        QLatin1String("org.freedesktop.Notifications")
-        );
-
-    if (!notifyInterface->isValid())
-    {
-        notifyCleanup();
-        return;
-    }
-
-    msgServerInformation = notifyInterface->call(QDBus::Block,QLatin1String("GetServerInformation"));
-
-    if (msgServerInformation.type()!=QDBusMessage::ReplyMessage)
-    {
-        notifyCleanup();
-        return;
-    }
-
-    if (msgServerInformation.arguments().size()<3)
-    {
-        notifyCleanup();
-        return;
-    }
 }

 void notifyStart(QMainWindow* mainWindow,unsigned long Id,const QString &Name)
@@ -64,27 +34,10 @@

 void notifyEvent(QMainWindow* mainWindow,unsigned long Id,const char* IdName,const QString &Text,const QString &Name)
 {
-    if (notifyInterface)
-    {
-        notifyInterface->call(
-            QDBus::BlockWithGui,
-            QLatin1String("Notify"),
-            QLatin1String("makemkv"),
-            QVariant((uint)0),
-            QLatin1String(""),
-            Name,
-            Text,
-            QStringList(),
-            QMap<QString, QVariant>(),
-            QVariant((int)3)
-            );
-    }
 }

 void notifyCleanup()
 {
-    delete notifyInterface;
-    notifyInterface = NULL;
 }

 void desktopShowFile(const QString &FileName)
fawtytoo
Posts: 5
Joined: Thu Nov 25, 2021 3:24 pm

Re: Interface steals focus when finished saving

Post by fawtytoo »

I'm on Debian, but that's ok. I'm a developer myself, so I'm ok modifying code.

Many thanks for that.
fawtytoo
Posts: 5
Joined: Thu Nov 25, 2021 3:24 pm

Re: Interface steals focus when finished saving

Post by fawtytoo »

Ok, that gets rid of the notification. Great! But what about the focus stealing?

I'm more of a GTK developer than Qt, and I can't make out where the popup dialog is invoked when ripping is completed.

Any ideas?
fawtytoo
Posts: 5
Joined: Thu Nov 25, 2021 3:24 pm

Re: Interface steals focus when finished saving

Post by fawtytoo »

Interestingly, this appears to be a Qt issue/problem/bug/whatever rather than anything with MakeMKV.

The popup in question is a QMessageBox. As standard, it steals focus with, apparently, no way to change this.

My solution, albeit dirty, is to prevent all "OK" message boxes from showing.

makemkvgui/src/mainwnd.cpp

In function MainWnd::ReportUiMessage, comment out or remove:

Code: Select all

( (Flags&AP_UIMSG_BOX_MASK) == AP_UIMSG_BOXOK ) ||
The result is no more popup and no more focus stealing and no more MakeMKV moving workspaces and upsetting other work I was doing elsewhere.

Of course, as there's no way of knowing when it's completed its jobs (apart from the drive spinning down), I'm going to leave the notification code as is.

There may be a better way to do this. But for now ...
Reiver
Posts: 23
Joined: Wed Jul 26, 2017 8:45 am

Re: Interface steals focus when finished saving

Post by Reiver »

It probably depends on your window manager settings. With my patch, the OK window doesn't steal focus on Enlightenment with focus follows mouse.
Post Reply