RE: Iconified windows



Hi !

On 08-Jun-98 Owen Taylor wrote:
>> Silly question: how do I un-iconify a window? Also, how do I tell a window
>> is iconfied?
>> 
>> My goal is a "show an existing window" function that knows to raise and
>> uniconify the window, as needed. I can currently do this by hiding and
>> showing the window, but this needlessly hides it if it is already visible. 
> 
> According to the ICCCM (inter-client-communication manual)
> 
>   gdk_window_show (widget->window)
> 
> should work. [No hide] A iconified window is unmapped by the window
> manager; the WM will take the window being shown as a signal
> to remove the icon.
> 
> Telling that the window is iconified is a bit trickier. If you [...]

In an earlier project we've used the following code, which seems
to work :

#include <gdk/gdkx.h>

void
window_iconify (GdkWindow *window)
{
  XWMHints *xwmh;
  GdkWindowPrivate *private;

  private = (GdkWindowPrivate*) window;
  xwmh = XGetWMHints (private->xdisplay, private->xwindow);
  xwmh->initial_state = IconicState;
  xwmh->flags |= StateHint;
  XSetWMHints (private->xdisplay, private->xwindow, xwmh);
} 

void
window_deiconify (GdkWindow *window)
{
  GdkWindowPrivate *private;

  private = (GdkWindowPrivate*) window;
  XMapRaised (private->xdisplay, private->xwindow);
} 

gboolean
window_is_iconified (GdkWindow *window)
{
  XWindowAttributes xattr;
  GdkWindowPrivate *private;

  private = (GdkWindowPrivate*) window;

  xattr.map_state = IsUnmapped;
  XGetWindowAttributes(private->xdisplay, private->xwindow, &xattr);
  return (xattr.map_state == IsUnmapped); 
}

Then you can do something like this :

  if (!GTK_WIDGET_VISIBLE (dialog))
    gtk_widget_show (dialog);
  else if (window_is_iconized (dialog->window))
    window_deiconify (dialog->window);
  else
    gdk_window_raise (dialog->window);

bye,
   Stefan



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