aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Kinnunen <fluxgen@fluxbox.org>2008-10-16 20:38:42 (GMT)
committerHenrik Kinnunen <fluxgen@fluxbox.org>2008-10-16 20:38:42 (GMT)
commitb9466363b3a231ceb96ae757073f1b5efba5fc94 (patch)
tree363bb79ba2987726c355016ee2611c0f104e3ba3
parent715dc907ae6a4ca65c492f94ce6379f59eff5157 (diff)
downloadfbpager-b9466363b3a231ceb96ae757073f1b5efba5fc94.zip
fbpager-b9466363b3a231ceb96ae757073f1b5efba5fc94.tar.bz2
Fixed so Extended Window Manager Hints actually work, needs more work though.
-rw-r--r--ChangeLog9
-rw-r--r--src/ClientHandler.hh3
-rw-r--r--src/Ewmh.cc118
-rw-r--r--src/Ewmh.hh3
-rw-r--r--src/FbPager.cc208
-rw-r--r--src/FbPager.hh23
-rw-r--r--src/FbTk/Makefile.in1
-rw-r--r--src/Makefile.am4
-rw-r--r--src/Pager.hh8
-rw-r--r--src/PropertyTools.cc71
-rw-r--r--src/PropertyTools.hh38
-rw-r--r--src/Workspace.cc48
-rw-r--r--src/Workspace.hh20
-rw-r--r--src/main.cc4
14 files changed, 387 insertions, 171 deletions
diff --git a/ChangeLog b/ChangeLog
index 14cacef..26e28e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,12 @@
1* format ( year-month-day) 1* format ( year-month-day)
2----- Version 0.1.6
3* 2008-10-16:
4 * Fixed so Extended Window Manager Hints actually work.
2---- Version 0.1.5 5---- Version 0.1.5
3* 2007-10-17: 6* 2007-10-17:
4 * Fixed gcc compile fix 7 * Fixed gcc compile fix
5 * Added _NET_DESKTOP_LAYOUT support 8 * Added _NET_DESKTOP_LAYOUT support
6 Which allows the WM to know the desktop layout displayed by 9 Which allows the WM to know the desktop layout displayed by
7 the pager. 10 the pager.
8---- Version 0.1.4 11---- Version 0.1.4
9* 2004-03-24: 12* 2004-03-24:
@@ -35,13 +38,13 @@
35 * Added -sr argument 38 * Added -sr argument
36 This will show the resources and value and exit fbpager 39 This will show the resources and value and exit fbpager
37 main.cc, FbPager.hh/cc 40 main.cc, FbPager.hh/cc
38 * alot of new resources and updates, check README (Thanks Mathias Gumz) 41 * alot of new resources and updates, check README (Thanks Mathias Gumz)
39* 2004-02-27: 42* 2004-02-27:
40 * Fixed mouse gestures (Thanks Mathias Gumz) 43 * Fixed mouse gestures (Thanks Mathias Gumz)
41 FbPager.hh/cc 44 FbPager.hh/cc
42 * Added fbpager.nextWorkspaceButton and fbpager.prevWorkspaceButton 45 * Added fbpager.nextWorkspaceButton and fbpager.prevWorkspaceButton
43 (Thanks Mathias Gumz) 46 (Thanks Mathias Gumz)
44 Use these to define which button combination to move to next/prev 47 Use these to define which button combination to move to next/prev
45 workspace 48 workspace
46 FbPager.cc 49 FbPager.cc
47 * Added fbpager.exitButton resource (Thanks Mathias Gumz) 50 * Added fbpager.exitButton resource (Thanks Mathias Gumz)
diff --git a/src/ClientHandler.hh b/src/ClientHandler.hh
index 1ec128d..914fb34 100644
--- a/src/ClientHandler.hh
+++ b/src/ClientHandler.hh
@@ -1,6 +1,6 @@
1// ClientHandler.hh for FbPager 1// ClientHandler.hh for FbPager
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation 6// to deal in the Software without restriction, including without limitation
@@ -59,6 +59,7 @@ public:
59 Orientation orientation, 59 Orientation orientation,
60 Corner starting_corner, 60 Corner starting_corner,
61 unsigned int columns, unsigned int rows) = 0; 61 unsigned int columns, unsigned int rows) = 0;
62 virtual bool propertyNotify( Pager &pager, XPropertyEvent &event) = 0;
62}; 63};
63 64
64} // end namespace FbPager 65} // end namespace FbPager
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 87e55bf..9f89f08 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -1,6 +1,6 @@
1// Ewmh.cc for FbPager 1// Ewmh.cc for FbPager
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation 6// to deal in the Software without restriction, including without limitation
@@ -27,6 +27,7 @@
27#include "FbTk/App.hh" 27#include "FbTk/App.hh"
28#include "FbTk/FbWindow.hh" 28#include "FbTk/FbWindow.hh"
29#include "FbRootWindow.hh" 29#include "FbRootWindow.hh"
30#include "PropertyTools.hh"
30 31
31#include <X11/Xatom.h> 32#include <X11/Xatom.h>
32 33
@@ -36,7 +37,41 @@
36#include <unistd.h> 37#include <unistd.h>
37#include <memory> 38#include <memory>
38 39
40
39using namespace std; 41using namespace std;
42using namespace PropertyTools;
43
44
45struct PropT {
46 PropT(unsigned char *data, unsigned int num):data(data), num(num) { }
47 ~PropT() {
48 if (data != 0)
49 XFree(data);
50 }
51 unsigned char *data;
52 unsigned int num;
53};
54
55
56typedef std::auto_ptr<PropT> PropTPtr;
57
58PropT *property(const FbTk::FbWindow &win, Atom atom,
59 Atom type, unsigned int num) {
60 Atom ret_type;
61 int fmt;
62 unsigned long nitems, bytes_after;
63 unsigned char *data = 0;
64 win.property(atom,
65 0, num,
66 False,
67 type,
68 &ret_type, &fmt,
69 &nitems,
70 &bytes_after,
71 &data);
72 return new PropT(data, nitems);
73
74}
40 75
41namespace FbPager { 76namespace FbPager {
42 77
@@ -56,7 +91,7 @@ public:
56 wm_pid = XInternAtom(disp, "_NET_WM_PID", False); 91 wm_pid = XInternAtom(disp, "_NET_WM_PID", False);
57 wm_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False); 92 wm_type = XInternAtom(disp, "_NET_WM_WINDOW_TYPE", False);
58 type_dock = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DOCK", False); 93 type_dock = XInternAtom(disp, "_NET_WM_WINDOW_TYPE_DOCK", False);
59 number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False); 94 number_of_desktops = XInternAtom(disp, "_NET_NUMBER_OF_DESKTOPS", False);
60 current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False); 95 current_desktop = XInternAtom(disp, "_NET_CURRENT_DESKTOP", False);
61 clientlist = XInternAtom(disp, "_NET_CLIENT_LIST", False); 96 clientlist = XInternAtom(disp, "_NET_CLIENT_LIST", False);
62 moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False); 97 moveresize_window = XInternAtom(disp, "_NET_MOVERESIZE_WINDOW", False);
@@ -64,11 +99,11 @@ public:
64 close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False); 99 close_window = XInternAtom(disp, "_NET_CLOSE_WINDOW", False);
65 desktop_layout = XInternAtom(disp, "_NET_DESKTOP_LAYOUT", False); 100 desktop_layout = XInternAtom(disp, "_NET_DESKTOP_LAYOUT", False);
66 } 101 }
67 Atom state_skip_pager, state_skip_taskbar, state_sticky, 102 Atom state_skip_pager, state_skip_taskbar, state_sticky,
68 state_hidden, state_shaded, state_above, state_below; 103 state_hidden, state_shaded, state_above, state_below;
69 Atom wm_desktop, wm_state, wm_pid, wm_type; 104 Atom wm_desktop, wm_state, wm_pid, wm_type;
70 Atom type_dock; 105 Atom type_dock;
71 Atom number_of_desktops, current_desktop; 106 Atom number_of_desktops, current_desktop;
72 Atom clientlist; 107 Atom clientlist;
73 Atom moveresize_window; 108 Atom moveresize_window;
74 Atom active_window; 109 Atom active_window;
@@ -106,11 +141,11 @@ void Ewmh::setDesktopLayout(FbTk::FbWindow &root,
106 (unsigned char*)data, 4 ); 141 (unsigned char*)data, 4 );
107} 142}
108 143
109void Ewmh::moveResize(FbTk::FbWindow &win) { 144void Ewmh::moveResize(FbTk::FbWindow &win) {
110 145
111 // We can't do this yet, there is a bug in fluxbox 0.9.8 146 // We can't do this yet, there is a bug in fluxbox 0.9.8
112 // and this makes it crash (it's fixed in cvs though) 147 // and this makes it crash (it's fixed in cvs though)
113 /* 148 /*
114 Display *disp = FbTk::App::instance()->display(); 149 Display *disp = FbTk::App::instance()->display();
115 XEvent event; 150 XEvent event;
116 event.xclient.display = disp; 151 event.xclient.display = disp;
@@ -144,9 +179,44 @@ void Ewmh::closeWindow(FbTk::FbWindow &win) {
144 XSendEvent(disp, RootWindow(disp, DefaultScreen(disp)), False, SubstructureNotifyMask, &event); 179 XSendEvent(disp, RootWindow(disp, DefaultScreen(disp)), False, SubstructureNotifyMask, &event);
145} 180}
146 181
182bool Ewmh::propertyNotify(Pager &pager, XPropertyEvent &event) try {
183 if (event.window != DefaultRootWindow(FbTk::App::instance()->display())) {
184 return false;
185 }
186 if (event.atom == m_data->current_desktop) {
187 pager.setCurrentWorkspace(getIntProperty(event.window, event.atom));
188 } else if (event.atom == m_data->number_of_desktops) {
189 pager.updateWorkspaceCount(getIntProperty(event.window, event.atom));
190 } else if (event.atom == m_data->active_window) {
191 pager.setFocusedWindow(getWinProperty(event.window, event.atom));
192 } else if (event.atom == m_data->clientlist) {
193 vector<Window> windows;
194 getWinArrayProperty(DefaultRootWindow(FbTk::App::instance()->display()), event.atom, windows);
195 std::vector< pair<Window, unsigned int > > wins_workspaces;
196 for ( unsigned int win = 0; win < windows.size(); ++win ) {
197 wins_workspaces.
198 push_back( std::make_pair(windows[win],
199 getIntProperty(windows[win],
200 m_data->wm_desktop)));
201 }
202 pager.addWindows(wins_workspaces);
203 } else {
204 // did not handle it here
205 return false;
206 }
207
208 return true;
209
210} catch ( const PropertyException& e ) {
211 cerr << "Ewmh Exception: " << e.what() << endl;
212 // we handle it
213 return true;
214}
215
147bool Ewmh::clientMessage(Pager &pager, XClientMessageEvent &event) { 216bool Ewmh::clientMessage(Pager &pager, XClientMessageEvent &event) {
148 if (!m_support) 217 if (!m_support)
149 return false; 218 return false;
219
150 220
151 if (event.message_type == m_data->current_desktop) { 221 if (event.message_type == m_data->current_desktop) {
152 pager.setCurrentWorkspace(event.data.l[0]); 222 pager.setCurrentWorkspace(event.data.l[0]);
@@ -180,7 +250,7 @@ void Ewmh::changeWorkspace(int screen_num, int workspace) {
180} 250}
181 251
182void Ewmh::setHints(FbTk::FbWindow &win, WindowHint &hint) { 252void Ewmh::setHints(FbTk::FbWindow &win, WindowHint &hint) {
183 253
184 int data = getpid(); 254 int data = getpid();
185 win.changeProperty(m_data->wm_pid, 255 win.changeProperty(m_data->wm_pid,
186 XA_CARDINAL, 256 XA_CARDINAL,
@@ -238,36 +308,6 @@ void Ewmh::setHints(FbTk::FbWindow &win, WindowHint &hint) {
238} 308}
239 309
240 310
241struct PropT {
242 PropT(unsigned char *data, unsigned int num):data(data), num(num) { }
243 ~PropT() {
244 if (data != 0)
245 XFree(data);
246 }
247 unsigned char *data;
248 unsigned int num;
249};
250
251typedef std::auto_ptr<PropT> PropTPtr;
252
253PropT *property(const FbTk::FbWindow &win, Atom atom,
254 Atom type, unsigned int num) {
255 Atom ret_type;
256 int fmt;
257 unsigned long nitems, bytes_after;
258 unsigned char *data = 0;
259 win.property(atom,
260 0, num,
261 False,
262 type,
263 &ret_type, &fmt,
264 &nitems,
265 &bytes_after,
266 &data);
267 return new PropT(data, nitems);
268
269}
270
271void Ewmh::getHints(const FbTk::FbWindow &win, WindowHint &hint) const { 311void Ewmh::getHints(const FbTk::FbWindow &win, WindowHint &hint) const {
272 PropTPtr p(property(win, 312 PropTPtr p(property(win,
273 m_data->wm_state, 313 m_data->wm_state,
diff --git a/src/Ewmh.hh b/src/Ewmh.hh
index 68c42b2..db1c17f 100644
--- a/src/Ewmh.hh
+++ b/src/Ewmh.hh
@@ -1,6 +1,6 @@
1// Ewmh.hh for FbPager 1// Ewmh.hh for FbPager
2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) 2// Copyright (c) 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"), 5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation 6// to deal in the Software without restriction, including without limitation
@@ -46,6 +46,7 @@ public:
46 Orientation orientation, 46 Orientation orientation,
47 Corner starting_corner, 47 Corner starting_corner,
48 unsigned int columns, unsigned int rows); 48 unsigned int columns, unsigned int rows);
49 bool propertyNotify( Pager &pager, XPropertyEvent &event);
49private: