aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-28 16:50:35 +0200
committerdec05eba <dec05eba@protonmail.com>2022-03-28 16:55:37 +0200
commitbbd2335bc32e4e814277d4466756b300c3b3bd74 (patch)
tree644f7fcd5f48a29a1ceec80389d3abb47a2e221f
parent8e23c088ceebd1308e0f32b584ae503495895b05 (diff)
Attempt to fix focus in video player by waiting until video loads, fix losing focus when opening save window
-rw-r--r--src/QuickMedia.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 4bdf4d6..da76335 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -633,7 +633,7 @@ namespace QuickMedia {
static mgl::vec2i get_focused_monitor_center(Display *disp, mgl::vec2i &monitor_size) {
int screen = DefaultScreen(disp);
monitor_size.x = DisplayWidth(disp, screen);
- monitor_size.y = DisplayWidth(disp, screen);
+ monitor_size.y = DisplayHeight(disp, screen);
int screen_center_x = monitor_size.x / 2;
int screen_center_y = monitor_size.y / 2;
@@ -2957,7 +2957,9 @@ namespace QuickMedia {
return;
XRaiseWindow(disp, video_player_window);
- XSetInputFocus(disp, video_player_window, RevertToPointerRoot, CurrentTime);
+ XSetInputFocus(disp, video_player_window, RevertToParent, CurrentTime);
+ XSync(disp, False);
+ XFlush(disp);
}
void Program::show_video_player_window(mgl::WindowHandle video_player_window) {
@@ -3124,7 +3126,7 @@ namespace QuickMedia {
mgl::WindowHandle video_player_window = None;
auto on_window_create = [&](mgl::WindowHandle _video_player_window) mutable {
video_player_window = _video_player_window;
- XSelectInput(disp, video_player_window, KeyPressMask | PointerMotionMask | FocusChangeMask);
+ XSelectInput(disp, video_player_window, KeyPressMask | PointerMotionMask | FocusChangeMask | StructureNotifyMask);
redirect_focus_to_video_player_window(video_player_window);
XSync(disp, False);
@@ -3348,10 +3350,13 @@ namespace QuickMedia {
time_watched_timer.restart();
video_loaded = true;
update_time_pos = true;
+ update_window_focus = true;
} else if(strcmp(event_name, "file-loaded") == 0) {
video_loaded = true;
+ update_window_focus = true;
} else if(strcmp(event_name, "video-reconfig") == 0 || strcmp(event_name, "audio-reconfig") == 0) {
video_loaded = true;
+ update_window_focus = true;
} else if(strcmp(event_name, "seek") == 0) {
update_time_pos = true;
} else if(strcmp(event_name, "fullscreen") == 0 && args.size() == 1) {
@@ -3411,6 +3416,10 @@ namespace QuickMedia {
}
handle_x11_events();
+ if(video_player_window && XCheckTypedWindowEvent(disp, video_player_window, MapNotify, &xev)) {
+ update_window_focus = true;
+ }
+
if(video_player_window && XCheckTypedWindowEvent(disp, video_player_window, FocusIn, &xev)) {}
if(video_player_window && XCheckTypedWindowEvent(disp, video_player_window, FocusOut, &xev)) {
@@ -4835,7 +4844,7 @@ namespace QuickMedia {
redraw = false;
comment_input.set_max_width(window_size.x - (logo_padding_x + logo_size.x + chat_input_padding_x + logo_padding_x));
- comment_input.set_position(vec2f_floor(logo_padding_x + logo_size.x + chat_input_padding_x, chat_input_padding_y - 5.0f * get_config().scale));
+ comment_input.set_position(vec2f_floor(logo_padding_x + logo_size.x + chat_input_padding_x, chat_input_padding_y));
const float body_width = window_size.x;