Obtaining pointer to the window with focus
- From: David Buchan <pdbuchan yahoo com>
- To: gtk-app-devel-list list <gtk-app-devel-list gnome org>
- Subject: Obtaining pointer to the window with focus
- Date: Mon, 9 Dec 2013 08:45:55 -0800 (PST)
I've not seen a clear answer to this obvious question. Maybe I'm not searching for the right terms.
What I want to do is create a dialog if an error occurs, and I want it to appear atop the window that
currently has focus. This seems like a standard thing to do, so it's weird I can't find a clear explanation.
What I have found suggests something like:
GtkWidget *widget, *focussed_window;
GList *list = NULL; // NULL means empty list
list = gtk_window_list_toplevels ();
g_list_foreach (list, (GFunc) g_object_ref, NULL);
while ((widget = g_list_next (list)) != NULL) { // line 577
if (gtk_window_has_toplevel_focus ((GtkWindow *) window)) {
focussed_window = widget; // We found the window that currently has focus.
}
g_list_free (list);
Is this the correct approach? If so, can someone show me how that would be coded in C?
This does not compile. I get:
func.c:577: warning: assignment from incompatible pointer type
Dave
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]