Commit b9e97cf0 authored by dmaclach@chromium.org's avatar dmaclach@chromium.org

Make sure curtain mode doesn't lock up MacOS 10.7

Also adds some extra error logging.

BUG=None
TEST=Go into curtain mode on 10.7 and then disconnect the session.


Review URL: http://codereview.chromium.org/8384011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108184 0039d316-1c4b-4281-b951-d872f2087c98
parent f4261897
...@@ -228,8 +228,11 @@ CapturerMac::~CapturerMac() { ...@@ -228,8 +228,11 @@ CapturerMac::~CapturerMac() {
ReleaseBuffers(); ReleaseBuffers();
CGUnregisterScreenRefreshCallback(CapturerMac::ScreenRefreshCallback, this); CGUnregisterScreenRefreshCallback(CapturerMac::ScreenRefreshCallback, this);
CGScreenUnregisterMoveCallback(CapturerMac::ScreenUpdateMoveCallback, this); CGScreenUnregisterMoveCallback(CapturerMac::ScreenUpdateMoveCallback, this);
CGDisplayRemoveReconfigurationCallback( CGError err = CGDisplayRemoveReconfigurationCallback(
CapturerMac::DisplaysReconfiguredCallback, this); CapturerMac::DisplaysReconfiguredCallback, this);
if (err != kCGErrorSuccess) {
LOG(ERROR) << "CGDisplayRemoveReconfigurationCallback " << err;
}
} }
bool CapturerMac::Init() { bool CapturerMac::Init() {
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
#include "remoting/host/curtain.h" #include "remoting/host/curtain.h"
#include <ApplicationServices/ApplicationServices.h>
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
namespace { namespace {
static const char* kCGSessionPath = static const char* kCGSessionPath =
...@@ -28,19 +31,25 @@ class CurtainMac : public Curtain { ...@@ -28,19 +31,25 @@ class CurtainMac : public Curtain {
}; };
void CurtainMac::EnableCurtainMode(bool enable) { void CurtainMac::EnableCurtainMode(bool enable) {
// Whether curtain mode is being enabled or disabled, switch out the session. // Whether curtain mode is being enabled or disabled, switch out the session
// if the current user is switched in.
// TODO(jamiewalch): If curtain mode is being enabled at the login screen, it // TODO(jamiewalch): If curtain mode is being enabled at the login screen, it
// should be deferred until the user logs in. // should be deferred until the user logs in.
pid_t child = fork(); base::mac::ScopedCFTypeRef<CFDictionaryRef> session(
if (child == 0) { CGSessionCopyCurrentDictionary());
execl(kCGSessionPath, kCGSessionPath, "-suspend", (char*)0); if (CFDictionaryGetValue(session,
exit(1); kCGSessionOnConsoleKey) == kCFBooleanTrue) {
} else if (child > 0) { pid_t child = fork();
int status = 0; if (child == 0) {
waitpid(child, &status, 0); execl(kCGSessionPath, kCGSessionPath, "-suspend", (char*)0);
// To ensure that the system has plenty of time to notify the CGDisplay- exit(1);
// ReconfigurationCallback, sleep here. 1s is probably overkill. } else if (child > 0) {
sleep(1); int status = 0;
waitpid(child, &status, 0);
// To ensure that the system has plenty of time to notify the CGDisplay-
// ReconfigurationCallback, sleep here. 1s is probably overkill.
sleep(1);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment