~ubuntu-branches/ubuntu/trusty/fluxbox/trusty-proposed

« back to all changes in this revision

Viewing changes to src/Ewmh.cc

  • Committer: Package Import Robot
  • Author(s): Paul Tagliamonte
  • Date: 2010-08-12 21:16:02 UTC
  • mfrom: (0.1.1) (1.1.10)
  • Revision ID: package-import@ubuntu.com-20100812211602-3tsmzl9in5nmwz7z
Tags: 1.1.1+git20100807.0cc08f9-1
* debian/ dir has been cleaned out, complete repackage
  of most files.
* pulled new archive from git.fluxbox.org HEAD, saved as
  tar.gz.
* Added in fluxbox.* files from the old dfsg tree.
* Added in system.fluxbox-menu file from the old dfsg tree
* Added the source/format file to bump package source
  version from 1.0 to 3.0 (quilt). 
* Changed rules file to match the old dfsg setup so that
  fluxbox behaves nicely.
* Removed entries from copyright that no longer apply.
* Added theme based on Denis Brand ( naran )'s old theme.
* Added a background I whipped up.
* Changed compile flags to point to debian theme by default
* Adding a patch to have fluxbox use x-terminal-emulator
  over xterm. Closes: #591694 (LP: #580485)
* Adding a patch to allow titlebar-window dragging.
* Changed the flags in rules to pull from a script. This script
  lets us un-hardcode what theme is default. Be sure there
  is a theme pack!
* Added comments to my patches.
* Removing debian/docs, empty file.
* Fixing fluxbox.desktop to remove all the warnings from
  desktop-file-validate
* Fixing libtool issue by running an update before
  configure in the rules script.
* Added a compile flag script to auto-detect what platform
  we are running on, and apply the correct theme. This
  should solve Ubuntnu issues later on.
* adding in a get-orig-source rule
* fixing the upstream version number to pinpoint
  the commit ( thanks, lfaraone ).
* adding a rule for get-orig-source. ( thanks again,
  lfaraone ).
* Updated rules to actually allow us to do a build from it
* Removed Denis from the uploaders ( as per an email
  conversation )
* Removing madduck from the uploaders ( thanks for asking,
  lfaraone. ). Thanks for your hard work, madduck.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "fluxbox.hh"
30
30
#include "FbWinFrameTheme.hh"
31
31
#include "FocusControl.hh"
 
32
#include "Debug.hh"
32
33
 
33
34
#include "FbTk/App.hh"
34
35
#include "FbTk/FbWindow.hh"
39
40
 
40
41
#include <X11/Xproto.h>
41
42
#include <X11/Xatom.h>
 
43
 
42
44
#include <iostream>
43
45
#include <algorithm>
44
46
#include <new>
 
47
 
45
48
#ifdef HAVE_CSTRING
46
49
  #include <cstring>
47
50
#else
48
51
  #include <string.h>
49
52
#endif
50
53
 
 
54
#ifdef HAVE_CSTDLIB
 
55
  #include <cstdlib>
 
56
#else
 
57
  #include <stdlib.h>
 
58
#endif
 
59
 
 
60
 
51
61
using std::cerr;
52
62
using std::endl;
53
63
using std::vector;
76
86
 * byte being B. The first two cardinals are width, height. Data is in rows,
77
87
 * left to right and top to bottom. 
78
88
 *
 
89
 ***
 
90
 *
 
91
 * NOTE: the returned data for XA_CARDINAL is long if the rfmt equals
 
92
 * 32. sizeof(long) on 64bit machines is 8. to quote from
 
93
 * "man XGetWindowProperty":
 
94
 *
 
95
 *    If the returned format is 32, the property data will be stored as 
 
96
 *    an array of longs (which in a 64-bit application will be 64-bit 
 
97
 *    values that are padded in the upper 4 bytes).
 
98
 *
 
99
 * this is especially true on 64bit machines when some of the clients
 
100
 * (eg: tvtime, konqueror3) have problems to feed in the right data
 
101
 * into the _NET_WM_ICON property. we faced some segfaults because
 
102
 * width and height were not quite right because of ignoring 64bit
 
103
 * behaviour on client side.
 
104
 *
79
105
 * TODO: maybe move the pixmap-creation code to FbTk? */
80
106
void extractNetWmIcon(Atom net_wm_icon, WinClient& winclient) {
81
107
 
82
108
    typedef std::pair<int, int> Size;
83
109
    typedef std::map<Size, const unsigned long*> IconContainer;
84
110
 
85
 
    // attention: the returned data for XA_CARDINAL is long if the rfmt equals
86
 
    // 32. sizeof(long) on 64bit machines is 8.
87
111
    unsigned long* raw_data = 0;
88
 
    long nr_icon_data = 0;
 
112
    unsigned long nr_icon_data = 0;
89
113
 
90
114
    {
91
115
        Atom rtype;
107
131
        // actually there is some data in _NET_WM_ICON
108
132
        nr_icon_data = nr_bytes_left / sizeof(CARD32);
109
133
 
 
134
        fbdbg << "extractNetWmIcon: " << winclient.title() << "\n";
 
135
        fbdbg << "nr_icon_data: " << nr_icon_data << "\n";
 
136
 
110
137
        // read all the icons stored in _NET_WM_ICON
111
138
        if (raw_data)
112
139
            XFree(raw_data);
118
145
 
119
146
            return;
120
147
        }
 
148
 
 
149
        fbdbg << "nr_read: " << nr_read << "|" << nr_bytes_left << "\n";
 
150
 
121
151
    }
122
152
 
123
153
    IconContainer icon_data; // stores all available data, sorted by size (width x height)
124
 
    int width;
125
 
    int height;
 
154
    unsigned long width;
 
155
    unsigned long height;
126
156
 
