Re: [Lazarus] "Defeating" a screen saver

2012-09-28 Thread Mark Morgan Lloyd

zeljko wrote:

Health warning:
http://lists.lazarus.freepascal.org/pipermail/lazarus/2008-August/037407.ht
ml suggests following a handle in TForm to arrive at a window ID, but that
appears to depend on the combination of widget set and window manager: as
a particular example, it's unreliable with gtk2 on top of KDE.

Without delving into the raw X API, the only reliable way of doing this
appears to be to run xwininfo and parse the output. The window ID from
that is compatible with xdg-screensaver.


What's problem with gtk2 and KDE ? You already have helper functions for X11 
in gtk2widgetset.inc, so there you can see howto get XWindow handle and do 
whatever with it with direct calls.


Go on then: how do I temporarily defeat the screensaver?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-28 Thread Paul Breneman

Mark Morgan Lloyd wrote:

Mark Morgan Lloyd wrote:

Mark Morgan Lloyd wrote:

Graeme Geldenhuys wrote:

On 2012-09-25 17:57, Mark Morgan Lloyd wrote:
suggestion of looking at the VLC sources I see they use it which 
has to

be a recommendation.


Interesting... I was wondering what they did. :)



I'll see what I can work in, but particularly allowing that
xdg-screensaver can take several seconds to run it's more suited to
being run at the start and end of a program session than "on the fly"


Needs a window ID. I think I can get that from a shell variable if 
there's a shell, but not if started directly from the desktop: anybody 
got any thoughts?


Health warning: 
http://lists.lazarus.freepascal.org/pipermail/lazarus/2008-August/037407.html 
suggests following a handle in TForm to arrive at a window ID, but that 
appears to depend on the combination of widget set and window manager: 
as a particular example, it's unreliable with gtk2 on top of KDE.


Without delving into the raw X API, the only reliable way of doing this 
appears to be to run xwininfo and parse the output. The window ID from 
that is compatible with xdg-screensaver.




Just a little warning that seems related to this topic...

In my Delphi communication programs I used PostMessage *very* much.  I 
used to pass the main form's handle down into my threads so they could 
post to that handle.  But a form's handle is not guaranteed to remain 
the same.  Therefore I now pass a TForm reference down so the handle can 
be obtained when needed.


A month ago some of my code that still passed just the handle failed 
under Win7.  Seems that Win7 was doing something to an *invisible* form 
and changing the form's handle so my messages went nowhere.  Passing the 
TForm reference fixed the bug.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-28 Thread zeljko

> Health warning:
> http://lists.lazarus.freepascal.org/pipermail/lazarus/2008-August/037407.ht
> ml suggests following a handle in TForm to arrive at a window ID, but that
> appears to depend on the combination of widget set and window manager: as
> a particular example, it's unreliable with gtk2 on top of KDE.
> 
> Without delving into the raw X API, the only reliable way of doing this
> appears to be to run xwininfo and parse the output. The window ID from
> that is compatible with xdg-screensaver.

What's problem with gtk2 and KDE ? You already have helper functions for X11 
in gtk2widgetset.inc, so there you can see howto get XWindow handle and do 
whatever with it with direct calls.

zeljko

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-28 Thread Mark Morgan Lloyd

Mark Morgan Lloyd wrote:

Mark Morgan Lloyd wrote:

Graeme Geldenhuys wrote:

On 2012-09-25 17:57, Mark Morgan Lloyd wrote:

suggestion of looking at the VLC sources I see they use it which has to
be a recommendation.


Interesting... I was wondering what they did. :)



I'll see what I can work in, but particularly allowing that
xdg-screensaver can take several seconds to run it's more suited to
being run at the start and end of a program session than "on the fly"


Needs a window ID. I think I can get that from a shell variable if 
there's a shell, but not if started directly from the desktop: anybody 
got any thoughts?


Health warning: 
http://lists.lazarus.freepascal.org/pipermail/lazarus/2008-August/037407.html 
suggests following a handle in TForm to arrive at a window ID, but that 
appears to depend on the combination of widget set and window manager: 
as a particular example, it's unreliable with gtk2 on top of KDE.


