I have IPC for detect other instance, if other instance is called it send message to first instance and stop.
This action work OK.
First instance must bring to front, and here begin problems.
I have Linux and Cinnamon, and I wrote special method:
Code: Select all
void BringToFront() {
int pid = getpid();
// Start with the root window.
Display *display = XOpenDisplay(0);
WindowsMatchingPid match(display, XDefaultRootWindow(display), pid);
Display *dsp = XOpenDisplay(NULL);
long id = match.result()[0];
XRaiseWindow ( dsp, id );
XCloseDisplay ( dsp );
}
void MyFrame::OnPoke(wxCommandEvent &event) {
SetFocus();
CmdStruct cmdStruct;
char *data = (char*)event.GetClientData();
auto argv = cmdStruct.unpack(data);
for (int i=1; i<argv.size(); i++)
OpenOrActivate(argv[i]);
BringToFront();
}