127
157
    // analyze the available icons
128
 
    long i;
129
 
 
 
158
    //
 
159
    // check also for invalid values coming in from "bad" applications
 
160
    unsigned long i;
130
161
    for (i = 0; i + 2 < nr_icon_data; i += width * height ) {
131
162
 
132
163
        width = raw_data[i++];
 
164
        if (width >= nr_icon_data) {
 
165
 
 
166
            fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON width (" 
 
167
                  << width << ") for " << winclient.title() << "\n";
 
168
            break;
 
169
        }
 
170
 
133
171
        height = raw_data[i++];
 
172
        if (height >= nr_icon_data) {
 
173
 
 
174
            fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON height (" 
 
175
                  << height << ") for " << winclient.title() << "\n";
 
176
 
 
177
            break;
 
178
        }
134
179
 
135
180
        // strange values stored in the NETWM_ICON
136
 
        if (width <= 0 || height <= 0 || i + width * height > nr_icon_data) {
137
 
            std::cerr << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions for " << winclient.title() << "\n";
138
 
            XFree(raw_data);
139
 
            return;
 
181
        if (i + width * height > nr_icon_data) {
 
182
            fbdbg << "Ewmh.cc extractNetWmIcon found strange _NET_WM_ICON dimensions (" 
 
183
                  << width << "x" << height << ")for " << winclient.title() << "\n";
 
184
 
 
185
            break;
140
186
        }
141
187
 
142
188
        icon_data[Size(width, height)] = &raw_data[i];
143
189
    }
144
190
 
 
191
    // no valid icons found at all
 
192
    if (icon_data.empty()) {
 
193
        XFree(raw_data);
 
194
        return;
 
195
    }
 
196
 
145
197
    Display* dpy = FbTk::App::instance()->display();
146
198
    int scrn = winclient.screen().screenNumber();
147
199
 
178
230
    const unsigned long* src = icon_data.begin()->second;
179
231
    unsigned int rgba;
180
232
    unsigned long pixel;
181
 
    int x;
182
 
    int y;
 
233
    unsigned long x;
 
234
    unsigned long y;
183
235
    unsigned char r, g, b, a;
184
236
 
185
237
    for (y = 0; y < height; y++) {
244
296
    winclient.setIcon(icon);
245
297
}
246
298
 
247
 
}; // end anonymous namespace
 
299
} // end anonymous namespace
248
300
 
249
301
class Ewmh::EwmhAtoms {
250
302
public:
778
830
    const BScreen::WorkspaceNames &workspacenames = screen.getWorkspaceNames();
779
831
    const size_t number_of_desks = workspacenames.size();
780
832
 
781
 
    char *names[number_of_desks];
 
833
    char** names = new char*[number_of_desks];
782
834
 
783
835
    for (size_t i = 0; i < number_of_desks; i++) {
784
836
        names[i] = new char[workspacenames[i].size() + 1]; // +1 for \0
800
852
#else
801
853
    if (XStringListToTextProperty(names, number_of_desks, &text)) {
802
854
        XSetTextProperty(FbTk::App::instance()->display(), screen.rootWindow().window(),
803
 
                         &text, m_net->desktop_names);
 
855
                &text, m_net->desktop_names);
804
856
        XFree(text.value);
805
857
    }
806
858
#endif
807
859
 
808
860
    for (size_t i = 0; i < number_of_desks; i++)
809
 
        delete [] names[i];
 
861
        delete[] names[i];
 
862
 
 
863
    delete[] names;
810
864
 
811
865
}
812
866
 
926
980
 
927
981
    updateActions(win);
928
982
 
929
 
    typedef vector<unsigned int> StateVec;
 
983
    typedef vector<Atom> StateVec;
930
984
 
931
985
    StateVec state;
932
986
 
1135
1189
            win_gravity, winclient->old_bw);
1136
1190
        return true;
1137
1191
    } else if (ce.message_type == m_net->restack_window) {
1138
 
#ifndef DEBUG
1139
 
        cerr << "Ewmh: restack window" << endl;
1140
 
#endif // DEBUG
 
1192
 
 
1193
        fbdbg << "Ewmh: restack window" << endl;
 
1194
 
1141
1195
        if (winclient == 0 || winclient->fbwindow() == 0)
1142
1196
            return true;
1143
1197
 
1159
1213
        // do restack if both items are on the same layer
1160
1214
        // else ignore restack
1161
1215
        if (&below_item.getLayer() == &above_item.getLayer())
1162
 
            below_item.getLayer().stackBelowItem(&below_item, &above_item);
 
1216
            below_item.getLayer().stackBelowItem(below_item, &above_item);
1163
1217
 
1164
1218
 
1165
1219
        return true;
1239
1293
        if (!newtitle.empty())
1240
1294
            winclient.setTitle(newtitle);
1241
1295
        if (winclient.fbwindow())
1242
 
            winclient.fbwindow()->titleSig().notify();
 
1296
            winclient.fbwindow()->titleSig().emit(newtitle, *winclient.fbwindow());
1243
1297
        return true;
1244
1298
    } else if (the_property == m_net->wm_icon_name) {
1245
1299
        // we don't use icon title, since we don't show icons
1304
1358
        if (value) { // if add attention
1305
1359
            Fluxbox::instance()->attentionHandler().addAttention(client);
1306
1360
        } else { // erase it
1307
 
            Fluxbox::instance()->attentionHandler().
1308
 
                update(&client.focusSig());
 
1361
            Fluxbox::instance()->attentionHandler().removeWindow(client);
1309
1362
        }
1310
1363
    } else if (state == m_net->wm_state_modal) {
1311
1364
        client.setStateModal(value);
1491
1544
                              (unsigned char *)extents, 4);
1492
1545
    }
1493
1546
}
 
1547