1 /* 2 * This file is part of Licq, an instant messaging client for UNIX. 3 * Copyright (C) 2006-2012 Licq developers <licq-dev@googlegroups.com> 4 * 5 * Licq is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * Licq is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Licq; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef SUPPORT_H 21 #define SUPPORT_H 22 23 #include <QWidget> 24 25 namespace LicqQtGui 26 { 27 /* 28 * Class holding support functions for LICQ windows 29 * 30 * Contains various functions needed by multiple windows and dialogs 31 */ 32 class Support 33 { 34 public: 35 /** 36 * Changes the stickiness state of the window 37 * Makes the window appear on all desktops, 38 * i.e. makes it omnipresent. 39 * 40 * @param win The window id to change stickiness for 41 * @param stick The desired stickiness state 42 */ 43 static void changeWinSticky(WId win, bool stick); 44 45 /** 46 * Sets widget name 47 * In case of running on X11, sets WM_WINDOW_ROLE and XClassHint.res_name 48 * for a window to allow window managers properly recognize it. 49 * 50 * @param widget The widget to set a name for 51 * @param name The name to be set 52 */ 53 static void setWidgetProps(QWidget* widget, const QString& name); 54 55 /** 56 * Hides the window from the pager and taskbar 57 * 58 * @param win The window id to ghost 59 */ 60 static void ghostWindow(WId win); 61 62 /** 63 * Turns the window into a docked widget on X11 64 * 65 * @param win The window to dock 66 * @return The handler to be passed to undockWindow() 67 */ 68 static WId dockWindow(WId win); 69 70 /** 71 * Reverts the effect of the previous method and cleans up 72 * 73 * @param win The window to undock 74 * @param handler The handler as returned by dockWindow() 75 */ 76 static void undockWindow(WId win, WId handler); 77 78 #if defined(Q_WS_X11) 79 /** 80 * Translates @a keyCode into @return XModifier 81 */ 82 static unsigned keyToXMod(int keyCode); 83 84 /** 85 * Translates @a keyCode into @return XKeySymbol 86 */ 87 static unsigned keyToXSym(int keyCode); 88 89 /** 90 * Grab/ungrab a global hotkey 91 * 92 * @param dsp X11 Display 93 * @param rootWin Root window that will get key events 94 * @param key Key to grab/ungrab 95 * @param enable True to grab, false to ungrab 96 */ 97 static void grabKey(Display* dsp, Qt::HANDLE rootWin, int key, bool enable); 98 #endif 99 100 private: 101 #if defined(Q_WS_X11) 102 /** 103 * Convenient wrapper to XGetWindowProperty 104 * 105 * The returned value must be deleted with XFree(). 106 */ 107 static unsigned char* getWindowProperty(WId win, const char* prop); 108 #endif 109 }; 110 111 } // namespace LicqQtGui 112 113 #endif 114