Reland of move all reference to carbon api (patchset #1 id:1 of https://codereview.webrtc.org/2316563002/ )
Reason for revert: Chromium build issues have been resolved. Original issue's description: > Revert of Remove all reference to carbon api (patchset #2 id:20001 of https://codereview.webrtc.org/2299633002/ ) > > Reason for revert: > Breaks chromium build > > Original issue's description: > > Remove all reference to carbon api > > > > BUG=webrtc:6282 > > > > Committed: https://crrev.com/dbd8b6bec4143c940b2f2ca8cd85c25d17327964 > > Cr-Commit-Position: refs/heads/master@{#14080} > > TBR=magjed@webrtc.org,mflodman@webrtc.org > # Skipping CQ checks because original CL landed less than 1 days ago. > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=webrtc:6282 > > Committed: https://crrev.com/b096aa7fd375a980daab3a986596548ca5de2a1c > Cr-Commit-Position: refs/heads/master@{#14081} TBR=magjed@webrtc.org,mflodman@webrtc.org # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:6282 Review-Url: https://codereview.webrtc.org/2321493002 Cr-Commit-Position: refs/heads/master@{#14125}
This commit is contained in:
@ -106,74 +106,7 @@ bool MacWindowPicker::IsVisible(const WindowId& id) {
|
||||
}
|
||||
|
||||
bool MacWindowPicker::MoveToFront(const WindowId& id) {
|
||||
// Init if we're not already initialized.
|
||||
if (get_window_list_desc_ == NULL && !Init()) {
|
||||
return false;
|
||||
}
|
||||
CGWindowID ids[1];
|
||||
ids[0] = id.id();
|
||||
CFArrayRef window_id_array =
|
||||
CFArrayCreate(NULL, reinterpret_cast<const void **>(&ids), 1, NULL);
|
||||
|
||||
CFArrayRef window_array =
|
||||
reinterpret_cast<CGWindowListCreateDescriptionFromArrayProc>(
|
||||
get_window_list_desc_)(window_id_array);
|
||||
if (window_array == NULL || 0 == CFArrayGetCount(window_array)) {
|
||||
// Could not find the window. It might have been closed.
|
||||
LOG(LS_INFO) << "Window not found";
|
||||
CFRelease(window_id_array);
|
||||
return false;
|
||||
}
|
||||
|
||||
CFDictionaryRef window = reinterpret_cast<CFDictionaryRef>(
|
||||
CFArrayGetValueAtIndex(window_array, 0));
|
||||
CFStringRef window_name_ref = reinterpret_cast<CFStringRef>(
|
||||
CFDictionaryGetValue(window, kCGWindowName));
|
||||
CFNumberRef application_pid = reinterpret_cast<CFNumberRef>(
|
||||
CFDictionaryGetValue(window, kCGWindowOwnerPID));
|
||||
|
||||
int pid_val;
|
||||
CFNumberGetValue(application_pid, kCFNumberIntType, &pid_val);
|
||||
std::string window_name;
|
||||
ToUtf8(window_name_ref, &window_name);
|
||||
|
||||
// Build an applescript that sets the selected window to front
|
||||
// within the application. Then set the application to front.
|
||||
bool result = true;
|
||||
std::stringstream ss;
|
||||
ss << "tell application \"System Events\"\n"
|
||||
<< "set proc to the first item of (every process whose unix id is "
|
||||
<< pid_val
|
||||
<< ")\n"
|
||||
<< "tell proc to perform action \"AXRaise\" of window \""
|
||||
<< window_name
|
||||
<< "\"\n"
|
||||
<< "set the frontmost of proc to true\n"
|
||||
<< "end tell";
|
||||
if (!RunAppleScript(ss.str())) {
|
||||
// This might happen to for example X applications where the X
|
||||
// server spawns of processes with their own PID but the X server
|
||||
// is still registered as owner to the application windows. As a
|
||||
// workaround, we put the X server process to front, meaning that
|
||||
// all X applications will show up. The drawback with this
|
||||
// workaround is that the application that we really wanted to set
|
||||
// to front might be behind another X application.
|
||||
ProcessSerialNumber psn;
|
||||
pid_t pid = pid_val;
|
||||
int res = GetProcessForPID(pid, &psn);
|
||||
if (res != 0) {
|
||||
LOG(LS_ERROR) << "Failed getting process for pid";
|
||||
result = false;
|
||||
}
|
||||
res = SetFrontProcess(&psn);
|
||||
if (res != 0) {
|
||||
LOG(LS_ERROR) << "Failed setting process to front";
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
CFRelease(window_id_array);
|
||||
CFRelease(window_array);
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MacWindowPicker::GetDesktopList(DesktopDescriptionList* descriptions) {
|
||||
|
||||
Reference in New Issue
Block a user