~ubuntu-branches/debian/experimental/qtcurve/experimental

« back to all changes in this revision

Viewing changes to gtk2/style/window.c

  • Committer: Package Import Robot
  • Author(s): Boris Pek, Thanks to Scarlett Clark
  • Date: 2015-07-26 04:17:05 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150726041705-yuxbierbpely1fvp
Tags: 1.8.18+git20150711-a3fff13-1
* Upstream Git snapshot (1.8.18-242-ga3fff13) is taken from:
  http://quickgit.kde.org/?p=qtcurve.git
* Localization files are taken from last stable release (1.8.18).
* Fixed in upstream:
  - gtk2-engines-qtcurve: inkscape 0.91 crashes after palette mouse-over
    (Closes: #786831)
  - gtk2-engines-qtcurve: massive memory leak in mysql-workbench
    (Closes: #682162)
* Update debian/patches:
  - delete qt53-build-fix.diff (fixed in upstream)
  - add enable-translations.patch
* Update debian/control:
  - bump Standards-Version to 3.9.6 (was 3.9.5): no changes required
  - update Build-Depends for transition from KDE4 to KF5:
    + delete dependencies from: kdebase-workspace-dev and qtdeclarative5-dev
    + add dependencies from: extra-cmake-modules, kio-dev,
      libkf5archive-dev, libkf5config-dev, libkf5configwidgets-dev,
      libkf5i18n-dev, libkf5kdelibs4support-dev, libkf5widgetsaddons-dev,
      libkf5xmlgui-dev, libqt5x11extras5-dev, libxcb1-dev, pkg-config
      [Thanks to Scarlett Clark]
  - delete package kwin-style-qtcurve: it is not available for KF5 yet
    (LP: #1452218)
  - package kde-style-qtcurve now provides package kde-style-qtcurve-qt4
  - package kde-style-qtcurve is "Multi-Arch: same" now
  - metapackage qtcurve now depends on kde-style-qtcurve-qt5 and recommends
    kwin-decoration-oxygen, oxygen-icon-theme and oxygencursors
* Update debian/rules:
  - build using kf5 libraries instead of kde4
  - update configure flags
  - use xz compression in packages
* Update debian/kde-style-qtcurve.install:
  there are no KDE4 related files anymore.
* Update debian/kde-style-qtcurve-qt5.install.
* Update debian/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****************************************************************************
2
 
 *   Copyright 2003 - 2010 Craig Drummond <craig.p.drummond@gmail.com>       *
3
 
 *   Copyright 2013 - 2014 Yichao Yu <yyc1992@gmail.com>                     *
4
 
 *                                                                           *
5
 
 *   This program is free software; you can redistribute it and/or modify    *
6
 
 *   it under the terms of the GNU Lesser General Public License as          *
7
 
 *   published by the Free Software Foundation; either version 2.1 of the    *
8
 
 *   License, or (at your option) version 3, or any later version accepted   *
9
 
 *   by the membership of KDE e.V. (or its successor approved by the         *
10
 
 *   membership of KDE e.V.), which shall act as a proxy defined in          *
11
 
 *   Section 6 of version 3 of the license.                                  *
12
 
 *                                                                           *
13
 
 *   This program is distributed in the hope that it will be useful,         *
14
 
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
15
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
16
 
 *   Lesser General Public License for more details.                         *
17
 
 *                                                                           *
18
 
 *   You should have received a copy of the GNU Lesser General Public        *
19
 
 *   License along with this library. If not,                                *
20
 
 *   see <http://www.gnu.org/licenses/>.                                     *
21
 
 *****************************************************************************/
22
 
 
23
 
#include <qtcurve-utils/x11qtc.h>
24
 
#include <qtcurve-utils/x11wrap.h>
25
 
#include <qtcurve-utils/gtkprops.h>
26
 
#include <qtcurve-utils/log.h>
27
 
#include <qtcurve-cairo/utils.h>
28
 
 
29
 
#include <gdk/gdkkeysyms.h>
30
 
#include <gdk/gdkx.h>
31
 
#include <common/common.h>
32
 
#include <common/config_file.h>
33
 
#include "qt_settings.h"
34
 
#include "window.h"
35
 
#include "menu.h"
36
 
 
37
 
extern Options opts;
38
 
 
39
 
static GtkWidget *qtcCurrentActiveWindow = NULL;
40
 
 
41
 
typedef struct {
42
 
    int width;
43
 
    int height;
44
 
    int timer;
45
 
    GtkWidget *widget;
46
 
    gboolean locked;
47
 
} QtCWindow;
48
 
 
49
 
static GHashTable *qtcWindowTable = NULL;
50
 
 
51
 
static QtCWindow*
52
 
qtcWindowLookupHash(void *hash, gboolean create)
53
 
{
54
 
    QtCWindow *rv = NULL;
55
 
 
56
 
    if (!qtcWindowTable)
57
 
        qtcWindowTable = g_hash_table_new(g_direct_hash, g_direct_equal);
58
 
 
59
 
    rv = (QtCWindow*)g_hash_table_lookup(qtcWindowTable, hash);
60
 
 
61
 
    if (!rv && create) {
62
 
        rv = qtcNew(QtCWindow);
63
 
        rv->width = rv->height = rv->timer = 0;
64
 
        rv->widget = NULL;
65
 
        rv->locked = false;
66
 
        g_hash_table_insert(qtcWindowTable, hash, rv);
67
 
        rv = g_hash_table_lookup(qtcWindowTable, hash);
68
 
    }
69
 
    return rv;
70
 
}
71
 
 
72
 
static void
73
 
qtcWindowRemoveFromHash(void *hash)
74
 
{
75
 
    if (qtcWindowTable) {
76
 
        QtCWindow *tv = qtcWindowLookupHash(hash, false);
77
 
        if (tv) {
78
 
            if (tv->timer) {
79
 
                g_source_remove(tv->timer);
80
 
                g_object_unref(G_OBJECT(tv->widget));
81
 
            }
82
 
            g_hash_table_remove(qtcWindowTable, hash);
83
 
        }
84
 
    }
85
 
}
86
 
 
87
 
static void
88
 
qtcWindowCleanup(GtkWidget *widget)
89
 
{
90
 
    if (widget) {
91
 
        QTC_DEF_WIDGET_PROPS(props, widget);
92
 
        if (!(qtcIsFlatBgnd(opts.bgndAppearance)) ||
93
 
            opts.bgndImage.type != IMG_NONE) {
94
 
            qtcWindowRemoveFromHash(widget);
95
 
            qtcDisconnectFromProp(props, windowConfigure);
96
 
        }
97
 
        qtcDisconnectFromProp(props, windowDestroy);
98
 
        qtcDisconnectFromProp(props, windowStyleSet);
99
 
        if ((opts.menubarHiding & HIDE_KEYBOARD) ||
100
 
            (opts.statusbarHiding & HIDE_KEYBOARD))
101
 
            qtcDisconnectFromProp(props, windowKeyRelease);
102
 
        if ((opts.menubarHiding & HIDE_KWIN) ||
103
 
            (opts.statusbarHiding & HIDE_KWIN))
104
 
            qtcDisconnectFromProp(props, windowMap);
105
 
        if (opts.shadeMenubarOnlyWhenActive || BLEND_TITLEBAR ||
106
 
            opts.menubarHiding || opts.statusbarHiding)
107
 
            qtcDisconnectFromProp(props, windowClientEvent);
108
 
        qtcWidgetProps(props)->windowHacked = false;
109
 
    }
110
 
}
111
 
 
112
 
static gboolean
113
 
qtcWindowStyleSet(GtkWidget *widget, GtkStyle *prev_style, void *data)
114
 
{
115
 
    QTC_UNUSED(prev_style);
116
 
    QTC_UNUSED(data);
117
 
    qtcWindowCleanup(widget);
118
 
    return false;
119
 
}
120
 
 
121
 
static gboolean qtcWindowToggleMenuBar(GtkWidget *widget);
122
 
static gboolean qtcWindowToggleStatusBar(GtkWidget *widget);
123
 
 
124
 
static gboolean
125
 
qtcWindowClientEvent(GtkWidget *widget, GdkEventClient *event, void *data)
126
 
{
127
 
    QTC_UNUSED(data);
128
 
    if (gdk_x11_atom_to_xatom(event->message_type) ==
129
 
        qtc_x11_qtc_active_window) {
130
 
        if (event->data.l[0]) {
131
 
            qtcCurrentActiveWindow = widget;
132
 
        } else if (qtcCurrentActiveWindow == widget) {
133
 
            qtcCurrentActiveWindow = 0L;
134
 
        }
135
 
        gtk_widget_queue_draw(widget);
136
 
    } else if (gdk_x11_atom_to_xatom(event->message_type) ==
137
 
               qtc_x11_qtc_titlebar_size) {
138
 
        qtcGetWindowBorderSize(true);
139
 
        GtkWidget *menubar = qtcWindowGetMenuBar(widget, 0);
140
 
 
141
 
        if (menubar) {
142
 
            gtk_widget_queue_draw(menubar);
143
 
        }
144
 
    } else if (gdk_x11_atom_to_xatom(event->message_type) ==
145
 
               qtc_x11_qtc_toggle_menubar) {
146
 
        if (opts.menubarHiding & HIDE_KWIN && qtcWindowToggleMenuBar(widget)) {
147
 
            gtk_widget_queue_draw(widget);
148
 
        }
149
 
    } else if (gdk_x11_atom_to_xatom(event->message_type) ==
150
 
               qtc_x11_qtc_toggle_statusbar) {
151
 
        if (opts.statusbarHiding & HIDE_KWIN &&
152
 
            qtcWindowToggleStatusBar(widget)) {
153
 
            gtk_widget_queue_draw(widget);
154
 
        }
155
 
    }
156
 
    return false;
157
 
}
158
 
 
159
 
static gboolean
160
 
qtcWindowDestroy(GtkWidget *widget, GdkEvent *event, void *data)
161
 
{
162
 
    QTC_UNUSED(event);
163
 
    QTC_UNUSED(data);
164
 
    qtcWindowCleanup(widget);
165
 
    return false;
166
 
}
167
 
 
168
 
gboolean
169
 
qtcWindowIsActive(GtkWidget *widget)
170
 
{
171
 
    return widget && (gtk_window_is_active(GTK_WINDOW(widget)) ||
172
 
                      qtcCurrentActiveWindow == widget);
173
 
}
174
 
 
175
 
static gboolean
176
 
qtcWindowSizeRequest(GtkWidget *widget)
177
 
{
178
 
    if (widget && (!(qtcIsFlatBgnd(opts.bgndAppearance)) ||
179
 
                   IMG_NONE != opts.bgndImage.type)) {
180
 
        QtcRect alloc = qtcWidgetGetAllocation(widget);
181
 
        QtcRect rect = {0, 0, 0, 0};
182
 
        if (qtcIsFlat(opts.bgndAppearance) &&
183
 
            IMG_NONE != opts.bgndImage.type) {
184
 
            EPixPos pos = (IMG_FILE == opts.bgndImage.type ?
185
 
                           opts.bgndImage.pos : PP_TR);
186
 
            if (opts.bgndImage.type == IMG_FILE) {
187
 
                qtcLoadBgndImage(&opts.bgndImage);
188
 
            }
189
 
            switch (pos) {
190
 
            case PP_TL:
191
 
                rect.width  = opts.bgndImage.width + 1;
192
 
                rect.height = opts.bgndImage.height + 1;
193
 
                break;
194
 
            case PP_TM:
195
 
            case PP_TR:
196
 
                rect.width = alloc.width;
197
 
                rect.height = (opts.bgndImage.type == IMG_FILE ?
198
 
                               opts.bgndImage.height :
199
 
                               RINGS_HEIGHT(opts.bgndImage.type)) + 1;
200
 
                break;
201
 
            case PP_LM:
202
 
            case PP_BL:
203
 
                rect.width = opts.bgndImage.width + 1;
204
 
                rect.height = alloc.height;
205
 
                break;
206
 
            case PP_CENTRED:
207
 
            case PP_BR:
208
 
            case PP_BM:
209
 
            case PP_RM:
210
 
                rect.width = alloc.width;
211
 
                rect.height = alloc.height;
212
 
                break;
213
 
            }
214
 
            if (alloc.width < rect.width) {
215
 
                rect.width = alloc.width;
216
 
            }
217
 
            if (alloc.height < rect.height) {
218
 
                rect.height = alloc.height;
219
 
            }
220
 
        } else {
221
 
            rect.width = alloc.width, rect.height = alloc.height;
222
 
        }
223
 
        gdk_window_invalidate_rect(gtk_widget_get_window(widget),
224
 
                                   (GdkRectangle*)&rect, false);
225
 
    }
226
 
    return false;
227
 
}
228
 
 
229
 
static gboolean
230
 
qtcWindowDelayedUpdate(void *user_data)
231
 
{
232
 
    QtCWindow *window = (QtCWindow*)user_data;
233
 
 
234
 
    if (window) {
235
 
        if (window->locked) {
236
 
            window->locked = false;
237
 
            return true;
238
 
        } else {
239
 
            g_source_remove(window->timer);
240
 
            window->timer = 0;
241
 
            // otherwise, trigger update
242
 
            gdk_threads_enter();
243
 
            qtcWindowSizeRequest(window->widget);
244
 
            gdk_threads_leave();
245
 
            g_object_unref(G_OBJECT(window->widget));
246
 
            return false;
247
 
        }
248
 
    }
249
 
    return false;
250
 
}
251
 
 
252
 
static gboolean
253
 
qtcWindowConfigure(GtkWidget *widget, GdkEventConfigure *event, void *data)
254
 
{
255
 
    QTC_UNUSED(widget);
256
 
    QtCWindow *window = (QtCWindow*)data;
257
 
 
258
 
    if (window && (event->width != window->width ||
259
 
                   event->height != window->height)) {
260
 
        window->width = event->width;
261
 
        window->height = event->height;
262
 
 
263
 
        // schedule delayed timeOut
264
 
        if (!window->timer) {
265
 
            g_object_ref(G_OBJECT(window->widget));
266
 
            window->timer =
267
 
                g_timeout_add(50, qtcWindowDelayedUpdate, window);
268
 
            window->locked = false;
269
 
        } else {
270
 
            window->locked = true;
271
 
        }
272
 
    }
273
 
    return false;
274
 
}
275
 
 
276
 
static gboolean
277
 
canGetChildren(GtkWidget *widget)
278
 
{
279
 
    return (GTK_APP_GHB != qtSettings.app ||
280
 
            0 != strcmp(g_type_name(G_OBJECT_TYPE(widget)), "GhbCompositor") ||
281
 
            gtk_widget_get_realized(widget));
282
 
}
283
 
 
284
 
GtkWidget*
285
 
qtcWindowGetMenuBar(GtkWidget *parent, int level)
286
 
{
287
 
    if (level < 3 && GTK_IS_CONTAINER(parent) && canGetChildren(parent)
288
 
        /* && gtk_widget_get_realized(parent)*/) {
289
 
        GtkWidget *rv = NULL;
290
 
        GList *children = gtk_container_get_children(GTK_CONTAINER(parent));
291
 
        for (GList *child = children;child && !rv;child = child->next) {
292
 
            GtkWidget *boxChild = (GtkWidget*)child->data;
293
 
 
294
 
            if (GTK_IS_MENU_BAR(boxChild)) {
295
 
                rv = GTK_WIDGET(boxChild);
296
 
            } else if (GTK_IS_CONTAINER(boxChild)) {
297
 
                rv=qtcWindowGetMenuBar(GTK_WIDGET(boxChild), level + 1);
298
 
            }
299
 
        }
300
 
 
301
 
        if (children) {
302
 
            g_list_free(children);
303
 
        }
304
 
        return rv;
305
 
    }
306
 
    return NULL;
307
 
}
308
 
 
309
 
GtkWidget*
310
 
qtcWindowGetStatusBar(GtkWidget *parent, int level)
311
 
{
312
 
    if (level < 3 && GTK_IS_CONTAINER(parent) && canGetChildren(parent)
313
 
        /* && gtk_widget_get_realized(parent)*/) {
314
 
        GtkWidget *rv = NULL;
315
 
        GList *children = gtk_container_get_children(GTK_CONTAINER(parent));
316
 
        for(GList *child = children;child && !rv;child = child->next) {
317
 
            GtkWidget *boxChild = (GtkWidget*)child->data;
318
 
 
319
 
            if (GTK_IS_STATUSBAR(boxChild)) {
320
 
                rv=GTK_WIDGET(boxChild);
321
 
            } else if (GTK_IS_CONTAINER(boxChild)) {
322
 
                rv=qtcWindowGetStatusBar(GTK_WIDGET(boxChild), level + 1);
323
 
            }
324
 
        }
325
 
        if (children) {
326
 
            g_list_free(children);
327
 
        }
328
 
        return rv;
329
 
    }
330
 
    return NULL;
331
 
}
332
 
 
333
 
void
334
 
qtcWindowMenuBarDBus(GtkWidget *widget, int size)
335
 
{
336
 
    GtkWindow *topLevel = GTK_WINDOW(gtk_widget_get_toplevel(widget));
337
 
    unsigned int xid = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(topLevel)));
338
 
 
339
 
    char cmd[160];
340
 
    //sprintf(cmd, "qdbus org.kde.kwin /QtCurve menuBarSize %u %d", xid, size);
341
 
    sprintf(cmd, "dbus-send --type=method_call --session --dest=org.kde.kwin /QtCurve org.kde.QtCurve.menuBarSize uint32:%u int32:%d",
342
 
            xid, size);
343
 
    system(cmd);
344
 
    /*
345
 
      char         xidS[16],
346
 
      sizeS[16];
347
 
      char         *args[]={"qdbus", "org.kde.kwin", "/QtCurve", "menuBarSize", xidS, sizeS, NULL};
348
 
 
349
 
      sprintf(xidS, "%u", xid);
350
 
      sprintf(sizeS, "%d", size);
351
 
      g_spawn_async("/tmp", args, NULL, (GSpawnFlags)0, NULL, NULL, NULL, NULL);
352
 
    */
353
 
}
354
 
 
355
 
void
356
 
qtcWindowStatusBarDBus(GtkWidget *widget, gboolean state)
357
 
{
358
 
    GtkWindow *topLevel = GTK_WINDOW(gtk_widget_get_toplevel(widget));
359
 
    unsigned int xid = GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(topLevel)));
