Re: How to shake a window



Just a quick guess but it sounds like you may need to use a 
while (gtk_events_pending())
    gtk_main_iteration();
to have things updated when you want them to.
Also, gdm the gnome login manager shakes the window like this when you
give a wrong password so you could always look at that code to see how
they did it.

        HTH,
                Stephen



Lokesh Setia wrote:
> 
> Hi all,
> 
> I am writing a utility program in gtk+, which has the following
> characterstics:
> 
> . It has a small window with a drawing_area (100x100), plus a couple
> of other small widgets.
> . It has NO Window Manager decorations
> . It collects some data from a web site and updates window contents
> accordingly.
> 
>   I want my window to shake visibally when the data gets updated (to
> attract the attention of the user). Such a feature known as buzz is
> there in a recent windows of yahoo_messenger, in case anyone has seen
> it).
> 
> I tried this code in the update data callback of a single-threaded
> application):
> 
> note: This is my first gtk program...
> 
> {
> 
>   /* Here I am in a callback */
>   /* ... some irrelevant code skipped */
> 
>   printf("in buzz...\n");
> 
>   gdk_window_get_position(main_window->window,
>                           &posx, &posy);
> 
>   for (ctr=0; ctr<5; ctr++) {
>     gdk_window_move( main_window->window, posx-50+(ctr*10), posy );
>     usleep(50 * 1000);
> 
>     gdk_window_move( main_window->window, posx+50-(ctr*10), posy );
>     usleep(50 * 1000);
> 
>   }
> 
>   gdk_window_move( main_window->window, posx, posy );
> 
> }
> 
> When I run this program, the shake is very random, and occurs only
> occasionally.  However, when I take my mouse over the window, the
> shake occurs more reliably (and even older events are processed as
> soon as I take my mouse there).
> 
> I tried giving --sync to my program.  Even now the window shakes only
> if my mouse is hovering over the window, plus I get following
> messages seemingly randomly:
> 
> Xlib: unexpected async reply (sequence 0x410)
> Gdk-ERROR **: BadWindow (invalid Window parameter)
>   serial 1331 error_code 3 request_code 15 minor_code 0
> Gdk-ERROR **: BadDrawable (invalid Pixmap or Window parameter)
>   serial 1335 error_code 9 request_code 14 minor_code 0
> 
> Anyone for why all this is happening, and how I could write a better
> code to shake a window.
> 
> PS:
> I also wish to know the following:
> 
> . How do I make my window "Always on Top" and Sticky, without user
> having to manually do this from her window manager?
> 
> . Where can I download some nice mouse cursors?
> 
> Thanks and regards,
> Lokesh.
> 
> _______________________________________________




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]