mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-02-16 10:30:47 +00:00
Quit when close button is pressed
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
|
||||
#include "../video.h"
|
||||
#include "../global.h"
|
||||
#include "../loop.h"
|
||||
#include "egl.h"
|
||||
#include "ffmpeg.h"
|
||||
|
||||
@@ -28,6 +30,7 @@
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <poll.h>
|
||||
|
||||
#define DECODER_BUFFER_SIZE 92*1024
|
||||
|
||||
@@ -35,6 +38,20 @@ static char* ffmpeg_buffer = NULL;
|
||||
|
||||
static Display *display;
|
||||
|
||||
static Atom wm_deletemessage;
|
||||
|
||||
static int x11_handler(int fd) {
|
||||
XEvent event;
|
||||
XNextEvent(display, &event);
|
||||
switch (event.type) {
|
||||
case ClientMessage:
|
||||
if (event.xclient.data.l[0] == wm_deletemessage)
|
||||
quit();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void x11_setup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags) {
|
||||
int avc_flags = SLICE_THREADING;
|
||||
if (drFlags & FORCE_HARDWARE_ACCELERATION)
|
||||
@@ -79,7 +96,11 @@ void x11_setup(int videoFormat, int width, int height, int redrawRate, void* con
|
||||
XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
|
||||
}
|
||||
|
||||
wm_deletemessage = XInternAtom(display, "WM_DELETE_WINDOW", False);
|
||||
XSetWMProtocols(display, window, &wm_deletemessage, 1);
|
||||
|
||||
egl_init(display, window, width, height);
|
||||
loop_add_fd(ConnectionNumber(display), x11_handler, POLLIN | POLLERR | POLLHUP);
|
||||
}
|
||||
|
||||
void x11_cleanup() {
|
||||
|
||||
Reference in New Issue
Block a user