aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-10 16:15:59 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-10 16:15:59 +0100
commit2b29acfb9f70cb7aff7d5da1f5fc59ee319e3606 (patch)
tree7f5f0b5f97268779831370d104f2b51ef1482a3a
parent47cd79054bb5033eba5776b1107537c8db30984c (diff)
Focus video player when focusing the main window
-rw-r--r--TODO3
-rw-r--r--src/QuickMedia.cpp39
-rw-r--r--src/plugins/Youtube.cpp4
-rw-r--r--src/plugins/youtube/YoutubeMediaProxy.cpp2
4 files changed, 33 insertions, 15 deletions
diff --git a/TODO b/TODO
index e8c962a..ef9511d 100644
--- a/TODO
+++ b/TODO
@@ -222,4 +222,5 @@ Ctrl+R set chapter to finished reading in chapters page.
Zero clear password memory after use.
Periodically cleanup old cache files (especially manga images, thumbnails and media). Maybe have a file that says when we last checked for old files,
and if its X days old then check and remove old files again and update the file.
-Render watch progress in youtube. \ No newline at end of file
+Render watch progress in youtube.
+Readd youtube watch progress which seems to be broken because of frozen download? \ No newline at end of file
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index cf7d058..6dda729 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2906,6 +2906,17 @@ namespace QuickMedia {
|| is_soundcloud(url);
}
+ static void show_video_player_window(Display *disp, Window video_player_window, Window window) {
+ XMapWindow(disp, video_player_window);
+ XSync(disp, False);
+
+ Window focused_window = None;
+ int dummy;
+ XGetInputFocus(disp, &focused_window, &dummy);
+ if(focused_window == window)
+ XSetInputFocus(disp, video_player_window, RevertToParent, CurrentTime);
+ }
+
void Program::video_page_download_video(const std::string &url, mgl::WindowHandle video_player_window) {
bool separate_audio_option = url_should_download_with_youtube_dl(url);
std::string video_id;
@@ -2939,10 +2950,8 @@ namespace QuickMedia {
tabs.push_back(Tab{ std::move(body), std::move(options_page), nullptr });
bool selected = page_loop(tabs);
- if(video_player_window) {
- XMapWindow(disp, video_player_window);
- XSync(disp, False);
- }
+ if(video_player_window)
+ show_video_player_window(disp, video_player_window, window.get_system_handle());
if(!selected)
return;
@@ -3069,6 +3078,12 @@ namespace QuickMedia {
if(!subtitle_data.url.empty())
video_player->add_subtitle(subtitle_data.url, subtitle_data.title, "eng");
+ Window focused_window = None;
+ int dummy;
+ XGetInputFocus(disp, &focused_window, &dummy);
+ if(focused_window == window.get_system_handle())
+ XSetInputFocus(disp, video_player_window, RevertToParent, CurrentTime);
+
update_time_pos = true;
};
@@ -3377,7 +3392,9 @@ namespace QuickMedia {
while (current_page == PageType::VIDEO_CONTENT && window.is_open() && !go_to_previous_page) {
while (window.poll_event(event)) {
common_event_handler(event);
- if(event.type == mgl::Event::Resized) {
+ if(event.type == mgl::Event::GainedFocus && video_player_window) {
+ XSetInputFocus(disp, video_player_window, RevertToParent, CurrentTime);
+ } else if(event.type == mgl::Event::Resized) {
window_size.x = event.size.width;
window_size.y = event.size.height;
} else if(event.type == mgl::Event::KeyPressed && (event.key.code == mgl::Keyboard::Escape || event.key.code == mgl::Keyboard::Q || event.key.code == mgl::Keyboard::Backspace)) {
@@ -3446,8 +3463,7 @@ namespace QuickMedia {
});
if(task_result == TaskResult::CANCEL) {
- XMapWindow(disp, video_player_window);
- XSync(disp, False);
+ show_video_player_window(disp, video_player_window, window.get_system_handle());
cancelled = true;
}
}
@@ -3463,8 +3479,7 @@ namespace QuickMedia {
});
if(related_pages_result == TaskResult::FALSE) {
- XMapWindow(disp, video_player_window);
- XSync(disp, False);
+ show_video_player_window(disp, video_player_window, window.get_system_handle());
show_notification("QuickMedia", "Failed to get related pages", Urgency::CRITICAL);
} else if(related_pages_result == TaskResult::TRUE && !related_pages.empty()) {
video_page->set_watch_progress(video_time_pos, video_duration);
@@ -3498,12 +3513,10 @@ namespace QuickMedia {
current_page = PageType::VIDEO_CONTENT;
load_video_error_check(resume_start_time > 0.1 ? std::to_string((int)resume_start_time) : "");
} else {
- XMapWindow(disp, video_player_window);
- XSync(disp, False);
+ show_video_player_window(disp, video_player_window, window.get_system_handle());
}
} else {
- XMapWindow(disp, video_player_window);
- XSync(disp, False);
+ show_video_player_window(disp, video_player_window, window.get_system_handle());
}
}
} else if(pressed_keysym == XK_c && pressing_ctrl) {
diff --git a/src/plugins/Youtube.cpp b/src/plugins/Youtube.cpp
index 2d92cd8..df79701 100644
--- a/src/plugins/Youtube.cpp
+++ b/src/plugins/Youtube.cpp
@@ -1860,6 +1860,7 @@ namespace QuickMedia {
}
std::string YoutubeVideoPage::get_url_timestamp() {
+ #if 0
if(!timestamp.empty())
return timestamp;
@@ -1881,6 +1882,9 @@ namespace QuickMedia {
return "";
else
return std::to_string(it->second.time_pos_sec);
+ #else
+ return timestamp;
+ #endif
}
BodyItems YoutubeVideoPage::get_related_media(const std::string &url) {
diff --git a/src/plugins/youtube/YoutubeMediaProxy.cpp b/src/plugins/youtube/YoutubeMediaProxy.cpp
index 0c0d8dd..e51e3d9 100644
--- a/src/plugins/youtube/YoutubeMediaProxy.cpp
+++ b/src/plugins/youtube/YoutubeMediaProxy.cpp
@@ -447,7 +447,7 @@ namespace QuickMedia {
return Error::OK;
}
- const ssize_t num_bytes_written = write_all_blocking(client_fd, buffer_start + buffer_offset, num_bytes_to_write);
+ const ssize_t num_bytes_written = write_all(client_fd, buffer_start + buffer_offset, num_bytes_to_write);
if(num_bytes_written == -1) {
const int err = errno;
if(err == EAGAIN || err == EWOULDBLOCK) {