|
|
| Author |
Message |
|
|
e-izmir-a Familiar Face
Joined: 16 Jan 2008 Posts: 8 Location: Schaafheim - Frankfurt / Germany
|
Posted: Wed Jan 16, 2008 1:05 pm Post subject: Inactive/ Active Window Signal |
|
|
Hello Everybody,
I need your suggestion for my little problem. I've got a window widget and I am drawing many little things on it with cairo. Now I have to draw a shape when the window is active, and change the colour of the shape if not. I know how to fetch the current state of the window for checking the activity ( gtk_window_is_active () ), but there is no signal for it. For drawing on the window surface, I am using the "expose" signal, but this signal is not the best solution for checking the window state, because the expose signal will be only called if there is anything to redraw (for example by maximizing the window or so on).
My question is: Is there any signal, that will be called, if the window is active/inactive?
I have looked at the API of GTK, but I did not found any signal or a brief of information.
Thank you for your helps,
Ercan
Last edited by e-izmir-a on Wed Jan 16, 2008 8:10 pm; edited 1 time in total |
|
| Back to top |
|
 |
Micah Carrick Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 427 Location: Portland, OR USA
|
Posted: Wed Jan 16, 2008 1:54 pm Post subject: |
|
|
| Code: (C) | 1 2 3 4
|
GtkWindow *my_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
/* ... */
GdkWindowState state = gdk_window_get_state (my_window->window); |
That will give you one of the following...
GDK_WINDOW_STATE_WITHDRAWN
the window is not shown.
GDK_WINDOW_STATE_ICONIFIED
the window is minimized.
GDK_WINDOW_STATE_MAXIMIZED
the window is maximized.
GDK_WINDOW_STATE_STICKY
the window is sticky.
GDK_WINDOW_STATE_FULLSCREEN
the window is maximized without decorations.
GDK_WINDOW_STATE_ABOVE
the window is kept above other windows.
GDK_WINDOW_STATE_BELOW
the window is kept below other windows. |
|
| Back to top |
|
 |
e-izmir-a Familiar Face
Joined: 16 Jan 2008 Posts: 8 Location: Schaafheim - Frankfurt / Germany
|
Posted: Wed Jan 16, 2008 2:06 pm Post subject: |
|
|
Yes, you are right, but I need a signal, that will be called if the window is active/inacative.
I have tried this code:
| Code: (C) | 1 2 3 4
| g_signal_connect (G_OBJECT ( window),
"window_state_event",
G_CALLBACK ( state_event ),
NULL); |
| Code: (C) | 1 2 3 4 5 6 7 8 9 10
|
void state_event (GtkWidget* widget,
GdkEventWindowState *event,
gpointer userdata)
{
if( event->changed_mask & GDK_WINDOW_STATE_ABOVE ) {
g_print("State: Active\n\n");
}
} |
But it cannot reach the code, where prints the string "State: Active". That means this code will not work :(
Any other suggestions?
Thanks,
Ercan |
|
| Back to top |
|
 |
Micah Carrick Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 427 Location: Portland, OR USA
|
Posted: Wed Jan 16, 2008 2:13 pm Post subject: |
|
|
| I believe your GDK_WINDOW_STATE_ABOVE flag is only tripped when the window is set to stay above all windows or that feature is turned off. This would not be tripped when the window is simply brought to the top of another window through you selecting it in your window manager. |
|
| Back to top |
|
 |
e-izmir-a Familiar Face
Joined: 16 Jan 2008 Posts: 8 Location: Schaafheim - Frankfurt / Germany
|
Posted: Wed Jan 16, 2008 2:19 pm Post subject: |
|
|
| Micah Carrick wrote: | | I believe your GDK_WINDOW_STATE_ABOVE flag is only tripped when the window is set to stay above all windows or that feature is turned off. This would not be tripped when the window is simply brought to the top of another window through you selecting it in your window manager. |
It sounds right. But how can I solve this problem? I have no ideas to get the window state while the window is active/inactive...
Isn't there any signal, who done exactly this job?
Thanks,
Ercan |
|
| Back to top |
|
 |
Micah Carrick Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 427 Location: Portland, OR USA
|
Posted: Wed Jan 16, 2008 2:27 pm Post subject: |
|
|
| I can't recall off the top of my head... I think the "expose-event" maybe what you're looking for? Take a look at the source code for the GdkDrawingArea example from Andrew's book: Foundations of GTK+ Development at http://gtkbook.com/ |
|
| Back to top |
|
 |
e-izmir-a Familiar Face
Joined: 16 Jan 2008 Posts: 8 Location: Schaafheim - Frankfurt / Germany
|
Posted: Wed Jan 16, 2008 2:31 pm Post subject: |
|
|
| Micah Carrick wrote: | | I can't recall off the top of my head... I think the "expose-event" maybe what you're looking for? Take a look at the source code for the GdkDrawingArea example from Andrew's book: Foundations of GTK+ Development at http://gtkbook.com/ |
"expose-event" will not work, because this signal will be only called if there is anything to redraw by minimizing or changing the window size (and so on)...
Okay, I'll looking to the source codes, maybe I'll find anything that help me to solve this little problem.
Can you tell me a solution, if you find anything?
Thanks,
Ercan |
|
| Back to top |
|
 |
|