Re: Obtaining pointer to the window with focus
- From: Florian Müllner <fmuellner gnome org>
- To: David Buchan <pdbuchan yahoo com>
- Cc: gtk-app-devel-list list <gtk-app-devel-list gnome org>
- Subject: Re: Obtaining pointer to the window with focus
- Date: Mon, 9 Dec 2013 21:51:32 +0100
On Mon, Dec 9, 2013 at 5:45 PM, David Buchan <pdbuchan yahoo com> wrote:
while ((widget = g_list_next (list)) != NULL) { // line 577
g_list_next() returns the element as GList, you can get to the actual
content by accessing the 'data' element, e.g. something like:
GList *list, *l;
list = gtk_window_get_toplevels();
for (l = list; l; l = l->next)
{
GtkWidget *window = l->data;
if (gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
...
}
g_list_free (list);
Note however that gtk_window_list_toplevels() lists windows from *all*
running applications, which is probably not what you want - popping up
a dialog as if it originated from a different application (e.g. an
open browser window, email client, ...) is bad style at best, if not
plainly deceptive.
If you are using GtkApplication, gtk_application_get_active_window()
will give you the most recently focused window of your application,
which is likely a much better fit for user expectations. If you are
not using GtkApplication, there is no equivalent function I'm aware of
- you might need to track this yourself in that case.
Cheers,
Florian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]