aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index e2b4a2b..6cf6875 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -798,6 +798,42 @@ namespace QuickMedia {
return -1;
}
+ enum class WindowFullscreenState {
+ UNSET,
+ SET,
+ TOGGLE
+ };
+
+ static bool window_set_fullscreen(Display *display, Window window, WindowFullscreenState state) {
+ 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 fullscreen window. The window manager doesn't support fullscreening windows.\n");
+ return false;
+ }
+
+ XEvent xev;
+ xev.type = ClientMessage;
+ xev.xclient.window = window;
+ xev.xclient.message_type = wm_state_atom;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = (int)state;
+ xev.xclient.data.l[1] = wm_state_fullscreen_atom;
+ xev.xclient.data.l[2] = 0;
+ xev.xclient.data.l[3] = 1;
+ xev.xclient.data.l[4] = 0;
+
+ if(!XSendEvent(display, XDefaultRootWindow(display), 0, SubstructureRedirectMask | SubstructureNotifyMask, &xev)) {
+ fprintf(stderr, "Failed to fullscreen window\n");
+ return false;
+ }
+
+ XFlush(display);
+ return true;
+ }
+
+#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
+
void Program::video_content_page() {
search_bar->onTextUpdateCallback = nullptr;
search_bar->onTextSubmitCallback = nullptr;
@@ -918,6 +954,8 @@ namespace QuickMedia {
KeySym pressed_keysym = XKeycodeToKeysym(disp, xev.xkey.keycode, 0);
if(pressed_keysym == XK_Escape) {
current_page = previous_page;
+ } else if(pressed_keysym == XK_f && CLEANMASK(xev.xkey.state) == ControlMask) {
+ window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE);
}
}
@@ -965,6 +1003,7 @@ namespace QuickMedia {
}
//window.setMouseCursorVisible(true);
+ window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET);
}
enum class TrackMediaType {
@@ -1055,7 +1094,7 @@ namespace QuickMedia {
BodyItem *selected_item = body->get_selected();
if(selected_item) {
if(track_media(TrackMediaType::HTML, content_title, selected_item->title, content_url) == 0) {
- show_notification("Media tracker", "You are now tracking \"" + content_title + "\" after \"" + selected_item->title + "\"");
+ show_notification("Media tracker", "You are now tracking \"" + content_title + "\" after \"" + selected_item->title + "\"", Urgency::LOW);
} else {
show_notification("Media tracker", "Failed to track media \"" + content_title + "\", chapter: \"" + selected_item->title + "\"", Urgency::CRITICAL);
}