mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-15 21:31:12 +00:00
Quit when close button is pressed
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../video.h"
|
#include "../video.h"
|
||||||
|
#include "../global.h"
|
||||||
|
#include "../loop.h"
|
||||||
#include "egl.h"
|
#include "egl.h"
|
||||||
#include "ffmpeg.h"
|
#include "ffmpeg.h"
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@
|
|||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
#define DECODER_BUFFER_SIZE 92*1024
|
#define DECODER_BUFFER_SIZE 92*1024
|
||||||
|
|
||||||
@@ -35,6 +38,20 @@ static char* ffmpeg_buffer = NULL;
|
|||||||
|
|
||||||
static Display *display;
|
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) {
|
void x11_setup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags) {
|
||||||
int avc_flags = SLICE_THREADING;
|
int avc_flags = SLICE_THREADING;
|
||||||
if (drFlags & FORCE_HARDWARE_ACCELERATION)
|
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);
|
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);
|
egl_init(display, window, width, height);
|
||||||
|
loop_add_fd(ConnectionNumber(display), x11_handler, POLLIN | POLLERR | POLLHUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void x11_cleanup() {
|
void x11_cleanup() {
|
||||||
|
|||||||
Reference in New Issue
Block a user