summaryrefslogtreecommitdiff
path: root/multimedia/fxtv/patches/patch-bf
blob: d8d8564b0b413845ca72400be0941302e1fb7518 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
$NetBSD: patch-bf,v 1.2 2011/07/05 03:27:22 dholland Exp $

Handle always-on-top.
Fix LP64 problems.

--- xutil.c.orig	1999-11-05 00:38:54.000000000 +0000
+++ xutil.c
@@ -44,6 +44,7 @@
 #include <X11/Shell.h>
 #include <X11/Xaw/Dialog.h>
 #include <X11/xpm.h>
+#include "glob.h"
 #include "tvdefines.h"
 #include "xutil.h"
 #include "app_rsrc.h"
@@ -63,6 +64,10 @@ void XawScrollbarSetThumb( Widget w, flo
 
 #define WM_BORDER_PAD 40
 
+#define _NET_WM_STATE_REMOVE	0
+#define _NET_WM_STATE_ADD	1
+#define _NET_WM_STATE_TOGGLE	2
+
 typedef struct {
     pid_t                  cmd_pid;
     TVUTIL_PIPE_END        end[3];
@@ -371,7 +376,7 @@ TV_BOOL XUTILPixmapLoad( char    *pixmap
         XFreePixmap( XtDisplay( wgt ), pixmap_depth1 );
         XFreeGC    ( XtDisplay( wgt ), gc );
         if ( pixmap_mask != NULL )
-            *pixmap_mask = NULL;
+            *pixmap_mask = 0;
     }
     else {
 
@@ -406,11 +411,12 @@ TV_BOOL XUTILPixmapLoad( char    *pixmap
         }
 
         *pixmap = pix_returned;
-        if ( pix_mask_returned )
+        if ( pix_mask_returned ) {
             if ( pixmap_mask != NULL )
                 *pixmap_mask = pix_mask_returned;
             else
                 XFreePixmap( XtDisplay( wgt ), pix_mask_returned );
+	}
     }
 
     if ( pixmap_path != NULL )
@@ -1543,3 +1549,46 @@ void XUTILDetermineFrameBufferVisual( Di
         }
     }
 }
+
+static void
+change_state (Display *d, Screen * screen, Window xwindow, int add,
+              Atom state1, Atom state2)
+{
+    XEvent xev;
+
+    xev.xclient.type = ClientMessage;
+    xev.xclient.serial = 0;
+    xev.xclient.send_event = True;
+    xev.xclient.display = d;
+    xev.xclient.window = xwindow;
+    xev.xclient.message_type = XInternAtom (d, "_NET_WM_STATE", FALSE);
+    xev.xclient.format = 32;
+    xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE;
+    xev.xclient.data.l[1] = state1;
+    xev.xclient.data.l[2] = state2;
+
+    XSendEvent (d, RootWindowOfScreen (screen), False,
+                SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+}
+
+void XUTILSetAlwaysOnTop(TV_BOOL status)
+{
+    Display  *d       = TVDISPLAY;
+    Screen   *screen  = XtScreen ( TVTOPLEVEL );
+    Window   win      = XtWindow ( TVTOPLEVEL );
+    static Atom xa_ABOVE = 0;
+    static Atom xa_BELOW = 0;
+        
+    if (!xa_ABOVE)
+    {
+        xa_ABOVE = XInternAtom (d, "_NET_WM_STATE_ABOVE", FALSE);
+        xa_BELOW = XInternAtom (d, "_NET_WM_STATE_BELOW", FALSE);
+    }
+
+    if (status) {
+        change_state (d, screen, win, FALSE, xa_ABOVE, xa_BELOW);
+        change_state (d, screen, win, TRUE,  xa_ABOVE, None);
+    } else {
+        change_state (d, screen, win, FALSE, xa_ABOVE, xa_BELOW);
+    }
+}