[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Window Focus Problem (was Re: GNUstep Window Manager (was RE: Idea))
From: |
Adam Fedor |
Subject: |
Window Focus Problem (was Re: GNUstep Window Manager (was RE: Idea)) |
Date: |
Mon, 08 Jan 2001 11:04:08 -0700 |
Sungjin Chun wrote:
>
>
> So, the problem lies in xgps and WindowMaker both sides...
Probably, or a misunderstanding on my part about how focus is supposed
to work. I have a simple (non-GNUstep) program which illustrates at
least one of the problems. I just haven't had the time to delve into why
it doesn't work.
/* InputFocus test
Written: Adam Fedor
Date: Oct 2000
Compile: $(CC) -I/usr/X11R6/include -g -Wall -o inputfocus \
inputfocus.o -L/usr/X11R6/lib -lXt -lX11 -lm
Run: Run the program, type 'q' to quit. Notice that focus isn't
returned to the xterm you started from .
Note that if you change the res_class classhint to something other
than GNUstep, it works again.
*/
#include <stdio.h>
#include <malloc.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
Atom protocols_atom;
Atom take_focus_atom;
Atom delete_win_atom;
Display *dpy;
int
setup_window(Window window)
{
XClassHint *classhint;
Atom protocols[2];
// Set protocols
protocols[0] = take_focus_atom;
protocols[1] = delete_win_atom;
XSetWMProtocols(dpy, window, protocols, 2);
classhint = XAllocClassHint();
classhint->res_name = "inputfocus";
classhint->res_class = "GNUstep"; /* <---- Change this */
if (XSetClassHint(dpy, window, classhint) == 0)
printf("Error setting class hints\n");
// Set the X event mask
XSelectInput(dpy, window, KeyPressMask | KeyReleaseMask | ButtonPressMask |
ButtonReleaseMask | PointerMotionMask |
StructureNotifyMask |
FocusChangeMask | PropertyChangeMask);
return 0;
}
int
main(int argc, char **argv)
{
XEvent xEvent;
Window window;
int done;
unsigned short keyCode;
dpy = XOpenDisplay(0);
protocols_atom = XInternAtom(dpy, "WM_PROTOCOLS", False);
take_focus_atom = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
delete_win_atom = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
window = XCreateSimpleWindow(dpy, DefaultRootWindow (dpy),
100, 100, 200, 200,
2,
BlackPixel (dpy, 0),
WhitePixel(dpy, 0));
setup_window(window);
XMapWindow(dpy, window);
done = 0;
while (!done)
{
XNextEvent(dpy, &xEvent);
printf("Event %d\n", xEvent.type);
switch (xEvent.type)
{
case MapNotify:
printf("%d MapNotify\n", xEvent.xmap.window);
break;
case KeyPress:
{
int count;
char buf[256];
XComposeStatus compose;
KeySym keysym;
keyCode = xEvent.xkey.keycode;
count = XLookupString ((XKeyEvent *)&xEvent, buf, 256, &keysym,
&compose);
printf("KeyPress %d, sym %d\n", keyCode, keysym);
if (keysym == 'q')
done=1;
}
break;
case ClientMessage:
printf("ClientMessage\n");
if (xEvent.xclient.message_type == protocols_atom)
{
printf("WM Protocol - %s\n",
XGetAtomName(dpy, xEvent.xclient.data.l[0]));
if (xEvent.xclient.data.l[0] == delete_win_atom)
{
}
else if (xEvent.xclient.data.l[0] == take_focus_atom)
{
printf("Setting input focus on %d\n", window);
XSetInputFocus(dpy, window, RevertToParent, CurrentTime);
}
}
break;
case MotionNotify:
{
Window rootWin;
Window childWin;
int currentX;
int currentY;
int winX;
int winY;
unsigned mask;
int ok;
printf("%d MotionNotify - %d %d\n",
xEvent.xmotion.window, xEvent.xmotion.x, xEvent.xmotion.y);
ok = XQueryPointer (dpy, window,
&rootWin, &childWin, ¤tX, ¤tY, &winX, &winY,
&mask);
printf(" Query - %d %d\n", currentX, currentY);
}
default:
break;
} /*switch*/
} /*while*/
XDestroyWindow(dpy, window);
XCloseDisplay(dpy);
return 0;
}
- Re: GNUstep Window Manager (was RE: Idea), (continued)
- Re: GNUstep Window Manager (was RE: Idea), Philippe C . D . Robert, 2001/01/08
- Re: GNUstep Window Manager (was RE: Idea), Sungjin Chun, 2001/01/07
- Re: GNUstep Window Manager (was RE: Idea), Nicola Pero, 2001/01/08
- Re: GNUstep Window Manager (was RE: Idea), Sungjin Chun, 2001/01/08
- Re: GNUstep Window Manager (was RE: Idea), Dan Pascu, 2001/01/08
- Re: GNUstep Window Manager (was RE: Idea), Sungjin Chun, 2001/01/08
- Window Focus Problem (was Re: GNUstep Window Manager (was RE: Idea)),
Adam Fedor <=
- Re: Window Focus Problem (was Re: GNUstep Window Manager (was RE: I dea)), Dan Pascu, 2001/01/09
- Re: Window Focus Problem (was Re: GNUstep Window Manager (was RE: I dea)), Sungjin Chun, 2001/01/09
Re: GNUstep Window Manager (was RE: Idea), Gregory Casamento, 2001/01/07
Re: GNUstep Window Manager (was RE: Idea), Richard Frith-Macdonald, 2001/01/07
Re: GNUstep Window Manager (was RE: Idea), Richard Frith-Macdonald, 2001/01/07