transient windows



Hi,

I wonder if there is some GTKish way to make a window transient for
another. Window managers don't let the parent to overlap the transient
window while it is visible (an example is Netscape Navigator's "Find
in page" dialog box).  In addition, some window managers,
e.g. WindowMaker minimize or hide the transient window as well, if the
parent is minimized/hidden.  In short, transient windows are handy for
pop-up dialogs etc.

Transient windows are marked with XSetTransientForHint(display,
window, parent) on the xlib level, but I haven't found any gtk/gdk
function to handle this.  A GtkWindow with type GTK_WINDOW_DIALOG is
marked transient for the _root window_, but is insufficient, and there
is no way to change this behaviour.

Find attached a workaround for the problem (a gtk-- widget).  This
uses the xlib call and therefore is an ugly hack.  Could you integrate
this transient window stuff into GTK?

Andras

// $Id: transient.h,v 1.1 1998/08/15 15:05:27 nagya Exp $ -*- c++ -*-

#ifndef TRANSIENT_H
#define TRANSIENT_H
#include <gtk--.h>

class Gtk_Transient : public Gtk_Window {
    Gtk_Window *transient_for;
public:
    Gtk_Transient(Gtk_Window *p);
protected:
    virtual void show_impl();
    virtual void hide_impl();
};

#endif
// $Id: transient.cc,v 1.1 1998/08/15 15:05:27 nagya Exp $

#include "transient.h"
#include <gdk/gdkx.h>
#include <X11/Xlib.h>

Gtk_Transient::Gtk_Transient(Gtk_Window *p) :
    Gtk_Window(GTK_WINDOW_DIALOG)
{
    transient_for = p;
}

void Gtk_Transient::show_impl()
{
    Gtk_Window::show_impl();
    Gtk_Main::grab_add(this);
    XSetTransientForHint(
	GDK_WINDOW_XDISPLAY(get_window()),
	GDK_WINDOW_XWINDOW(get_window()),
	GDK_WINDOW_XWINDOW(transient_for->get_window()));
}

void Gtk_Transient::hide_impl()
{
    Gtk_Main::grab_remove(this);
    Gtk_Window::hide_impl();
}


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