360
 
 
361
 
    char cmd[160];
362
 
    //sprintf(cmd, "qdbus org.kde.kwin /QtCurve statusBarState %u %s", xid, state ? "true" : "false");
363
 
    sprintf(cmd, "dbus-send --type=method_call --session --dest=org.kde.kwin /QtCurve org.kde.QtCurve.statusBarState uint32:%u boolean:%s",
364
 
            xid, state ? "true" : "false");
365
 
    system(cmd);
366
 
    /*
367
 
      char         xidS[16],
368
 
      stateS[6];
369
 
      char         *args[]={"qdbus", "org.kde.kwin", "/QtCurve", "statusBarState", xidS, stateS, NULL};
370
 
 
371
 
      sprintf(xidS, "%u", xid);
372
 
      sprintf(stateS, "%s", state ? "true" : "false");
373
 
      g_spawn_async("/tmp", args, NULL, (GSpawnFlags)0, NULL, NULL, NULL, NULL);
374
 
    */
375
 
}
376
 
 
377
 
static gboolean
378
 
qtcWindowToggleMenuBar(GtkWidget *widget)
379
 
{
380
 
    GtkWidget *menuBar = qtcWindowGetMenuBar(widget, 0);
381
 
 
382
 
    if (menuBar) {
383
 
        int size = 0;
384
 
        qtcSetMenuBarHidden(qtSettings.appName, gtk_widget_get_visible(menuBar));
385
 
        if (gtk_widget_get_visible(menuBar)) {
386
 
            gtk_widget_hide(menuBar);
387
 
        } else {
388
 
            size = qtcWidgetGetAllocation(menuBar).height;
389
 
            gtk_widget_show(menuBar);
390
 
        }
391
 
 
392
 
        qtcMenuEmitSize(menuBar, size);
393
 
        qtcWindowMenuBarDBus(widget, size);
394
 
        return true;
395
 
    }
396
 
    return false;
397
 
}
398
 
 
399
 
