Send WINDOW_CLOSE instead of SESSION_END on Alt+F4 and handle that as a close signal

This commit is contained in:
K. Lange 2018-04-27 22:38:36 +09:00 committed by Kevin Lange
parent 8516e44a20
commit 037f055549
10 changed files with 40 additions and 2 deletions

View File

@ -112,6 +112,7 @@ int main(int argc, char * argv[]) {
}
}
break;
case YUTANI_MSG_WINDOW_CLOSE:
case YUTANI_MSG_SESSION_END:
playing = 0;
break;

View File

@ -1307,8 +1307,8 @@ static void handle_key_event(yutani_globals_t * yg, struct yutani_msg_key_event
(ke->event.modifiers & KEY_MOD_LEFT_ALT) &&
(ke->event.keycode == KEY_F4)) {
if (focused->z != YUTANI_ZORDER_BOTTOM && focused->z != YUTANI_ZORDER_TOP) {
yutani_msg_buildx_session_end_alloc(response);
yutani_msg_buildx_session_end(response);
yutani_msg_buildx_window_close_alloc(response);
yutani_msg_buildx_window_close(response, focused->wid);
pex_send(yg->server, focused->owner, response->size, (char *)response);
return;
}
@ -2455,6 +2455,13 @@ int main(int argc, char * argv[]) {
}
}
break;
case YUTANI_SPECIAL_REQUEST_PLEASE_CLOSE:
if (w) {
yutani_msg_buildx_window_close_alloc(response);
yutani_msg_buildx_window_close(response, w->wid);
pex_send(yg->server, w->owner, response->size, (char *)response);
}
break;
default:
TRACE("Unknown special request type: 0x%x", sr->request);
break;

View File

@ -93,6 +93,7 @@ int main (int argc, char ** argv) {
}
}
break;
case YUTANI_MSG_WINDOW_CLOSE:
case YUTANI_MSG_SESSION_END:
should_exit = 1;
break;

View File

@ -302,6 +302,7 @@ int main(int argc, char * argv[]) {
}
}
break;
case YUTANI_MSG_WINDOW_CLOSE:
case YUTANI_MSG_SESSION_END:
playing = 0;
break;

View File

@ -147,6 +147,7 @@ int main (int argc, char ** argv) {
}
}
break;
case YUTANI_MSG_WINDOW_CLOSE:
case YUTANI_MSG_SESSION_END:
should_exit = 1;
break;

View File

@ -1480,6 +1480,15 @@ void * handle_incoming(void) {
}
}
break;
case YUTANI_MSG_WINDOW_CLOSE:
{
struct yutani_msg_window_close * wc = (void*)m->data;
if (wc->wid == window->wid) {
kill(child_pid, SIGKILL);
exit_application = 1;
}
}
break;
case YUTANI_MSG_SESSION_END:
{
kill(child_pid, SIGKILL);

View File

@ -174,6 +174,7 @@ int main (int argc, char ** argv) {
(int)wr->bufid);
}
break;
case YUTANI_MSG_WINDOW_CLOSE:
case YUTANI_MSG_SESSION_END:
should_exit = 1;
break;

View File

@ -404,6 +404,7 @@ typedef struct yutani_window {
* Special one-off single-shot request messages.
*/
#define YUTANI_SPECIAL_REQUEST_MAXIMIZE 1
#define YUTANI_SPECIAL_REQUEST_PLEASE_CLOSE 2
typedef struct {
int x;

View File

@ -135,6 +135,13 @@ static void _decor_start_maximize(struct MenuEntry * self) {
yutani_focus_window(_decor_menu_owner_window->ctx, _decor_menu_owner_window->wid);
}
static void _decor_close(struct MenuEntry * self) {
if (!_decor_menu_owner_window)
return;
yutani_special_request(_decor_menu_owner_window->ctx, _decor_menu_owner_window, YUTANI_SPECIAL_REQUEST_PLEASE_CLOSE);
}
yutani_window_t * decor_show_default_menu(yutani_window_t * window, int y, int x) {
if (_decor_menu->window) return NULL;
_decor_menu_owner_window = window;
@ -150,6 +157,8 @@ void init_decorations() {
_decor_menu = menu_create();
menu_insert(_decor_menu, menu_create_normal(NULL, NULL, "Maximize", _decor_start_maximize));
menu_insert(_decor_menu, menu_create_normal(NULL, NULL, "Move", _decor_start_move));
menu_insert(_decor_menu, menu_create_separator());
menu_insert(_decor_menu, menu_create_normal(NULL, NULL, "Close", _decor_close));
if (!theme || !strcmp(theme, "simple")) {
initialize_simple();

View File

@ -741,6 +741,13 @@ void yutani_special_request(yutani_t * yctx, yutani_window_t * window, uint32_t
yutani_msg_send(yctx, m);
}
void yutani_special_request_wid(yutani_t * yctx, yutani_wid_t wid, uint32_t request) {
/* For working with other applications' windows */
yutani_msg_buildx_special_request_alloc(m);
yutani_msg_buildx_special_request(m, wid, request);
yutani_msg_send(yctx, m);
}
gfx_context_t * init_graphics_yutani(yutani_window_t * window) {
gfx_context_t * out = malloc(sizeof(gfx_context_t));
out->width = window->width;