Should there be a call to make a window "active"?

...where "make a window active" means "de-iconify it, raise it, and give
it the input focus".

The GTK+ application on which I work (Ethereal) doesn't have many modal
windows (I prefer not to, for example, keep people from looking at
packets in the list of captured packets if they're trying to set up a
display filter).

Instead, I use a technique that Netscape also uses if you select
"Communicator->Bookmarks->Edit Bookmarks" when there's already a
bookmark window open.

If the user selects, say, "File->Open" when there's already a file
selection dialog box open, I do a "gdk_window_show()" and a
"gdk_window_raise()" on the dialog box, to request that it be
de-iconified and raised.

Unfortunately, I can't also request that it be given the input focus, as
there's no GDK call to do an "XSetInputFocus()" on it.

This would require a routine - call it "gdk_window_set_active()" - that:

	on X11, would de-iconify and raise the window, wait for a
	MapNotify event to arrive indicating that the window is now
	mapped, and then do "XSetInputFocus()";

	on Win32, would do "SetActiveWindow()" (and do whatever other
	calls are necessary to de-iconify and raise it);

	on other platforms, would do the appropriate thing for that
	platform, or do nothing if it's not supported.

Then again, Netscape on X doesn't seem to give that window the input
focus, so perhaps either

	1) it's impossible (although the page at

	   shows some code that I suspect is intended to do that:

		void sdl_RemapWindow(void)
		    SDL_SysWMinfo info;

		    if ( SDL_GetWMInfo(&info) > 0 ) {
		        if ( info.subsystem == SDL_SYSWM_X11 ) {
		            Display *display;
		            Window window;
		            XEvent event;

		            display =;
		            window =;

		            do {
		              XNextEvent(display, &event);
		            } while ( event.type != MapNotify );

		            XSetInputFocus(display, window, RevertToPointerRoot,



	2) it's not considered to be the right thing to do.

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