gboolean
400
 
qtcWindowSetStatusBarProp(GtkWidget *w)
401
 
{
402
 
    QTC_DEF_WIDGET_PROPS(props, w);
403
 
    if (w && !qtcWidgetProps(props)->statusBarSet) {
404
 
        GtkWindow *topLevel = GTK_WINDOW(gtk_widget_get_toplevel(w));
405
 
        xcb_window_t wid =
406
 
            GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(topLevel)));
407
 
 
408
 
        qtcWidgetProps(props)->statusBarSet = true;
409
 
        qtcX11SetStatusBar(wid);
410
 
        return true;
411
 
    }
412
 
    return false;
413
 
}
414
 
 
415
 
static gboolean
416
 
qtcWindowToggleStatusBar(GtkWidget *widget)
417
 
{
418
 
    GtkWidget *statusBar = qtcWindowGetStatusBar(widget, 0);
419
 
 
420
 
    if (statusBar) {
421
 
        bool state = gtk_widget_get_visible(statusBar);
422
 
        qtcSetStatusBarHidden(qtSettings.appName, state);
423
 
        if (state) {
424
 
            gtk_widget_hide(statusBar);
425
 
        } else {
426
 
            gtk_widget_show(statusBar);
427
 
        }
428
 
        qtcWindowStatusBarDBus(widget, state);
429
 
        return true;
430
 
    }
431
 
    return false;
432
 
}
433
 
 
434
 
