]> uap-core.de Git - uwplayer.git/commitdiff
click in the video area can move the window now
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 23 Jan 2022 07:55:59 +0000 (08:55 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 23 Jan 2022 07:55:59 +0000 (08:55 +0100)
application/window.c
application/window.h

index d14861e867daac86ace84096f031d953ef2c7d5c..c0110848dbe83f6b3ba1f1fc9085c8178fc19ba2 100644 (file)
@@ -181,20 +181,44 @@ void WindowHandlePlayerEvent(MainWindow *win, XEvent *event) {
     
     if(etype == MotionNotify) {
         Time cur_motion_time = event->xmotion.time;
-        int x = event->xmotion.x;
-        int y = event->xmotion.y;
+        int x = event->xmotion.x_root;
+        int y = event->xmotion.y_root;
         if(win->cursorhidden && cur_motion_time - win->player_event_time < IGNORE_MOTION_THRESHOLD_MS) {
-            int diff_x = abs(x - win->mouse_x_orig);
-            int diff_y = abs(y - win->mouse_y_orig);
+            int diff_x = abs(x - win->mouse_x);
+            int diff_y = abs(y - win->mouse_y);
             if(diff_x > MOTION_POS_THRESHOLD_PIX || diff_y > MOTION_POS_THRESHOLD_PIX) {
                 WindowShowPlayerCursor(win);
             }
         } else {
-            win->mouse_x_orig = x;
-            win->mouse_y_orig = y;
+            win->mouse_x = x;
+            win->mouse_y = y;
         }
         win->player_event_time = cur_motion_time;
         win->motion_playback_time = win->player->playback_time;
+        
+        
+        
+        if(win->pwbuttonpressed) {
+            Display *dp = XtDisplay(win->window);
+                
+            XtUngrabPointer(win->player_widget, CurrentTime);
+
+            XEvent xev;
+            memset(&xev, 0, sizeof(xev));
+            xev.type = ClientMessage;
+            xev.xclient.message_type = XInternAtom(dp, "_NET_WM_MOVERESIZE", False);
+            xev.xclient.window = XtWindow(win->window);
+            xev.xclient.format = 32;
+            xev.xclient.data.l[0] = x;
+            xev.xclient.data.l[1] = y;
+            xev.xclient.data.l[2] = 8; // _NET_WM_MOVERESIZE_MOVE
+            xev.xclient.data.l[3] = 1; // button1
+            xev.xclient.data.l[4] = 1; // source indication
+
+            XSendEvent(dp, DefaultRootWindow(dp), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+
+            win->pwbuttonpressed = FALSE;  
+        }
     } else if(etype == ButtonPress) {
         Time t = event->xbutton.time;
         if(t - win->button_press_time < DOUBLE_CLICK_TIME_MS) {
@@ -204,8 +228,10 @@ void WindowHandlePlayerEvent(MainWindow *win, XEvent *event) {
         } else {
             win->button_press_time = t;
         }
+        win->pwbuttonpressed = 1;
     } else if(etype == ButtonRelease) {
         win->player_event_time = event->xbutton.time;
+        win->pwbuttonpressed = FALSE;
     }
 }
 
index b0f9c6430b6fbf99972a4f1c1a3dbea9385f360a..05385cc552a364748bf82c5d526f23a58faeeede 100644 (file)
@@ -57,6 +57,7 @@ typedef struct MainWindow {
     bool mbvisible;
     bool cursorhidden;
     bool buttongrab;
+    bool pwbuttonpressed;
     
     Widget playRepeatTrackButton;
     Widget playRepeatListButton;
@@ -67,8 +68,6 @@ typedef struct MainWindow {
     double motion_playback_time;
     int mouse_x;
     int mouse_y;
-    int mouse_x_orig;
-    int mouse_y_orig;
     
     Boolean repeatTrack;
     Boolean repeatList;