~ubuntu-branches/debian/sid/openbox/sid

« back to all changes in this revision

Viewing changes to openbox/popup.c

  • Committer: Bazaar Package Importer
  • Author(s): Nico Golde, Nico Golde, Eugenio Paolantonio
  • Date: 2011-10-03 22:59:30 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20111003225930-tdvyax5tx63dyoez
Tags: 3.5.0-1
[Nico Golde]
* New upstream release (Closes: #638783).
  - Fix crashes in the menu code (Closes: #563891).
* Add Brazilian translation to openbox.desktop,
  thanks Sérgio Cipolla (Closes: #627912).
* Remove 06_fix_swap_byte_order.patch, applied upstream.
* Bump debhelper dependency to >= 7.0.50~ due to override.
* Remove CHANGELOG from openbox.docs to prevent double installation.
* Add 02_fix_freedesktop_compliance.dpatch desktop file to
  /usr/share/applications.

[Eugenio Paolantonio]
* debian/patches:
  - Disabled 03_place_windows_in_quadrants.patch
  - Updated 01_rc.xml.patch and 06_fix_swap_byte_order.patch
  - Removed 04_fix_ftbfs_no-add-needed.patch and 20_24bits_support.patch
* debian/control:
  - Added myself to the Uploaders.
  - Build-Depends: removed libxau-dev, libxft-dev and python-xdg;
    added libimlib2-dev
  - openbox Suggests: added python-xdg
  - libobrender21 renamed to libobrender27
  - libobparser21 renamed to libobt0
* debian/rules:
  - Rewrote using a simpler debhelper syntax
  - Moved the install pass to openbox.install
* debian/*.{install,links,dirs}:
  - Updated.
* debian/openbox.xsession:
  - Removed. Openbox now ships it by default.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "stacking.h"
26
26
#include "event.h"
27
27
#include "screen.h"
28
 
#include "mainloop.h"
29
 
#include "render/render.h"
30
 
#include "render/theme.h"
 
28
#include "obrender/render.h"
 
29
#include "obrender/theme.h"
31
30
 
32
31
ObPopup *popup_new(void)
33
32
{
34
33
    XSetWindowAttributes attrib;
35
 
    ObPopup *self = g_new0(ObPopup, 1);
 
34
    ObPopup *self = g_slice_new0(ObPopup);
36
35
 
37
 
    self->obwin.type = Window_Internal;
 
36
    self->obwin.type = OB_WINDOW_CLASS_INTERNAL;
38
37
    self->gravity = NorthWestGravity;
39
38
    self->x = self->y = self->textw = self->h = 0;
40
 
    self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
 
39
    self->a_bg = RrAppearanceCopy(ob_rr_theme->osd_bg);
41
40
    self->a_text = RrAppearanceCopy(ob_rr_theme->osd_hilite_label);
42
41
    self->iconwm = self->iconhm = 1;
43
42
 
44
43
    attrib.override_redirect = True;
45
 
    self->bg = XCreateWindow(ob_display, RootWindow(ob_display, ob_screen),
 
44
    self->bg = XCreateWindow(obt_display, obt_root(ob_screen),
46
45
                             0, 0, 1, 1, 0, RrDepth(ob_rr_inst),
47
46
                             InputOutput, RrVisual(ob_rr_inst),
48
47
                             CWOverrideRedirect, &attrib);
49
48
 
50
 
    self->text = XCreateWindow(ob_display, self->bg,
 
49
    self->text = XCreateWindow(obt_display, self->bg,
51
50
                               0, 0, 1, 1, 0, RrDepth(ob_rr_inst),
52
51
                               InputOutput, RrVisual(ob_rr_inst), 0, NULL);
53
52
 
54
 
    XSetWindowBorderWidth(ob_display, self->bg, ob_rr_theme->obwidth);
55
 
    XSetWindowBorder(ob_display, self->bg,
 
53
    XSetWindowBorderWidth(obt_display, self->bg, ob_rr_theme->obwidth);
 
54
    XSetWindowBorder(obt_display, self->bg,
56
55
                     RrColorPixel(ob_rr_theme->osd_border_color));
57
56
 
58
 
    XMapWindow(ob_display, self->text);
 
57
    XMapWindow(obt_display, self->text);
59
58
 
60
59
    stacking_add(INTERNAL_AS_WINDOW(self));
61
 
    g_hash_table_insert(window_map, &self->bg, self);
 
60
    window_add(&self->bg, INTERNAL_AS_WINDOW(self));
62
61
    return self;
63
62
}
64
63
 
67
66
    if (self) {
68
67
        popup_hide(self); /* make sure it's not showing or is being delayed and
69
68
                             will be shown */
70
 
        XDestroyWindow(ob_display, self->bg);
71
 
        XDestroyWindow(ob_display, self->text);
 
69
        XDestroyWindow(obt_display, self->bg);
 
70
        XDestroyWindow(obt_display, self->text);
72
71
        RrAppearanceFree(self->a_bg);
73
72
        RrAppearanceFree(self->a_text);
74
 
        g_hash_table_remove(window_map, &self->bg);
 
73
        window_remove(self->bg);
75
74
        stacking_remove(self);
76
 
        g_free(self);
 
75
        g_slice_free(ObPopup, self);
77
76
    }
78
77
}
79
78
 
143
142
{
144
143
    ObPopup *self = data;
145
144
 
146
 
    XMapWindow(ob_display, self->bg);
 
145
    XMapWindow(obt_display, self->bg);
147
146
    stacking_raise(INTERNAL_AS_WINDOW(self));
148
147
    self->mapped = TRUE;
149
148
    self->delay_mapped = FALSE;
 
149
    self->delay_timer = 0;
150
150
 
151
151
    return FALSE; /* don't repeat */
152
152
}
153
153
 
154
 
void popup_delay_show(ObPopup *self, gulong usec, gchar *text)
 
154
void popup_delay_show(ObPopup *self, gulong msec, gchar *text)
155
155
{
156
156
    gint l, t, r, b;
157
157
    gint x, y, w, h;
159
159
    gint emptyx, emptyy; /* empty space between elements */
160
160
    gint textx, texty, textw, texth;
161
161
    gint iconx, icony, iconw, iconh;
162
 
    Rect *area, mon;
 
162
    const Rect *area;
 
163
    Rect mon;
 
164
    gboolean hasicon = self->hasicon;
163
165
 
164
166
    /* when there is no icon and the text is not parent relative, then
165
167
       fill the whole dialog with the text appearance, don't use the bg at all
166
168
    */
167
 
    if (self->hasicon || self->a_text->surface.grad == RR_SURFACE_PARENTREL)
 
169
    if (hasicon || self->a_text->surface.grad == RR_SURFACE_PARENTREL)
168
170
        RrMargins(self->a_bg, &l, &t, &r, &b);
169
171
    else
170
172
        l = t = r = b = 0;
192
194
    iconx = textx = l + ob_rr_theme->paddingx;
193
195
 
194
196
    emptyx = l + r + ob_rr_theme->paddingx * 2;
195
 
    if (self->hasicon) {
 
197
    if (hasicon) {
196
198
        iconw = texth * self->iconwm;
197
199
        iconh = texth * self->iconhm;
198
200
        textx += iconw + ob_rr_theme->paddingx;
199
201
        if (textw)
200
202
            emptyx += ob_rr_theme->paddingx; /* between the icon and text */
 
203
        icony = (h - iconh - emptyy) / 2 + t + ob_rr_theme->paddingy;
201
204
    } else
202
205
        iconw = 0;
203
206
 
204
207
    texty = (h - texth - emptyy) / 2 + t + ob_rr_theme->paddingy;
205
 
    icony = (h - iconh - emptyy) / 2 + t + ob_rr_theme->paddingy;
206
208
 
207
209
    /* when there is no icon, then fill the whole dialog with the text
208
210
       appearance
209
211
    */
210
 
    if (!self->hasicon)
 
212
    if (!hasicon)
211
213
    {
212
214
        textx = texty = 0;
213
215
        texth += emptyy;
259
261
    x=MAX(MIN(x, area->x+area->width-w),area->x);
260
262
    y=MAX(MIN(y, area->y+area->height-h),area->y);
261
263
 
262
 
    g_free(area);
263
 
 
264
264
    if (m == screen_num_monitors) {
265
265
        RECT_SET(mon, x, y, w, h);
266
266
        m = screen_find_monitor(&mon);
270
270
 
271
271
        x=MAX(MIN(x, area->x+area->width-w),area->x);
272
272
        y=MAX(MIN(y, area->y+area->height-h),area->y);
273
 
 
274
 
        g_free(area);
275
273
    }
276
274
 
277
275
    /* set the windows/appearances up */
278
 
    XMoveResizeWindow(ob_display, self->bg, x, y, w, h);
 
276
    XMoveResizeWindow(obt_display, self->bg, x, y, w, h);
279
277
    /* when there is no icon and the text is not parent relative, then
280
278
       fill the whole dialog with the text appearance, don't use the bg at all
281
279
    */
282
 
    if (self->hasicon || self->a_text->surface.grad == RR_SURFACE_PARENTREL)
 
280
    if (hasicon || self->a_text->surface.grad == RR_SURFACE_PARENTREL)
283
281
        RrPaint(self->a_bg, self->bg, w, h);
284
282
 
285
283
    if (textw) {
286
284
        self->a_text->surface.parent = self->a_bg;
287
285
        self->a_text->surface.parentx = textx;
288
286
        self->a_text->surface.parenty = texty;
289
 
        XMoveResizeWindow(ob_display, self->text, textx, texty, textw, texth);
 
287
        XMoveResizeWindow(obt_display, self->text, textx, texty, textw, texth);
290
288
        RrPaint(self->a_text, self->text, textw, texth);
291
289
    }
292
290
 
293
 
    if (self->hasicon)
 
291
    if (hasicon)
294
292
        self->draw_icon(iconx, icony, iconw, iconh, self->draw_icon_data);
295
293
 
296
294
    /* do the actual showing */
297
295
    if (!self->mapped) {
298
 
        if (usec) {
 
296
        if (msec) {
299
297
            /* don't kill previous show timers */
300
298
            if (!self->delay_mapped) {
301
 
                ob_main_loop_timeout_add(ob_main_loop, usec,
302
 
                                         popup_show_timeout, self,
303
 
                                         g_direct_equal, NULL);
 
299
                self->delay_timer =
 
300
                    g_timeout_add(msec, popup_show_timeout, self);
304
301
                self->delay_mapped = TRUE;
305
302
            }
306
303
        } else {
317
314
        /* kill enter events cause by this unmapping */
318
315
        ignore_start = event_start_ignore_all_enters();
319
316
 
320
 
        XUnmapWindow(ob_display, self->bg);
 
317
        XUnmapWindow(obt_display, self->bg);
321
318
        self->mapped = FALSE;
322
319
 
323
320
        event_end_ignore_all_enters(ignore_start);
324
321
    } else if (self->delay_mapped) {
325
 
        ob_main_loop_timeout_remove_data(ob_main_loop, popup_show_timeout, self, FALSE);
 
322
        g_source_remove(self->delay_timer);
 
323
        self->delay_timer = 0;
326
324
        self->delay_mapped = FALSE;
327
325
    }
328
326
}
334
332
    self->a_icon->surface.parent = self->popup->a_bg;
335
333
    self->a_icon->surface.parentx = x;
336
334
    self->a_icon->surface.parenty = y;
337
 
    XMoveResizeWindow(ob_display, self->icon, x, y, w, h);
 
335
    XMoveResizeWindow(obt_display, self->icon, x, y, w, h);
338
336
    RrPaint(self->a_icon, self->icon, w, h);
339
337
}
340
338
 
342
340
{
343
341
    ObIconPopup *self;
344
342
 
345
 
    self = g_new0(ObIconPopup, 1);
 
343
    self = g_slice_new0(ObIconPopup);
346
344
    self->popup = popup_new();
347
345
    self->a_icon = RrAppearanceCopy(ob_rr_theme->a_clear_tex);
348
 
    self->icon = XCreateWindow(ob_display, self->popup->bg,
 
346
    self->icon = XCreateWindow(obt_display, self->popup->bg,
349
347
                               0, 0, 1, 1, 0,
350
348
                               RrDepth(ob_rr_inst), InputOutput,
351
349
                               RrVisual(ob_rr_inst), 0, NULL);
352
 
    XMapWindow(ob_display, self->icon);
 
350
    XMapWindow(obt_display, self->icon);
353
351
 
354
352
    self->popup->hasicon = TRUE;
355
353
    self->popup->draw_icon = icon_popup_draw_icon;
361
359
void icon_popup_free(ObIconPopup *self)
362
360
{
363
361
    if (self) {
364
 
        XDestroyWindow(ob_display, self->icon);
 
362
        XDestroyWindow(obt_display, self->icon);
365
363
        RrAppearanceFree(self->a_icon);
366
364
        popup_free(self->popup);
367
 
        g_free(self);
 
365
        g_slice_free(ObIconPopup, self);
368
366
    }
369
367
}
370
368
 
371
 
void icon_popup_delay_show(ObIconPopup *self, gulong usec,
 
369
void icon_popup_delay_show(ObIconPopup *self, gulong msec,
372
370
                           gchar *text, RrImage *icon)
373
371
{
374
372
    if (icon) {
381
379
        self->a_icon->texture[0].type = RR_TEXTURE_NONE;
382
380
    }
383
381
 
384
 
    popup_delay_show(self->popup, usec, text);
 
382
    popup_delay_show(self->popup, msec, text);
385
383
}
386
384
 
387
385
void icon_popup_icon_size_multiplier(ObIconPopup *self, guint wm, guint hm)
487
485
                a->surface.parent = self->popup->a_bg;
488
486
                a->surface.parentx = x + px;
489
487
                a->surface.parenty = y + py;
490
 
                XMoveResizeWindow(ob_display, self->wins[n],
 
488
                XMoveResizeWindow(obt_display, self->wins[n],
491
489
                                  x + px, y + py, eachw, eachh);
492
490
                RrPaint(a, self->wins[n], eachw, eachh);
493
491
            }
501
499
{
502
500
    ObPagerPopup *self;
503
501
 
504
 
    self = g_new(ObPagerPopup, 1);
 
502
    self = g_slice_new(ObPagerPopup);
505
503
    self->popup = popup_new();
506
504
 
507
505
    self->desks = 0;
508
506
    self->wins = g_new(Window, self->desks);
509
 
    self->hilight = RrAppearanceCopy(ob_rr_theme->osd_hilite_fg);
510
 
    self->unhilight = RrAppearanceCopy(ob_rr_theme->osd_unhilite_fg);
 
507
    self->hilight = RrAppearanceCopy(ob_rr_theme->osd_hilite_bg);
 
508
    self->unhilight = RrAppearanceCopy(ob_rr_theme->osd_unhilite_bg);
511
509
 
512
510
    self->popup->hasicon = TRUE;
513
511
    self->popup->draw_icon = pager_popup_draw_icon;
522
520
        guint i;
523
521
 
524
522
        for (i = 0; i < self->desks; ++i)
525
 
            XDestroyWindow(ob_display, self->wins[i]);
 
523
            XDestroyWindow(obt_display, self->wins[i]);
526
524
        g_free(self->wins);
527
525
        RrAppearanceFree(self->hilight);
528
526
        RrAppearanceFree(self->unhilight);
529
527
        popup_free(self->popup);
530
 
        g_free(self);
 
528
        g_slice_free(ObPagerPopup, self);
531
529
    }
532
530
}
533
531
 
534
 
void pager_popup_delay_show(ObPagerPopup *self, gulong usec,
 
532
void pager_popup_delay_show(ObPagerPopup *self, gulong msec,
535
533
                            gchar *text, guint desk)
536
534
{
537
535
    guint i;
538
536
 
539
537
    if (screen_num_desktops < self->desks)
540
538
        for (i = screen_num_desktops; i < self->desks; ++i)
541
 
            XDestroyWindow(ob_display, self->wins[i]);
 
539
            XDestroyWindow(obt_display, self->wins[i]);
542
540
 
543
541
    if (screen_num_desktops != self->desks)
544
542
        self->wins = g_renew(Window, self->wins, screen_num_desktops);
549
547
 
550
548
            attr.border_pixel =
551
549
                RrColorPixel(ob_rr_theme->osd_border_color);
552
 
            self->wins[i] = XCreateWindow(ob_display, self->popup->bg,
 
550
            self->wins[i] = XCreateWindow(obt_display, self->popup->bg,
553
551
                                          0, 0, 1, 1, ob_rr_theme->obwidth,
554
552
                                          RrDepth(ob_rr_inst), InputOutput,
555
553
                                          RrVisual(ob_rr_inst), CWBorderPixel,
556
554
                                          &attr);
557
 
            XMapWindow(ob_display, self->wins[i]);
 
555
            XMapWindow(obt_display, self->wins[i]);
558
556
        }
559
557
 
560
558
    self->desks = screen_num_desktops;
561
559
    self->curdesk = desk;
562
560
 
563
 
    popup_delay_show(self->popup, usec, text);
 
561
    popup_delay_show(self->popup, msec, text);
564
562
}
565
563
 
566
564
void pager_popup_icon_size_multiplier(ObPagerPopup *self, guint wm, guint hm)