1 /* 2 * this file is part of the oxygen gtk engine 3 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 4 * Copyright (c) 2010 Ruslan Kabatsayev <b7.10110111@gmail.com> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or(at your option ) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free 18 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 19 * MA 02110-1301, USA. 20 */ 21 22 #include "oxygenwidgetsizedata.h" 23 #include "../oxygenstyle.h" 24 #include "../oxygengtkutils.h" 25 26 namespace Oxygen 27 { 28 29 //___________________________________________________________________________________________________________ updateMask()30 bool WidgetSizeData::updateMask() 31 { 32 33 /* check widget type, store window and offset */ 34 GdkWindow* window(0); 35 int verticalMaskOffset(0); 36 if( GTK_IS_MENU( _target ) ) 37 { 38 39 window = gtk_widget_get_parent_window( _target ); 40 verticalMaskOffset=Oxygen::Menu_VerticalOffset; 41 42 } else if( 43 Gtk::gtk_is_tooltip( _target ) || 44 Gtk::gtk_combobox_is_popup( _target ) || 45 Gtk::gtk_combo_is_popup( _target ) ) { 46 47 window=gtk_widget_get_window( _target ); 48 49 } else { 50 51 std::cerr << "FIXME: Oxygen::WidgetSizeData: unknown window type: \""<< Gtk::gtk_widget_path( _target )<<"\"\n"; 52 return false; 53 54 } 55 56 const bool alpha( Gtk::gtk_widget_has_rgba( _target ) ); 57 const GtkAllocation allocation( Gtk::gtk_widget_get_allocation( _target ) ); 58 const int &width(allocation.width); 59 const int &height(allocation.height); 60 61 // check modifications 62 const bool sizeChanged( width != _width || height != _height ); 63 const bool alphaChanged( alpha != _alpha ); 64 if( !( sizeChanged || alphaChanged ) ) return false; 65 66 if(!alpha) 67 { 68 69 // make menus/tooltips/combo lists appear rounded using XShape extension if screen isn't composited 70 GdkPixmap* mask( Style::instance().helper().roundMask( width, height - 2*verticalMaskOffset) ); 71 gdk_window_shape_combine_mask( window, mask, 0, verticalMaskOffset ); 72 gdk_pixmap_unref(mask); 73 74 } else { 75 76 // reset mask if compositing has appeared after we had set a mask 77 gdk_window_shape_combine_mask( window, NULL, 0, 0); 78 79 } 80 81 // adjust blur region 82 if( sizeChanged && alpha && 83 ( Gtk::gtk_is_tooltip( _target ) || 84 ( Style::instance().settings().backgroundOpacity() < 255 && GTK_IS_MENU( _target ) ) ) ) 85 { Style::instance().setWindowBlur(window,true); } 86 87 // Update widget properties 88 _width=width; 89 _height=height; 90 _alpha=alpha; 91 92 return sizeChanged; 93 } 94 95 } 96