[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/farmerbb/crouton
Browse files Browse the repository at this point in the history
  • Loading branch information
dnschneid committed Sep 1, 2017
2 parents 0b3ec2c + 2aa1dd1 commit 6072e32
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/freon.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@

#define LOCK_FILE_DIR "/tmp/crouton-lock"
#define DISPLAY_LOCK_FILE LOCK_FILE_DIR "/display"
#define FREON_DBUS_METHOD_CALL(function) \
#define LIBCROSSERVICE_METHOD_CALL(function) \
system("host-dbus dbus-send --system --dest=org.chromium.LibCrosService " \
"--type=method_call --print-reply /org/chromium/LibCrosService " \
"org.chromium.LibCrosServiceInterface." #function)
#define DISPLAYSERVICE_METHOD_CALL(function) \
system("host-dbus dbus-send --system --dest=org.chromium.DisplayService " \
"--type=method_call --print-reply /org/chromium/DisplayService " \
"org.chromium.DisplayServiceInterface." #function)

#define TRACE(...) /* fprintf(stderr, __VA_ARGS__) */
#define ERROR(...) fprintf(stderr, __VA_ARGS__)
Expand Down Expand Up @@ -162,7 +166,10 @@ int ioctl(int fd, unsigned long int request, ...) {
(request == VT_ACTIVATE && (uintptr_t)data == 0)) {
if (lockfd != -1) {
TRACE("Telling Chromium OS to regain control\n");
ret = FREON_DBUS_METHOD_CALL(TakeDisplayOwnership);
ret = LIBCROSSERVICE_METHOD_CALL(TakeDisplayOwnership);
if (WEXITSTATUS(ret) == 1) {
ret = DISPLAYSERVICE_METHOD_CALL(TakeOwnership);
}
if (set_display_lock(0) < 0) {
ERROR("Failed to release display lock\n");
}
Expand All @@ -171,7 +178,10 @@ int ioctl(int fd, unsigned long int request, ...) {
(request == VT_ACTIVATE && (uintptr_t)data == 7)) {
if (set_display_lock(getpid()) == 0) {
TRACE("Telling Chromium OS to drop control\n");
ret = FREON_DBUS_METHOD_CALL(ReleaseDisplayOwnership);
ret = LIBCROSSERVICE_METHOD_CALL(ReleaseDisplayOwnership);
if (WEXITSTATUS(ret) == 1) {
ret = DISPLAYSERVICE_METHOD_CALL(ReleaseOwnership);
}
} else {
ERROR("Unable to claim display lock\n");
ret = -1;
Expand Down

0 comments on commit 6072e32

Please sign in to comment.