Re: [gtk-list] gtk_window_position only works when window hidden ?
- From: Tim Janik <timj gtk org>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] gtk_window_position only works when window hidden ?
- Date: Sun, 12 Jul 1998 12:24:24 +0200 (CEST)
On Sun, 12 Jul 1998, Georg Greve wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
>
> Hi !
>
> I have a notice dialog that is considered extremely important where
> data can be added over time, so it should always go where the mouse
> pointer is whenever anything interesting happens.
>
> gtk_window_position(GTK_WINDOW(notice_dialog), GTK_WIN_POS_MOUSE);
>
> does the trick when the window is hidden, but what do I have to do to
> move the mapped and drawn window ? I don't want to hide/show the
> window every time because I guess that could be extremely annoying...
the GtkWindow::win_pos value is only taken care of in the process of
showing the window.
for the purpose of window-followes-mouse (though, i guess i could find that
behaviour annoying) you either need to hide+show the window each time, or
adjust it's position manually:
/* get current window size */
width = GTK_WIDGET (window)->requisition.width;
height = GTK_WIDGET (window)->requisition.height;
/* get pointer position */
gdk_window_get_pointer (NULL, &x, &y, NULL);
/* adjust window to contain pointer in the middle */
x = width / 2;
y = height / 2;
/* check x and y screen bounds */
screen_width = gdk_screen_width ();
screen_height = gdk_screen_height ();
if (x < 0) x = 0;
else if (x > (screen_width - width))
x = screen_width - width;
if (y < 0) y = 0;
else if (y > (screen_height - height))
y = screen_height - height;
/* adjust the GtkWindow's gdk window */
gdk_window_move (widget->window, x, y);
if you want your window to save this position for subsequent
show operations, you need to call
gtk_window_position(window, GTK_WIN_POS_NONE);
gtk_widget_set_uposition (GTK:WIDGET (window), x, y);
as well.
(the above code is an adjustment of the GTK_WIN_POS_MOUSE code from
gtkwindow.c to your needs. of course i haven't actually tried it out
or compiled it ;)
>
> Later,
> Georg
>
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]