GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 23, 2014 7:57 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Inactive/ Active Window Signal
PostPosted: Wed Jan 16, 2008 1:05 pm 
Offline
Familiar Face

Joined: Wed Jan 16, 2008 12:05 pm
Posts: 8
Location: Schaafheim - Frankfurt / Germany
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.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 1:54 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
Code:
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.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 2:06 pm 
Offline
Familiar Face

Joined: Wed Jan 16, 2008 12:05 pm
Posts: 8
Location: Schaafheim - Frankfurt / Germany
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:
      g_signal_connect (G_OBJECT ( window),
                    "window_state_event",
                    G_CALLBACK ( state_event ),
                    NULL);

Code:
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 2:13 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
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.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 2:19 pm 
Offline
Familiar Face

Joined: Wed Jan 16, 2008 12:05 pm
Posts: 8
Location: Schaafheim - Frankfurt / Germany
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 2:27 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
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/

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 2:31 pm 
Offline
Familiar Face

Joined: Wed Jan 16, 2008 12:05 pm
Posts: 8
Location: Schaafheim - Frankfurt / Germany
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group