aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 873bd31..92eccdc 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2165,6 +2165,37 @@ namespace QuickMedia {
return true;
}
+ static bool window_is_fullscreen(Display *display, Window window) {
+ Atom wm_state_atom = XInternAtom(display, "_NET_WM_STATE", False);
+ Atom wm_state_fullscreen_atom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False);
+ if(wm_state_atom == False || wm_state_fullscreen_atom == False) {
+ fprintf(stderr, "Failed to get window atoms\n");
+ return false;
+ }
+
+ Atom type;
+ int format = 0;
+ unsigned long num_items = 0;
+ unsigned long bytes_after = 0;
+ unsigned char *properties = nullptr;
+ if(XGetWindowProperty(display, window, wm_state_atom, 0, 1024, False, XA_ATOM, &type, &format, &num_items, &bytes_after, &properties) != Success) {
+ fprintf(stderr, "Failed to get window wm state property\n");
+ return false;
+ }
+
+ bool is_fullscreen = false;
+ Atom *atoms = (Atom*)properties;
+ for(unsigned long i = 0; i < num_items; ++i) {
+ if(atoms[i] == wm_state_fullscreen_atom) {
+ is_fullscreen = true;
+ break;
+ }
+ }
+
+ XFree(properties);
+ return is_fullscreen;
+ }
+
static const char *useragent_str = "user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36";
static int accumulate_string_limit_head(char *data, int size, void *userdata) {
@@ -2442,7 +2473,13 @@ namespace QuickMedia {
window.setView(sf::View(visible_area));
} else if(event.type == sf::Event::KeyPressed && (event.key.code == sf::Keyboard::Escape || event.key.code == sf::Keyboard::Q || event.key.code == sf::Keyboard::Backspace)) {
// To be able to close the video player while the video is loading
- current_page = previous_page;
+ if(window_is_fullscreen(disp, window.getSystemHandle())) {
+ window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET);
+ } else {
+ current_page = previous_page;
+ }
+ } else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::F && event.key.control) {
+ window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE);
} else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::C && event.key.control) {
save_video_url_to_clipboard();
} else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::S && event.key.control) {
@@ -2458,8 +2495,12 @@ namespace QuickMedia {
#pragma GCC diagnostic pop
bool pressing_ctrl = (CLEANMASK(xev.xkey.state) == ControlMask);
if(pressed_keysym == XK_Escape || pressed_keysym == XK_q || pressed_keysym == XK_BackSpace) {
- current_page = previous_page;
- break;
+ if(window_is_fullscreen(disp, window.getSystemHandle())) {
+ window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET);
+ } else {
+ current_page = previous_page;
+ break;
+ }
} else if(pressed_keysym == XK_f && pressing_ctrl) {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE);
} else if(pressed_keysym == XK_s && pressing_ctrl) {