static void
435
 
qtcWindowSetProperties(GtkWidget *w, unsigned short opacity)
436
 
{
437
 
    GtkWindow *topLevel = GTK_WINDOW(gtk_widget_get_toplevel(w));
438
 
    unsigned long prop = (qtcIsFlatBgnd(opts.bgndAppearance) ?
439
 
                          (IMG_NONE != opts.bgndImage.type ?
440
 
                           APPEARANCE_RAISED : APPEARANCE_FLAT) :
441
 
                          opts.bgndAppearance) & 0xFF;
442
 
    //GtkRcStyle *rcStyle=gtk_widget_get_modifier_style(w);
443
 
    GdkColor *bgnd = /* rcStyle ? &rcStyle->bg[GTK_STATE_NORMAL] : */
444
 
        &qtcPalette.background[ORIGINAL_SHADE];
445
 
    xcb_window_t wid =
446
 
        GDK_WINDOW_XID(gtk_widget_get_window(GTK_WIDGET(topLevel)));
447
 
 
448
 
    if (opacity != 100) {
449
 
        qtcX11SetOpacity(wid, opacity);
450
 
    }
451
 
    prop |= (((toQtColor(bgnd->red) & 0xFF) << 24) |
452
 
             ((toQtColor(bgnd->green) & 0xFF) << 16) |
453
 
             ((toQtColor(bgnd->blue) & 0xFF) << 8));
454
 
    qtcX11ChangeProperty(XCB_PROP_MODE_REPLACE, wid, qtc_x11_qtc_bgnd,
455
 
                         XCB_ATOM_CARDINAL, 32, 1, &prop);
456
 
    qtcX11Flush();
457
 
}
458
 
 
459
 
