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() {
ReleaseBuffers();
CGUnregisterScreenRefreshCallback(CapturerMac::ScreenRefreshCallback, this);
CGScreenUnregisterMoveCallback(CapturerMac::ScreenUpdateMoveCallback, this);
CGDisplayRemoveReconfigurationCallback(
CGError err = CGDisplayRemoveReconfigurationCallback(
CapturerMac::DisplaysReconfiguredCallback, this);
if (err != kCGErrorSuccess) {
LOG(ERROR) << "CGDisplayRemoveReconfigurationCallback " << err;
}
}
bool CapturerMac::Init() {
......
......@@ -4,9 +4,12 @@
#include "remoting/host/curtain.h"
#include <ApplicationServices/ApplicationServices.h>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
namespace {
static const char* kCGSessionPath =
......@@ -28,19 +31,25 @@ class CurtainMac : public Curtain {
};
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
// should be deferred until the user logs in.
pid_t child = fork();
if (child == 0) {
execl(kCGSessionPath, kCGSessionPath, "-suspend", (char*)0);
exit(1);
} else if (child > 0) {
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);
base::mac::ScopedCFTypeRef<CFDictionaryRef> session(
CGSessionCopyCurrentDictionary());
if (CFDictionaryGetValue(session,
kCGSessionOnConsoleKey) == kCFBooleanTrue) {
pid_t child = fork();
if (child == 0) {
execl(kCGSessionPath, kCGSessionPath, "-suspend", (char*)0);
exit(1);
} else if (child > 0) {
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