I was able to get it to build. I was not setting the CEF_ROOT to the proper binary I think, however the Release version upon executing the executable:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 42 (X_SetInputFocus)
Serial number of failed request: 290
Current serial number in output stream: 292
The Debug version
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 42 (X_SetInputFocus)
Serial number of failed request: 290
Current serial number in output stream: 292
[0623/092626:FATAL:context.cc(211)] Check failed: false. context not valid
#0 0x7f71822bc4ae base::debug::StackTrace::StackTrace()
#1 0x7f71823085ef logging::LogMessage::~LogMessage()
#2 0x7f7181f8de09 CefQuitMessageLoop()
#3 0x7f7181dd84c9 cef_quit_message_loop
#4 0x00000043b3ca CefQuitMessageLoop()
#5 0x0000004097cc SimpleHandler::OnBeforeClose()
#6 0x00000045e13d (anonymous namespace)::life_span_handler_on_before_close()
#7 0x7f7181e5595f CefLifeSpanHandlerCToCpp::OnBeforeClose()
#8 0x7f7181f30f1e CefBrowserHostImpl::DestroyBrowser()
#9 0x7f7181f6320f CefBrowserInfoManager::DestroyAllBrowsers()
#10 0x7f7181f8e3c0 CefContext::FinishShutdownOnUIThread()
#11 0x7f7181f8d9ed CefContext::Shutdown()
#12 0x7f7181f8cd26 (anonymous namespace)::CefForceShutdown::~CefForceShutdown()
#13 0x7f718080353a __cxa_finalize
#14 0x7f7181dd2553 <unknown>
Aborted (core dumped)
Here is a solution I am trying and will report back.
Found on StackOverflow:
http://stackoverflow.com/questions/16720961/many-xsetinputfocuss-and-xsync-causes-errorFrom the documentation, it states the following:
The specified focus window must be viewable at the time XSetInputFocus is called, or a BadMatch error results. If the focus window later becomes not viewable, the X server evaluates the revert_to argument to determine the new focus window as follows:
If revert_to is RevertToParent, the focus reverts to the parent (or the closest viewable ancestor), and the new revert_to value is taken to be RevertToNone.
If revert_to is RevertToPointerRoot or RevertToNone, the focus reverts to PointerRoot or None, respectively. When the focus reverts, the X server generates FocusIn and FocusOut events, but the last-focus-change time is not affected.
XSetInputFocus can generate BadMatch, BadValue, and BadWindow errors.
So, I was missing a check to determine whether the window is viewable or not. The following change will fix the problem:
main()
{
// Obtain the X11 display.
Display *display = XOpenDisplay(0);
if(display == NULL)
return -1;
// Get the root window for the current display.
Window winRoot = XDefaultRootWindow(display);
WindowsMatchingPid wmp(display,winRoot,4344);
list<Window> lw = wmp.result();
for(list<Window>::iterator it=lw.begin(); it != lw.end(); it++ ){
XWindowAttributes attribute; // <-- Added
XGetWindowAttributes(display,*it,&attribute); // <-- Added
if(attribute.map_state == IsViewable ){ // <-- Added
XSetInputFocus(display,*it,RevertToParent,CurrentTime);
} // <-- Added
}
XCloseDisplay(display);
return 0;
}