Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make meh quit when the window manager closes the window #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void key_prev(){
}
}
}
void key_quit(){
void meh_quit(){
exit(EXIT_SUCCESS);
}

Expand Down
2 changes: 1 addition & 1 deletion src/meh.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void backend_run();
void key_reload();
void key_next();
void key_prev();
void key_quit();
void meh_quit();
void key_action();

/* callbacks from backend */
Expand Down
10 changes: 8 additions & 2 deletions src/xlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void handlekeypress(XEvent *event){
switch(key){
case XK_Escape:
case XK_q:
key_quit();
meh_quit();
break;
case XK_Return:
key_action();
Expand Down Expand Up @@ -225,8 +225,14 @@ void handlekeypress(XEvent *event){


void handleevent(XEvent *event){
Atom closed = XInternAtom(display, "WM_DELETE_WINDOW", True);
XSetWMProtocols(display, window, &closed, 1);

switch(event->type){
/* Might not get ConfigureNotify, for example if there's no window manager */
case ClientMessage:
meh_quit();
break;
case MapNotify:
if (!width || !height)
{
Expand All @@ -235,7 +241,7 @@ void handleevent(XEvent *event){
width = attr.width;
height = attr.height;
}
break;
break;
case ConfigureNotify:
if(width != event->xconfigure.width || height != event->xconfigure.height){
width = event->xconfigure.width;
Expand Down