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