aboutsummaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-02-17 18:48:22 (GMT)
committerfluxgen <fluxgen>2002-02-17 18:48:22 (GMT)
commit890ba372b26c029b1fb147d1668cde942b43393a (patch)
tree150db9a6d4263511a7a5f677db76b77db9dd5e2f /src/Window.cc
parentb8c9d50d7dc51097d6c100f6b8cffd371b7be33e (diff)
downloadfluxbox_pavel-890ba372b26c029b1fb147d1668cde942b43393a.zip
fluxbox_pavel-890ba372b26c029b1fb147d1668cde942b43393a.tar.bz2
gnome functions
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc229
1 files changed, 205 insertions, 24 deletions
diff --git a/src/Window.cc b/src/Window.cc
index c4e211e..aee5504 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.28 2002/02/16 11:25:41 fluxgen Exp $ 25// $Id: Window.cc,v 1.29 2002/02/17 18:48:22 fluxgen Exp $
26 26
27//use GNU extensions 27//use GNU extensions
28#ifndef _GNU_SOURCE 28#ifndef _GNU_SOURCE
@@ -74,6 +74,9 @@ display(0),
74lastButtonPressTime(0), 74lastButtonPressTime(0),
75windowmenu(0), 75windowmenu(0),
76tab(0) 76tab(0)
77#ifdef GNOME
78,gnome_hints(0)
79#endif
77{ 80{
78 81
79 #ifdef DEBUG 82 #ifdef DEBUG
@@ -386,10 +389,6 @@ FluxboxWindow::~FluxboxWindow(void) {
386 if (screen==0) //the window wasn't created 389 if (screen==0) //the window wasn't created
387 return; 390 return;
388 391
389 #ifdef GNOME
390 XDeleteProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom());
391 #endif
392
393 Fluxbox *fluxbox = Fluxbox::instance(); 392 Fluxbox *fluxbox = Fluxbox::instance();
394 393
395 394
@@ -856,6 +855,7 @@ void FluxboxWindow::grabButtons() {
856 //---grab with "all" modifiers 855 //---grab with "all" modifiers
857 grabButton(display, Button3, frame.window, fluxbox->getLowerRightAngleCursor()); 856 grabButton(display, Button3, frame.window, fluxbox->getLowerRightAngleCursor());
858} 857}
858
859void FluxboxWindow::createButton(int type, ButtonEventProc pressed, ButtonEventProc released, ButtonDrawProc draw) { 859void FluxboxWindow::createButton(int type, ButtonEventProc pressed, ButtonEventProc released, ButtonDrawProc draw) {
860 Button b; 860 Button b;
861 b.win = createChildWindow(frame.title); 861 b.win = createChildWindow(frame.title);
@@ -867,27 +867,46 @@ void FluxboxWindow::createButton(int type, ButtonEventProc pressed, ButtonEventP
867 b.released = released; 867 b.released = released;
868 buttonlist.push_back(b); 868 buttonlist.push_back(b);
869} 869}
870
870#ifdef GNOME 871#ifdef GNOME
872//TODO
871void FluxboxWindow::updateGnomeAtoms() { 873void FluxboxWindow::updateGnomeAtoms() {
874 updateGnomeWorkspaceAtom();
875 updateGnomeStateAtom();
876 updateGnomeLayerAtom();
877 updateGnomeWorkspaceAtom();
878}
879
880void FluxboxWindow::updateGnomeStateAtom() {
881 BaseDisplay *bd = screen->getBaseDisplay();
882 int val = getGnomeWindowState();
883 XChangeProperty(display, client.window, bd->getGnomeStateAtom(),
884 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1);
885}
886
887void FluxboxWindow::updateGnomeLayerAtom() {
888 BaseDisplay *bd = screen->getBaseDisplay();
889 int val = getGnomeLayer();
890 XChangeProperty(display, client.window, bd->getGnomeLayerAtom(),
891 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1);
892}
893
894void FluxboxWindow::updateGnomeWorkspaceAtom() {
895 BaseDisplay *bd = screen->getBaseDisplay();
872 int val = workspace_number; 896 int val = workspace_number;
873 XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeWorkspaceAtom(), 897 XChangeProperty(display, client.window, bd->getGnomeWorkspaceAtom(),
874 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1); 898 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&val, 1);
875 long state = getGnomeWindowState();
876 XChangeProperty(display, client.window, screen->getBaseDisplay()->getGnomeStateAtom(),
877 XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&state, 1);
878 #ifdef DEBUG
879 cerr<<__FILE__<<"("<<__LINE__<<"): 0x"<<hex<<screen->getBaseDisplay()->getGnomeStateAtom()<<dec<<endl;
880 #endif
881} 899}
882 900
883long FluxboxWindow::getGnomeWindowState() { 901//TODO
884 long state=0; 902int FluxboxWindow::getGnomeWindowState() {
903 int state=0;
885 if (isStuck()) 904 if (isStuck())
886 state |= BaseDisplay::WIN_STATE_STICKY; 905 state |= WIN_STATE_STICKY;
887 if (isIconic()) 906 if (isIconic())
888 state |= BaseDisplay::WIN_STATE_MINIMIZED; 907 state |= WIN_STATE_MINIMIZED;
889 if (isShaded()) 908 if (isShaded())
890 state |= BaseDisplay::WIN_STATE_SHADED; 909 state |= WIN_STATE_SHADED;
891 /*TODO: states: 910 /*TODO: states:
892 WIN_STATE_MAXIMIZED_VERT // window in maximized V state 911 WIN_STATE_MAXIMIZED_VERT // window in maximized V state
893 WIN_STATE_MAXIMIZED_HORIZ // window in maximized H state 912 WIN_STATE_MAXIMIZED_HORIZ // window in maximized H state
@@ -899,8 +918,148 @@ long FluxboxWindow::getGnomeWindowState() {
899 */ 918 */
900 return state; 919 return state;
901} 920}
921
922//TODO
923int FluxboxWindow::getGnomeLayer() {
924 return WIN_LAYER_NORMAL;
925}
926
927bool FluxboxWindow::handleGnomePropertyNotify(Atom atom) {
928 BaseDisplay *bd = screen->getBaseDisplay();
929
930 if (atom == bd->getGnomeStateAtom()) {
931 #ifdef DEBUG
932 cerr<<__FILE__<<"("<<__LINE__<<"): gnome state"<<endl;
933 #endif
934 loadGnomeStateAtom();
935 } else if (atom == bd->getGnomeWorkspaceAtom()) {
936 #ifdef DEBUG
937 cerr<<__FILE__<<"("<<__LINE__<<"): gnome workspace"<<endl;
938 #endif
939 } else if (atom == bd->getGnomeHintsAtom()) {
940 #ifdef DEBUG
941 cerr<<__FILE__<<"("<<__LINE__<<"): gnome hints"<<endl;
942 #endif
943 loadGnomeHintsAtom();
944 } else if (atom == bd->getGnomeLayerAtom()){
945 #ifdef DEBUG
946 cerr<<__FILE__<<"("<<__LINE__<<"): gnome layer"<<endl;
947 #endif
948
949 } else
950 return false;
951
952 return true;
953}
954
955//TODO
956void FluxboxWindow::setGnomeState(int state) {
957 #ifdef DEBUG
958 cerr<<"state=0x"<<hex<<state<<dec<<endl;
959 #endif
960
961 if ( state & WIN_STATE_STICKY) {
962 cerr<<"Sticky"<<endl;
963 if (!isStuck())
964 stick();
965 } else if (isStuck())
966 stick();
967
968 if (state & WIN_STATE_MINIMIZED) {
969 cerr<<"Minimized"<<endl;
970 if (isIconic())
971 iconify();
972 } else if (isIconic())
973 deiconify(true, true);
974 /* TODO
975 if (state & WIN_STATE_MAXIMIZED_VERT)
976 cerr<<"Maximize Vert"<<endl;
977 if (state & WIN_STATE_MAXIMIZED_HORIZ)
978 cerr<<"Maximize Horiz"<<endl;
979 if (state & WIN_STATE_HIDDEN)
980 cerr<<"Hidden"<<endl;
981 if (state & WIN_STATE_SHADED) {
982 cerr<<"Shaded"<<endl;
983 if (!isShaded()) shade();
984 } else if (isShaded())
985 shade();
986
987 if (state & WIN_STATE_HID_WORKSPACE)
988 cerr<<"HID Workspace"<<endl;
989 if (state & WIN_STATE_HID_TRANSIENT)
990 cerr<<"HID Transient"<<endl;
991 if (state & WIN_STATE_FIXED_POSITION)
992 cerr<<"Fixed Position"<<endl;
993 if (state & WIN_STATE_ARRANGE_IGNORE)
994 cerr<<"Arrange Ignore"<<endl;
995 */
996}
997//------------ loadGnomeAtoms ------------
998// Loads the values from the atoms
999//----------------------------------------
1000void FluxboxWindow::loadGnomeAtoms() {
1001 loadGnomeStateAtom();
1002 loadGnomeHintsAtom();
1003}
1004//----------- loadGnomeStateAtom -------
1005// Gets gnome state from the atom
1006//----------------------------------------
1007void FluxboxWindow::loadGnomeStateAtom() {
1008 Atom ret_type;
1009 int fmt;
1010 unsigned long nitems, bytes_after;
1011 long flags, *data = 0;
1012 BaseDisplay *bd = screen->getBaseDisplay();
1013 if (XGetWindowProperty (bd->getXDisplay(), getClientWindow(),
1014 bd->getGnomeStateAtom(), 0, 1, False, XA_CARDINAL,
1015 &ret_type, &fmt, &nitems, &bytes_after,
1016 (unsigned char **) &data) == Success && data) {
1017 flags = *data;
1018 setGnomeState(flags);
1019 XFree (data);
1020 }
1021}
1022
1023//--------- loadGnomeHintsAtom ---------
1024// Gets the gnome hint from the atom
1025//----------------------------------------
1026void FluxboxWindow::loadGnomeHintsAtom() {
1027 Atom ret_type;
1028 int fmt;
1029 unsigned long nitems, bytes_after;
1030 long *data = 0;
1031 BaseDisplay *bd = screen->getBaseDisplay();
1032 if (XGetWindowProperty (bd->getXDisplay(), getClientWindow(),
1033 bd->getGnomeHintsAtom(), 0, 1, False, XA_CARDINAL,
1034 &ret_type, &fmt, &nitems, &bytes_after,
1035 (unsigned char **) &data) == Success && data) {
1036 gnome_hints = static_cast<int>(*data);
1037 #ifdef DEBUG
1038 cerr<<__FILE__<<"("<<__LINE__<<"): gnome hints:0x"<<hex<<gnome_hints<<dec<<endl;
1039 #endif
1040 XFree (data);
1041 }
1042}
1043
902#endif //!GNOME 1044#endif //!GNOME
903 1045
1046#ifdef NEWWMSPEC
1047//TODO!!
1048
1049void FluxboxWindow::updateNETWMAtoms() {
1050
1051}
1052
1053int FluxboxWindow::getNETWMWindowState() {
1054
1055}
1056
1057void FluxboxWindow::loadNETWMWorkspaceAtom() {
1058
1059}
1060
1061#endif //!NEWWMSPEC
1062
904Window FluxboxWindow::findTitleButton(int type) { 1063Window FluxboxWindow::findTitleButton(int type) {
905 for (unsigned int i=0; i<buttonlist.size(); i++) { 1064 for (unsigned int i=0; i<buttonlist.size(); i++) {
906 if (buttonlist[i].type == type) 1065 if (buttonlist[i].type == type)
@@ -1667,6 +1826,10 @@ void FluxboxWindow::configure(int dx, int dy,
1667 1826
1668 1827
1669bool FluxboxWindow::setInputFocus(void) { 1828bool FluxboxWindow::setInputFocus(void) {
1829 #ifdef GNOME
1830 if (gnome_hints & WIN_HINTS_SKIP_FOCUS)
1831 return false;
1832 #endif
1670 if (((signed) (frame.x + frame.width)) < 0) { 1833 if (((signed) (frame.x + frame.width)) < 0) {
1671 if (((signed) (frame.y + frame.y_border)) < 0) 1834 if (((signed) (frame.y + frame.y_border)) < 0)
1672 configure(screen->getBorderWidth(), screen->getBorderWidth(), 1835 configure(screen->getBorderWidth(), screen->getBorderWidth(),
@@ -1848,9 +2011,7 @@ void FluxboxWindow::close(void) {
1848void FluxboxWindow::withdraw(void) { 2011void FluxboxWindow::withdraw(void) {
1849 visible = false; 2012 visible = false;
1850 iconic = false; 2013 iconic = false;
1851// 2014
1852// setState(WithdrawnState);
1853//
1854 XUnmapWindow(display, frame.window); 2015 XUnmapWindow(display, frame.window);
1855 2016
1856 XSelectInput(display, client.window, NoEventMask); 2017 XSelectInput(display, client.window, NoEventMask);
@@ -2091,11 +2252,14 @@ void FluxboxWindow::setWorkspace(int n) {
2091 2252
2092 blackbox_attrib.flags |= BaseDisplay::ATTRIB_WORKSPACE; 2253 blackbox_attrib.flags |= BaseDisplay::ATTRIB_WORKSPACE;
2093 blackbox_attrib.workspace = workspace_number; 2254 blackbox_attrib.workspace = workspace_number;
2255 #ifdef GNOME
2256 updateGnomeWorkspaceAtom();
2257 #endif
2094} 2258}
2095 2259
2096 2260
2097void FluxboxWindow::shade(void) { 2261void FluxboxWindow::shade(void) {
2098 if (decorations.titlebar) 2262 if (decorations.titlebar) {
2099 if (shaded) { 2263 if (shaded) {
2100 XResizeWindow(display, frame.window, frame.width, frame.height); 2264 XResizeWindow(display, frame.window, frame.width, frame.height);
2101 shaded = false; 2265 shaded = false;
@@ -2111,6 +2275,10 @@ void FluxboxWindow::shade(void) {
2111 2275
2112 setState(IconicState); 2276 setState(IconicState);
2113 } 2277 }
2278 #ifdef GNOME
2279 updateGnomeStateAtom();
2280 #endif
2281 }
2114} 2282}
2115 2283
2116 2284
@@ -2138,6 +2306,9 @@ void FluxboxWindow::stick(void) {
2138 //find a STICK button in window 2306 //find a STICK button in window
2139 redrawAllButtons(); 2307 redrawAllButtons();
2140 setState(current_state); 2308 setState(current_state);
2309 #ifdef GNOME
2310 updateGnomeStateAtom();
2311 #endif
2141} 2312}
2142 2313
2143 2314
@@ -2557,7 +2728,9 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent *re) {
2557 2728
2558 2729
2559void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) { 2730void FluxboxWindow::mapNotifyEvent(XMapEvent *ne) {
2560 2731 #ifdef GNOME
2732 loadGnomeAtoms();
2733 #endif
2561 if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) { 2734 if ((ne->window == client.window) && (! ne->override_redirect) && (visible)) {
2562 Fluxbox *fluxbox = Fluxbox::instance(); 2735 Fluxbox *fluxbox = Fluxbox::instance();
2563 BaseDisplay::GrabGuard gg(*fluxbox); 2736 BaseDisplay::GrabGuard gg(*fluxbox);
@@ -2786,8 +2959,16 @@ void FluxboxWindow::propertyNotifyEvent(Atom atom) {
2786 if (windowmenu) 2959 if (windowmenu)
2787 windowmenu->reconfigure(); 2960 windowmenu->reconfigure();
2788 } 2961 }
2962 } else {
2963 bool val = false;
2964 #ifdef GNOME
2965 val = handleGnomePropertyNotify(atom);
2966 #endif
2967 #ifdef NEWWMSPEC
2968 if (!val)
2969 handleNETWMPropertyNotify(atom);
2970 #endif
2789 } 2971 }
2790
2791 break; 2972 break;
2792 } 2973 }
2793 2974