Don't hardcode fps for fake screen

Currently, when main hardware screen is powered-off,
X server initializes fake screen's timer with
1 second update interval.

Streaming software like Nomachine or Vnc, as well as
desktop input automation suffers from it, since it
will forever be stuck on 1 fps until the display is
turned back on.

This commit adds command line option -fakescreenfps <int>
that allows the user to change the default fake screen
timer.

Signed-off-by: Baranin Alexander <ismailsiege@gmail.com>
This commit is contained in:
Boris-Barboris 2021-06-22 00:51:08 +03:00 committed by Povilas Kanapickas
parent 8836b9d243
commit 16571b8926
4 changed files with 35 additions and 10 deletions

View File

@ -164,6 +164,9 @@ a list of accepted extension names is printed.
.B \-f \fIvolume\fP
sets beep (bell) volume (allowable range: 0-100).
.TP 8
.B \-fakescreenfps \fFps\fP
sets fake presenter screen default fps (allowable range: 1-600).
.TP 8
.B \-fp \fIfontPath\fP
sets the search path for fonts. This path is a comma separated list
of directories which the X server searches for font databases.

View File

@ -112,6 +112,8 @@ __stdcall unsigned long GetTickCount(void);
#include "miinitext.h"
#include "present.h"
Bool noTestExtensions;
#ifdef COMPOSITE
@ -534,6 +536,7 @@ UseMsg(void)
ErrorF
("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
ErrorF("-f # bell base (0-100)\n");
ErrorF("-fakescreenfps # fake screen default fps (1-600)\n");
ErrorF("-fp string default font path\n");
ErrorF("-help prints message with these options\n");
ErrorF("+iglx Allow creating indirect GLX contexts\n");
@ -781,6 +784,15 @@ ProcessCommandLine(int argc, char *argv[])
else
UseMsg();
}
else if (strcmp(argv[i], "-fakescreenfps") == 0) {
if (++i < argc) {
FakeScreenFps = (uint32_t) atoi(argv[i]);
if (FakeScreenFps < 1 || FakeScreenFps > 600)
FatalError("fakescreenfps must be an integer in [1;600] range\n");
}
else
UseMsg();
}
else if (strcmp(argv[i], "-fp") == 0) {
if (++i < argc) {
defaultFontPath = argv[i];

View File

@ -162,4 +162,6 @@ present_register_complete_notify(present_complete_notify_proc proc);
extern _X_EXPORT Bool
present_can_window_flip(WindowPtr window);
extern _X_EXPORT uint32_t FakeScreenFps;
#endif /* _PRESENT_H_ */

View File

@ -113,21 +113,29 @@ present_fake_queue_vblank(ScreenPtr screen,
return Success;
}
uint32_t FakeScreenFps = 0;
void
present_fake_screen_init(ScreenPtr screen)
{
uint32_t fake_fps;
present_screen_priv_ptr screen_priv = present_screen_priv(screen);
/* For screens with hardware vblank support, the fake code
* will be used for off-screen windows and while screens are blanked,
* in which case we want a slow interval here
*
* Otherwise, pretend that the screen runs at 60Hz
*/
if (screen_priv->info && screen_priv->info->get_crtc)
screen_priv->fake_interval = 1000000;
else
screen_priv->fake_interval = 16667;
if (FakeScreenFps)
fake_fps = FakeScreenFps;
else {
/* For screens with hardware vblank support, the fake code
* will be used for off-screen windows and while screens are blanked,
* in which case we want a large interval here: 1Hz
*
* Otherwise, pretend that the screen runs at 60Hz
*/
if (screen_priv->info && screen_priv->info->get_crtc)
fake_fps = 1;
else
fake_fps = 60;
}
screen_priv->fake_interval = 1000000 / fake_fps;
}
void