Without delving into the raw X API, the only reliable way of doing this 
appears to be to run xwininfo and parse the output. The window ID from 
that is compatible with xdg-screensaver.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-26 Thread Mark Morgan Lloyd

Mark Morgan Lloyd wrote:

Graeme Geldenhuys wrote:

On 2012-09-25 17:57, Mark Morgan Lloyd wrote:

suggestion of looking at the VLC sources I see they use it which has to
be a recommendation.


Interesting... I was wondering what they did. :)



I'll see what I can work in, but particularly allowing that
xdg-screensaver can take several seconds to run it's more suited to
being run at the start and end of a program session than "on the fly"


Why not simply execute the command in a background thread. Your main 
thread then continues pulling in data or whatever it does.


I've already got a thread moving data around, and I know that when 
data's actively moving that the user isn't fiddling with keyboard or 
mouse (odds are he's got his hands on a MIDI device). I can also assume 
that he used the GUI shortly before data started arriving, so in 
practice I can use a 30 secs foreground timer (which already looks for 
and loads an updated backend .so) to fire an enable/disable command when 
the rate of flow changes.


Needs a window ID. I think I can get that from a shell variable if 
there's a shell, but not if started directly from the desktop: anybody 
got any thoughts?


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Mark Morgan Lloyd

Graeme Geldenhuys wrote:

On 2012-09-25 17:57, Mark Morgan Lloyd wrote:

suggestion of looking at the VLC sources I see they use it which has to
be a recommendation.


Interesting... I was wondering what they did. :)



I'll see what I can work in, but particularly allowing that
xdg-screensaver can take several seconds to run it's more suited to
being run at the start and end of a program session than "on the fly"


Why not simply execute the command in a background thread. Your main 
thread then continues pulling in data or whatever it does.


I've already got a thread moving data around, and I know that when 
data's actively moving that the user isn't fiddling with keyboard or 
mouse (odds are he's got his hands on a MIDI device). I can also assume 
that he used the GUI shortly before data started arriving, so in 
practice I can use a 30 secs foreground timer (which already looks for 
and loads an updated backend .so) to fire an enable/disable command when 
the rate of flow changes.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Graeme Geldenhuys

On 2012-09-25 17:57, Mark Morgan Lloyd wrote:

suggestion of looking at the VLC sources I see they use it which has to
be a recommendation.


Interesting... I was wondering what they did. :)



I'll see what I can work in, but particularly allowing that
xdg-screensaver can take several seconds to run it's more suited to
being run at the start and end of a program session than "on the fly"


Why not simply execute the command in a background thread. Your main 
thread then continues pulling in data or whatever it does.



Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Mark Morgan Lloyd

Henry Vermaak wrote:

On 25/09/12 11:01, Mark Morgan Lloyd wrote:

I appreciate that there might be no guaranteed portable answer to this
one, and FWIW I'm primarily interested in the Linux+X+KDE combination.

If a program knows that something's going on that it might later need to
tell the user about, e.g. that there's serial comms going on in the
background even if the GUI's not being updated, is it possible to do
anything that the LCL and lower levels will interpret similarly to
keyboard and mouse activity in order to prevent a screen saver from
kicking in?


xdg-screensaver is a script that you can use to control the screensaver
(seems to support all the ones I know).  It's in the xdg-utils package
on my system.  I don't know of a nicer way to do this and cover all the
bases, except to use dbus with org.freedesktop.ScreenSaver, most desktop
environments should work with that, I think.


I try to use the xdg utilities when I can, and pursuing Graeme's 
suggestion of looking at the VLC sources I see they use it which has to 
be a recommendation.


I'll see what I can work in, but particularly allowing that 
xdg-screensaver can take several seconds to run it's more suited to 
being run at the start and end of a program session than "on the fly" 
when data is seen coming through. The only alternative I can see is 
doing something at the kernel level to push a keyboard or mouse event 
through to X.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Mark Morgan Lloyd

Graeme Geldenhuys wrote:

On 2012-09-25 11:55, Mark Morgan Lloyd wrote:

stringgrid with an updating field on the screen, I've not yet tried e.g.
simulating a shiftkey event.


