We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4703

Summary: linux: Don't simulate activity when not needed
Product: SDL Reporter: Bastien Nocera <bugzilla>
Component: mainAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: 0001-linux-Don-t-simulate-activity-when-not-needed.patch

Description Bastien Nocera 2019-07-02 09:24:42 UTC
Created attachment 3853 [details]
0001-linux-Don-t-simulate-activity-when-not-needed.patch

There's no need to simulate activity when we already hold a cookie for
an ongoing inhibition, best thing it can do is wake up the screensaver
proxy for it to return a missing method error on anything newer than
a GNOME 2 clone.
Comment 1 Ryan C. Gordon 2019-07-02 14:10:56 UTC
Something like this patch is now https://hg.libsdl.org/SDL/rev/5959fcbe6dfe, thanks!

--ryan.
Comment 2 Bastien Nocera 2019-07-02 15:17:29 UTC
This function doesn't exist, why try to call it?

    1.13 +        SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID);
Comment 3 Ryan C. Gordon 2019-07-02 15:42:03 UTC
(In reply to Bastien Nocera from comment #2)
> This function doesn't exist, why try to call it?
> 
>     1.13 +        SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver",
> "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver",
> "SimulateUserActivity", DBUS_TYPE_INVALID);

It exists here, with Gnome in Ubuntu 16.04:

[icculus@taise ~]$ qdbus org.freedesktop.ScreenSaver /org/freedesktop/ScreenSaver |grep Simulate
method void org.freedesktop.ScreenSaver.SimulateUserActivity()

But specifically, this is the interface KDE prefers, apparently.

--ryan.
Comment 4 Bastien Nocera 2019-07-04 12:15:08 UTC
(In reply to Ryan C. Gordon from comment #3)
> (In reply to Bastien Nocera from comment #2)
> > This function doesn't exist, why try to call it?
> > 
> >     1.13 +        SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver",
> > "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver",
> > "SimulateUserActivity", DBUS_TYPE_INVALID);
> 
> It exists here, with Gnome in Ubuntu 16.04:
> 
> [icculus@taise ~]$ qdbus org.freedesktop.ScreenSaver
> /org/freedesktop/ScreenSaver |grep Simulate
> method void org.freedesktop.ScreenSaver.SimulateUserActivity()
> 
> But specifically, this is the interface KDE prefers, apparently.

This is a bug/regression in KDE. The interface below was based on an implementation that was already done in KDE, and for which I wrote the GNOME implementation:
https://specifications.freedesktop.org/idle-inhibit-spec/latest/re01.html
Comment 5 Bastien Nocera 2019-07-10 11:30:20 UTC
(In reply to Bastien Nocera from comment #4)
> (In reply to Ryan C. Gordon from comment #3)
> > (In reply to Bastien Nocera from comment #2)
> > > This function doesn't exist, why try to call it?
> > > 
> > >     1.13 +        SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver",
> > > "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver",
> > > "SimulateUserActivity", DBUS_TYPE_INVALID);
> > 
> > It exists here, with Gnome in Ubuntu 16.04:
> > 
> > [icculus@taise ~]$ qdbus org.freedesktop.ScreenSaver
> > /org/freedesktop/ScreenSaver |grep Simulate
> > method void org.freedesktop.ScreenSaver.SimulateUserActivity()
> > 
> > But specifically, this is the interface KDE prefers, apparently.

That doesn't seem to be the case. kscreenlocker is the "locker" used in Plasma, and it's supported the Inhibit interface for a number of years. The Inhibit interface is better than making "poke" D-Bus calls in the mainloop.

This is the kscreenlocker D-Bus interface:
https://github.com/KDE/kscreenlocker/blob/5824f086faa68a4b38930b180b33a8f95d0b6739/dbus/org.freedesktop.ScreenSaver.xml#L24

which looks like it's implemented here:
https://github.com/KDE/kscreenlocker/blob/master/interface.cpp#L122

It relies on powerdevil being installed, but that's a core component of the desktop.