static gboolean
460
 
qtcWindowKeyRelease(GtkWidget *widget, GdkEventKey *event, void *user_data)
461
 
{
462
 
    QTC_UNUSED(user_data);
463
 
    // Ensure only ctrl/alt/shift/capsLock are pressed...
464
 
    if (GDK_CONTROL_MASK & event->state && GDK_MOD1_MASK & event->state &&
465
 
        !event->is_modifier && 0 == (event->state & 0xFF00)) {
466
 
        bool toggled = false;
467
 
        if (opts.menubarHiding & HIDE_KEYBOARD &&
468
 
            (GDK_KEY_m == event->keyval || GDK_KEY_M == event->keyval)) {
469
 
            toggled = qtcWindowToggleMenuBar(widget);
470
 
        }
471
 
        if (opts.statusbarHiding & HIDE_KEYBOARD &&
472
 
            (GDK_KEY_s == event->keyval || GDK_KEY_S == event->keyval)) {
473
 
            toggled = qtcWindowToggleStatusBar(widget);
474
 
        }
475
 
        if (toggled) {
476
 
            gtk_widget_queue_draw(widget);
477
 
        }
478
 
    }
479
 
    return false;
480
 
}
481
 
 
482
 
static gboolean
483
 
qtcWindowMap(GtkWidget *widget, GdkEventKey *event, void *user_data)
484
 
