event: Remove Unmap notify handle function provisionally and improve uicb_client_kill
This commit is contained in:
parent
8d0fb5948f
commit
ac58ced07a
42
src/client.c
42
src/client.c
@ -296,19 +296,36 @@ void
|
||||
uicb_client_kill(uicb_t cmd)
|
||||
{
|
||||
XEvent ev;
|
||||
Atom *atom = NULL;
|
||||
int proto;
|
||||
Bool canbedel = 0;
|
||||
|
||||
CHECK(sel);
|
||||
|
||||
ev.type = ClientMessage;
|
||||
ev.xclient.window = sel->win;
|
||||
ev.xclient.message_type = wm_atom[WMProtocols];
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = wm_atom[WMDelete];
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
|
||||
XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
|
||||
client_unmanage(sel);
|
||||
XSetErrorHandler(errorhandler);
|
||||
if(XGetWMProtocols(dpy, sel->win, &atom, &proto) && atom)
|
||||
{
|
||||
while(proto--)
|
||||
if(atom[proto] == wm_atom[WMDelete])
|
||||
++canbedel;
|
||||
XFree(atom);
|
||||
if(canbedel)
|
||||
{
|
||||
ev.type = ClientMessage;
|
||||
ev.xclient.window = sel->win;
|
||||
ev.xclient.message_type = wm_atom[WMProtocols];
|
||||
ev.xclient.format = 32;
|
||||
ev.xclient.data.l[0] = wm_atom[WMDelete];
|
||||
ev.xclient.data.l[1] = CurrentTime;
|
||||
ev.xclient.data.l[2] = 0;
|
||||
ev.xclient.data.l[3] = 0;
|
||||
ev.xclient.data.l[4] = 0;
|
||||
XSendEvent(dpy, sel->win, False, NoEventMask, &ev);
|
||||
}
|
||||
else
|
||||
XDestroyWindow(dpy, sel->win);
|
||||
}
|
||||
else
|
||||
XDestroyWindow(dpy, sel->win);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -342,6 +359,8 @@ client_manage(Window w, XWindowAttributes *wa)
|
||||
Client *c, *t = NULL;
|
||||
Window trans;
|
||||
Status rettrans;
|
||||
XSetWindowAttributes at;
|
||||
|
||||
|
||||
c = emalloc(1, sizeof(Client));
|
||||
c->win = w;
|
||||
@ -350,10 +369,11 @@ client_manage(Window w, XWindowAttributes *wa)
|
||||
c->geo.width = wa->width;
|
||||
c->geo.height = wa->height;
|
||||
c->tag = seltag;
|
||||
at.event_mask = PropertyChangeMask;
|
||||
|
||||
frame_create(c);
|
||||
client_size_hints(c);
|
||||
XSelectInput(dpy, c->win, PropertyChangeMask | StructureNotifyMask);
|
||||
XChangeWindowAttributes(dpy, c->win, CWEventMask, &at);
|
||||
mouse_grabbuttons(c, False);
|
||||
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
|
||||
for(t = clients; t && t->win != trans; t = t->next);
|
||||
|
||||
35
src/event.c
35
src/event.c
@ -137,6 +137,7 @@ configurerequest(XConfigureRequestEvent *ev)
|
||||
}
|
||||
else
|
||||
client_configure(c);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -147,7 +148,6 @@ configurerequest(XConfigureRequestEvent *ev)
|
||||
wc.border_width = ev->border_width;
|
||||
wc.sibling = ev->above;
|
||||
wc.stack_mode = ev->detail;
|
||||
|
||||
XConfigureWindow(dpy, ev->window, ev->value_mask, &wc);
|
||||
}
|
||||
XSync(dpy, False);
|
||||
@ -227,7 +227,7 @@ void
|
||||
focusin(XFocusChangeEvent *ev)
|
||||
{
|
||||
if(sel && ev->window != sel->win)
|
||||
XSetInputFocus(dpy, sel->win, RevertToPointerRoot, CurrentTime);
|
||||
client_focus(sel);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -282,7 +282,7 @@ keypress(XKeyPressedEvent *ev)
|
||||
* \param ev XMappingEvent pointer
|
||||
*/
|
||||
void
|
||||
mapnotify(XMappingEvent *ev)
|
||||
mappingnotify(XMappingEvent *ev)
|
||||
{
|
||||
if(ev->request == MappingKeyboard)
|
||||
grabkeys();
|
||||
@ -303,6 +303,7 @@ maprequest(XMapRequestEvent *ev)
|
||||
if(!client_gb_win(ev->window))
|
||||
client_manage(ev->window, &at);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -339,28 +340,6 @@ propertynotify(XPropertyEvent *ev)
|
||||
return;
|
||||
}
|
||||
|
||||
/** UnmapNotify handle event
|
||||
* \param ev XUnmapEvent pointer
|
||||
*/
|
||||
void
|
||||
unmapnotify(XUnmapEvent *ev)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if((c = client_gb_win(ev->window))
|
||||
&& ev->event == root
|
||||
&& ev->send_event
|
||||
&& getwinstate(c->win) == NormalState
|
||||
&& !c->hide)
|
||||
{
|
||||
XReparentWindow(dpy, c->win, root, 0, 0);
|
||||
client_unmanage(c);
|
||||
XSetErrorHandler(errorhandler);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Event handle function: execute every function
|
||||
* handle by event
|
||||
* \param ev Event
|
||||
@ -368,6 +347,8 @@ unmapnotify(XUnmapEvent *ev)
|
||||
void
|
||||
getevent(XEvent ev)
|
||||
{
|
||||
|
||||
|
||||
switch (ev.type)
|
||||
{
|
||||
case ButtonPress: buttonpress(&ev.xbutton); break;
|
||||
@ -378,10 +359,10 @@ getevent(XEvent ev)
|
||||
case FocusIn: focusin(&ev.xfocus); break;
|
||||
case KeyPress: keypress(&ev.xkey); break;
|
||||
case MapRequest: maprequest(&ev.xmaprequest); break;
|
||||
case MappingNotify: mapnotify(&ev.xmapping); break;
|
||||
case MappingNotify: mappingnotify(&ev.xmapping); break;
|
||||
case PropertyNotify: propertynotify(&ev.xproperty); break;
|
||||
case UnmapNotify: unmapnotify(&ev.xunmap); break;
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -41,9 +41,10 @@ frame_create(Client *c)
|
||||
{
|
||||
XSetWindowAttributes at;
|
||||
|
||||
at.background_pixel = conf.client.bordernormal;
|
||||
at.background_pixel = conf.client.bordernormal;
|
||||
at.background_pixmap = ParentRelative;
|
||||
at.override_redirect = True;
|
||||
at.bit_gravity = StaticGravity;
|
||||
at.event_mask = SubstructureRedirectMask|SubstructureNotifyMask
|
||||
|ExposureMask|VisibilityChangeMask
|
||||
|EnterWindowMask|LeaveWindowMask|FocusChangeMask
|
||||
|
||||
@ -45,6 +45,10 @@ errorhandler(Display *d, XErrorEvent *event)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Ignore focus change error */
|
||||
if(event->request_code == 42)
|
||||
return 0;
|
||||
|
||||
XGetErrorText(d, event->error_code, mess, 128);
|
||||
fprintf(stderr, "WMFS error: %s(%d) opcodes %d/%d\n resource #%lx\n", mess,
|
||||
event->error_code,
|
||||
|
||||
@ -151,10 +151,9 @@ void expose(XExposeEvent *ev);
|
||||
void focusin(XFocusChangeEvent *ev);
|
||||
void grabkeys(void);
|
||||
void keypress(XKeyPressedEvent *ev);
|
||||
void mapnotify(XMappingEvent *ev);
|
||||
void mappingnotify(XMappingEvent *ev);
|
||||
void maprequest(XMapRequestEvent *ev);
|
||||
void propertynotify(XPropertyEvent *ev);
|
||||
void unmapnotify(XUnmapEvent *ev);
|
||||
void getevent(XEvent ev);
|
||||
|
||||
/* mouse.c */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user