[Development] extending QtMacExtras?
René J. V. Bertin
rjvbertin at gmail.com
Fri Jan 22 17:08:17 CET 2016
Sorvig Morten wrote:
>> One thing that's really missing from Qt at the moment is a way for an
>> application that is not the foreground application to post a window in the
>> foreground (cf. also my thread on extending QProcess). To my knowledge this
>> can only be done by forcing the application to the foreground using the same
>> technique also used by the QCocoaIntegration ctor. Crude, but sometimes
>> required.
>
> I still don’t understand what the general-purpose API in Qt would do. Perhaps
The basic GP API would provide functions like "come to the foreground";
becomeForegroundApplication(bool force)
{
[NSApp activateIgnoringOtherApps:force];
}
No need for daemons in that case, as each application would only emit
instructions about itself.
>> A variant could take a WId and activate the application owning the
>> corresponding window or widget. I'm not sure to what extent that would be
>> trivial or even possible to implement (Jake? Morten?). It would allow to
>> simulate things that can currently be done (only?) on Unix/X11:
>
>> 1) hand off a request from a foreground application ("A") to a background
>> process or daemon ("D"), providing it a target WId
>
> But if WIds can’t be used in cross-application contexts (which is true for Qt
> on OS X, they are NSView pointers), then you can’t send them to a background
> process either. (?)
Probably, but not necessarily so. It is possible to obtain a list of all open
windows. It's not the most common thing to do and I forget exactly what
information one obtains to identify the windows, but it did seem possible to do
a simple comparison. In other words, even if you only have data that are
pointers to memory you don't own, you can still compare those pointers among
each other, which could then lead to finding an identifier of the target
application. The interesting bit with the NSApplication class is that you can
not only send requests to your own running application, but to any running
application; see for instance http://stackoverflow.com/questions/13367703/cocoa-switch-focus-to-application-and-then-switch-it-back .
It would of course be a lot easier if the WId were a thin wrapper that contained
not only the window reference but also a reference to the owning application.
Just thinking out loud, sorry :)
R.
More information about the Development
mailing list