Another option.  From the 'man xscreensaver-command' output.

-
  -deactivate
This tells xscreensaver to pretend that there has just been user 
activity.  This means that if the  screensaver is  active  (the  screen 
 is blanked), then this command will cause the screen to un-blank as if 
there had been keyboard or mouse activity.  If the screen is locked, 
then the password dialog will pop up first, as usual.  If the  screen 
is  not  blanked,  then  this simulated user activity will re-start the 
countdown (so, issuing the -deactivate command periodically is one way 
to prevent the screen from blanking.)

-

But then I don't know if this applies to kde-screensaver and 
gnome-screensaver too, even though they are forks of xscreensaver.


Thanks for that, interesting. I've certainly had problems getting 
screensaver+powerdown to work properly in the past, which I tracked down 
to different configuration requirements for the X and KDE 
implementations (specifically, IIRC, the X server had to be told not to 
do various things to give KDE a chance).


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Graeme Geldenhuys

On 2012-09-25 11:55, Henry Vermaak wrote:


xdg-screensaver is a script that you can use to control the screensaver
(seems to support all the ones I know).


Cool, I didn't know about that one. At least I can confirm that OpenSUSE 
12.2 does have xdg-screensaver functionality.



Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Graeme Geldenhuys

On 2012-09-25 11:55, Mark Morgan Lloyd wrote:

stringgrid with an updating field on the screen, I've not yet tried e.g.
simulating a shiftkey event.


Another option.  From the 'man xscreensaver-command' output.

-
  -deactivate
This tells xscreensaver to pretend that there has just been user 
activity.  This means that if the  screensaver is  active  (the  screen 
 is blanked), then this command will cause the screen to un-blank as if 
there had been keyboard or mouse activity.  If the screen is locked, 
then the password dialog will pop up first, as usual.  If the  screen 
is  not  blanked,  then  this simulated user activity will re-start the 
countdown (so, issuing the -deactivate command periodically is one way 
to prevent the screen from blanking.)

-

But then I don't know if this applies to kde-screensaver and 
gnome-screensaver too, even though they are forks of xscreensaver.


Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Henry Vermaak
On 25/09/12 11:01, Mark Morgan Lloyd wrote:
> I appreciate that there might be no guaranteed portable answer to this
> one, and FWIW I'm primarily interested in the Linux+X+KDE combination.
> 
> If a program knows that something's going on that it might later need to
> tell the user about, e.g. that there's serial comms going on in the
> background even if the GUI's not being updated, is it possible to do
> anything that the LCL and lower levels will interpret similarly to
> keyboard and mouse activity in order to prevent a screen saver from
> kicking in?

xdg-screensaver is a script that you can use to control the screensaver
(seems to support all the ones I know).  It's in the xdg-utils package
on my system.  I don't know of a nicer way to do this and cover all the
bases, except to use dbus with org.freedesktop.ScreenSaver, most desktop
environments should work with that, I think.

Henry

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Mark Morgan Lloyd

Graeme Geldenhuys wrote:

On 2012-09-25 11:01, Mark Morgan Lloyd wrote:

interpret similarly to keyboard and mouse activity in order to prevent a
screen saver from kicking in?


Maybe download the VLC Player source code, and see what they do to 
disable the screensaver while a video is playing. I know VLC works well 
in that context. I don't know of other X11 applications that temporarily 
disable the screensaver while working, but I am sure there must be some.


Thanks, that's a good idea. I've already tried making sure there's a 
stringgrid with an updating field on the screen, I've not yet tried e.g. 
simulating a shiftkey event.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] "Defeating" a screen saver

2012-09-25 Thread Graeme Geldenhuys

On 2012-09-25 11:01, Mark Morgan Lloyd wrote:

interpret similarly to keyboard and mouse activity in order to prevent a
screen saver from kicking in?


Maybe download the VLC Player source code, and see what they do to 
disable the screensaver while a video is playing. I know VLC works well 
in that context. I don't know of other X11 applications that temporarily 
disable the screensaver while working, but I am sure there must be some.


Sorry I can't be or more help.

Regards,
  - Graeme -


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus