Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
69fe5632
Commit
69fe5632
authored
Oct 17, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xdg-screensaver plugin
parent
198f8954
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
0 deletions
+113
-0
configure.ac
configure.ac
+1
-0
modules/misc/Modules.am
modules/misc/Modules.am
+1
-0
modules/misc/xdg-screensaver.c
modules/misc/xdg-screensaver.c
+111
-0
No files found.
configure.ac
View file @
69fe5632
...
...
@@ -3671,6 +3671,7 @@ AS_IF([test "${enable_xcb}" != "no"], [
VLC_ADD_PLUGIN([globalhotkeys])
VLC_ADD_CFLAGS([globalhotkeys],[${XCB_KEYSYMS_CFLAGS} ${XCB_CFLAGS}] )
VLC_ADD_LIBS([globalhotkeys],[${XCB_KEYSYMS_LIBS} ${XCB_LIBS}] )
VLC_ADD_PLUGIN([xdg_screensaver])
])
...
...
modules/misc/Modules.am
View file @
69fe5632
...
...
@@ -19,6 +19,7 @@ SOURCES_gnutls = gnutls.c dhparams.h
SOURCES_svg = svg.c
SOURCES_audioscrobbler = audioscrobbler.c
SOURCES_inhibit = inhibit.c
SOURCES_xdg_screensaver = xdg-screensaver.c
libvlc_LTLIBRARIES += \
liblogger_plugin.la
...
...
modules/misc/xdg-screensaver.c
0 → 100644
View file @
69fe5632
/*****************************************************************************
* xdg-screensaver.c
*****************************************************************************
* Copyright (C) 2008 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_inhibit.h>
#include <spawn.h>
#include <sys/wait.h>
static
int
Open
(
vlc_object_t
*
);
static
void
Close
(
vlc_object_t
*
);
vlc_module_begin
()
set_shortname
(
"XDG-screensaver"
)
set_description
(
N_
(
"XDG screen saver inhibition"
)
)
set_capability
(
"inhibit"
,
10
)
set_callbacks
(
Open
,
Close
)
set_category
(
CAT_ADVANCED
)
set_subcategory
(
SUBCAT_ADVANCED_MISC
)
vlc_module_end
()
struct
vlc_inhibit_sys
{
pid_t
pid
;
char
id
[
11
];
};
static
void
Inhibit
(
vlc_inhibit_t
*
ih
,
bool
suspend
);
static
int
Open
(
vlc_object_t
*
obj
)
{
vlc_inhibit_t
*
ih
=
(
vlc_inhibit_t
*
)
obj
;
vlc_inhibit_sys_t
*
p_sys
=
malloc
(
sizeof
(
*
p_sys
));
if
(
p_sys
==
NULL
)
return
VLC_ENOMEM
;
ih
->
p_sys
=
p_sys
;
ih
->
inhibit
=
Inhibit
;
p_sys
->
pid
=
0
;
snprintf
(
p_sys
->
id
,
sizeof
(
p_sys
->
id
),
"0x%08"
PRIx32
,
ih
->
window_id
);
return
VLC_SUCCESS
;
}
static
void
Close
(
vlc_object_t
*
obj
)
{
vlc_inhibit_t
*
ih
=
(
vlc_inhibit_t
*
)
obj
;
vlc_inhibit_sys_t
*
p_sys
=
ih
->
p_sys
;
if
(
p_sys
->
pid
)
{
int
status
;
while
(
waitpid
(
p_sys
->
pid
,
&
status
,
0
)
==
-
1
);
}
free
(
p_sys
);
}
static
void
Inhibit
(
vlc_inhibit_t
*
ih
,
bool
suspend
)
{
vlc_inhibit_sys_t
*
p_sys
=
ih
->
p_sys
;
pid_t
pid
;
/* xdg-screensaver can take quite a while to start up (e.g. 1 second).
* So we avoid _waiting_ for it unless we really need to (clean up). */
/* TODO: it would be even faster to cache the current state, and
* wait in a separate thread until the target state is reached. */
if
(
p_sys
->
pid
)
{
int
status
;
while
(
waitpid
(
p_sys
->
pid
,
&
status
,
0
)
==
-
1
);
p_sys
->
pid
=
0
;
}
char
*
argv
[
4
]
=
{
(
char
*
)
"xdg-screensaver"
,
suspend
?
(
char
*
)
"suspend"
:
(
char
*
)
"resume"
,
p_sys
->
id
,
NULL
,
};
if
(
posix_spawnp
(
&
pid
,
"xdg-screensaver"
,
NULL
,
NULL
,
argv
,
environ
)
==
0
)
{
msg_Dbg
(
ih
,
"started xdg-screensaver (PID = %d)"
,
(
int
)
pid
);
ih
->
p_sys
->
pid
=
pid
;
}
else
msg_Warn
(
ih
,
"could not start xdg-screensaver"
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment