summaryrefslogtreecommitdiff
path: root/graphics/fxtv/patches/patch-bf
blob: c7f7d6bcf9dcf79aec5760d888b036d4ace11203 (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
$NetBSD: patch-bf,v 1.1 2003/09/28 15:58:34 jmmv Exp $

--- xutil.c.orig	1999-11-05 01:38:54.000000000 +0100
+++ 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];
@@ -1543,3 +1548,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);
+    }
+}