{
485
 
    QTC_UNUSED(event);
486
 
    QTC_UNUSED(user_data);
487
 
    QTC_DEF_WIDGET_PROPS(props, widget);
488
 
    qtcWindowSetProperties(widget, qtcWidgetProps(props)->windowOpacity);
489
 
 
490
 
    if (opts.menubarHiding & HIDE_KWIN) {
491
 
        GtkWidget *menuBar = qtcWindowGetMenuBar(widget, 0);
492
 
 
493
 
        if (menuBar) {
494
 
            int size = (gtk_widget_get_visible(menuBar) ?
495
 
                        qtcWidgetGetAllocation(menuBar).height : 0);
496
 
 
497
 
            qtcMenuEmitSize(menuBar, size);
498
 
            qtcWindowMenuBarDBus(widget, size);
499
 
        }
500
 
    }
501
 
 
502
 
    if(opts.statusbarHiding&HIDE_KWIN)
503
 
    {
504
 
        GtkWidget *statusBar=qtcWindowGetStatusBar(widget, 0);
505
 
 
506
 
        if(statusBar)
507
 
            qtcWindowStatusBarDBus(widget, !gtk_widget_get_visible(statusBar));
508
 
    }
509
 
    return false;
510
 
}
511
 
 
512
 
gboolean
513
 
