[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Console Button
- From: Erik Mouw <J A K Mouw its tudelft nl>
- To: gtk-app-devel-list redhat com
- Subject: Re: Console Button
- Date: Mon, 4 Oct 99 11:30:59 +0200
On Sun, 03 Oct 1999 14:15:42 +0100, Carlos Pereira wrote:
> I would like to implement a console button: when pressed, the window
> that launched the app (where printing messages are shown) comes on top,
> when pressed again, the window goes back quietly and the app is refreshed.
> Of course, many windows can be open at the same time, so it is necessary
> to know which one is the right one, and then, somehow, to inform the window
> manager to change the window priority... how can this be done?
There are no simple gtk or gdk functions for this, you have to use Xlib
functions: XRaiseWindow() and XLowerWindow(). Both functions need the X
display and a window. You can get the current X display and window with:
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
GtkWidget *toplevel;
Display *display;
Window w;
toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(toplevel);
display = GDK_WINDOW_XDISPLAY(toplevel->window);
w = GDK_WINDOW_XWINDOW(toplevel->window);
Now raise your application's window with:
XRaiseWindow(display, w);
The only problem you have is to get the window ID of the xterm you want to
raise. However, xterms set the environment variable WINDOWID, so for
xterms it is quite easy:
char *windowid;
Window w;
windowid = getenv("WINDOWID");
if(windowid == NULL)
{
perror("getenv");
exit(-1);
}
w = (Window)atoi(windowid);
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2785859 Fax: +31-15-2781843 Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]