qtcWindowSetup(GtkWidget *widget, int opacity)
514
 
{
515
 
    QTC_DEF_WIDGET_PROPS(props, widget);
516
 
    if (widget && !qtcWidgetProps(props)->windowHacked) {
517
 
        qtcWidgetProps(props)->windowHacked = true;
518
 
        if (!qtcIsFlatBgnd(opts.bgndAppearance) ||
519
 
            opts.bgndImage.type != IMG_NONE) {
520
 
            QtCWindow *window = qtcWindowLookupHash(widget, true);
521
 
            if (window) {
522
 
                QtcRect alloc = qtcWidgetGetAllocation(widget);
523
 
                qtcConnectToProp(props, windowConfigure, "configure-event",
524
 
                                 qtcWindowConfigure, window);
525
 
                window->width = alloc.width;
526
 
                window->height = alloc.height;
527
 
                window->widget = widget;
528
 
            }
529
 
        }
530
 
        qtcConnectToProp(props, windowDestroy, "destroy-event",
531
 
                         qtcWindowDestroy, NULL);
532
 
        qtcConnectToProp(props, windowStyleSet, "style-set",
533
 
                         qtcWindowStyleSet, NULL);
534
 
        if ((opts.menubarHiding & HIDE_KEYBOARD) ||
535
 
            (opts.statusbarHiding & HIDE_KEYBOARD)) {
536
 
            qtcConnectToProp(props, windowKeyRelease, "key-release-event",
537
 
                             qtcWindowKeyRelease, NULL);
538
 
        }
539
 
        qtcWidgetProps(props)->windowOpacity = (unsigned short)opacity;
540
 
        qtcWindowSetProperties(widget, (unsigned short)opacity);
541
 
 
542
 
        if ((opts.menubarHiding & HIDE_KWIN) ||
543
 
            (opts.statusbarHiding & HIDE_KWIN) || 100 != opacity)
544
 
            qtcConnectToProp(props, windowMap, "map-event", qtcWindowMap, NULL);
545
 
        if (opts.shadeMenubarOnlyWhenActive || BLEND_TITLEBAR ||
546
 
            opts.menubarHiding || opts.statusbarHiding)
547
 
            qtcConnectToProp(props, windowClientEvent, "client-event",
548
 
                             qtcWindowClientEvent, NULL);
549
 
        return true;
550
 
    }
551
 
    return false;
552
 
}