1*4882a593Smuzhiyun /* 2*4882a593Smuzhiyun * Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved. 3*4882a593Smuzhiyun * Copyright (C) Colin Harrison 2005-2008 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining 6*4882a593Smuzhiyun * a copy of this software and associated documentation files (the 7*4882a593Smuzhiyun * "Software"), to deal in the Software without restriction, including 8*4882a593Smuzhiyun * without limitation the rights to use, copy, modify, merge, publish, 9*4882a593Smuzhiyun * distribute, sublicense, and/or sell copies of the Software, and to 10*4882a593Smuzhiyun * permit persons to whom the Software is furnished to do so, subject to 11*4882a593Smuzhiyun * the following conditions: 12*4882a593Smuzhiyun * 13*4882a593Smuzhiyun * The above copyright notice and this permission notice shall be 14*4882a593Smuzhiyun * included in all copies or substantial portions of the Software. 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17*4882a593Smuzhiyun * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18*4882a593Smuzhiyun * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19*4882a593Smuzhiyun * NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR 20*4882a593Smuzhiyun * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 21*4882a593Smuzhiyun * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22*4882a593Smuzhiyun * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23*4882a593Smuzhiyun * 24*4882a593Smuzhiyun * Except as contained in this notice, the name of the XFree86 Project 25*4882a593Smuzhiyun * shall not be used in advertising or otherwise to promote the sale, use 26*4882a593Smuzhiyun * or other dealings in this Software without prior written authorization 27*4882a593Smuzhiyun * from the XFree86 Project. 28*4882a593Smuzhiyun * 29*4882a593Smuzhiyun * Authors: Earle F. Philhower, III 30*4882a593Smuzhiyun * Colin Harrison 31*4882a593Smuzhiyun */ 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #if !defined(WINPREFS_H) 34*4882a593Smuzhiyun #define WINPREFS_H 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun /* Need Bool */ 37*4882a593Smuzhiyun #include <X11/Xdefs.h> 38*4882a593Smuzhiyun /* Need TRUE */ 39*4882a593Smuzhiyun #include "misc.h" 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun /* Need to know how long paths can be... */ 42*4882a593Smuzhiyun #include <limits.h> 43*4882a593Smuzhiyun /* Xwindows redefines PATH_MAX to at least 1024 */ 44*4882a593Smuzhiyun #include <X11/Xwindows.h> 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun #include "winwindow.h" 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun #ifndef NAME_MAX 49*4882a593Smuzhiyun #define NAME_MAX PATH_MAX 50*4882a593Smuzhiyun #endif 51*4882a593Smuzhiyun #define MENU_MAX 128 /* Maximum string length of a menu name or item */ 52*4882a593Smuzhiyun #define PARAM_MAX (4*PATH_MAX) /* Maximum length of a parameter to a MENU */ 53*4882a593Smuzhiyun 54*4882a593Smuzhiyun /* Supported commands in a MENU {} statement */ 55*4882a593Smuzhiyun typedef enum MENUCOMMANDTYPE { 56*4882a593Smuzhiyun CMD_EXEC, /* /bin/sh -c the parameter */ 57*4882a593Smuzhiyun CMD_MENU, /* Display a popup menu named param */ 58*4882a593Smuzhiyun CMD_SEPARATOR, /* Menu separator */ 59*4882a593Smuzhiyun CMD_ALWAYSONTOP, /* Toggle always-on-top mode */ 60*4882a593Smuzhiyun CMD_RELOAD /* Reparse the .XWINRC file */ 61*4882a593Smuzhiyun } MENUCOMMANDTYPE; 62*4882a593Smuzhiyun 63*4882a593Smuzhiyun #define STYLE_NONE (0L) /* Dummy the first entry */ 64*4882a593Smuzhiyun #define STYLE_NOTITLE (1L) /* Force window style no titlebar */ 65*4882a593Smuzhiyun #define STYLE_OUTLINE (1L<<1) /* Force window style just thin-line border */ 66*4882a593Smuzhiyun #define STYLE_NOFRAME (1L<<2) /* Force window style no frame */ 67*4882a593Smuzhiyun #define STYLE_TOPMOST (1L<<3) /* Open a window always-on-top */ 68*4882a593Smuzhiyun #define STYLE_MAXIMIZE (1L<<4) /* Open a window maximized */ 69*4882a593Smuzhiyun #define STYLE_MINIMIZE (1L<<5) /* Open a window minimized */ 70*4882a593Smuzhiyun #define STYLE_BOTTOM (1L<<6) /* Open a window at the bottom of the Z order */ 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun /* Where to place a system menu */ 73*4882a593Smuzhiyun typedef enum MENUPOSITION { 74*4882a593Smuzhiyun AT_START, /* Place menu at the top of the system menu */ 75*4882a593Smuzhiyun AT_END /* Put it at the bottom of the menu (default) */ 76*4882a593Smuzhiyun } MENUPOSITION; 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun /* Menu item definitions */ 79*4882a593Smuzhiyun typedef struct MENUITEM { 80*4882a593Smuzhiyun char text[MENU_MAX + 1]; /* To be displayed in menu */ 81*4882a593Smuzhiyun MENUCOMMANDTYPE cmd; /* What should it do? */ 82*4882a593Smuzhiyun char param[PARAM_MAX + 1]; /* Any parameters? */ 83*4882a593Smuzhiyun unsigned long commandID; /* Windows WM_COMMAND ID assigned at runtime */ 84*4882a593Smuzhiyun } MENUITEM; 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun /* A completely read in menu... */ 87*4882a593Smuzhiyun typedef struct MENUPARSED { 88*4882a593Smuzhiyun char menuName[MENU_MAX + 1]; /* What's it called in the text? */ 89*4882a593Smuzhiyun MENUITEM *menuItem; /* Array of items */ 90*4882a593Smuzhiyun int menuItems; /* How big's the array? */ 91*4882a593Smuzhiyun } MENUPARSED; 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun /* To map between a window and a system menu to add for it */ 94*4882a593Smuzhiyun typedef struct SYSMENUITEM { 95*4882a593Smuzhiyun char match[MENU_MAX + 1]; /* String to look for to apply this sysmenu */ 96*4882a593Smuzhiyun char menuName[MENU_MAX + 1]; /* Which menu to show? Used to set *menu */ 97*4882a593Smuzhiyun MENUPOSITION menuPos; /* Where to place it (ignored in root) */ 98*4882a593Smuzhiyun } SYSMENUITEM; 99*4882a593Smuzhiyun 100*4882a593Smuzhiyun /* To redefine icons for certain window types */ 101*4882a593Smuzhiyun typedef struct ICONITEM { 102*4882a593Smuzhiyun char match[MENU_MAX + 1]; /* What string to search for? */ 103*4882a593Smuzhiyun char iconFile[PATH_MAX + NAME_MAX + 2]; /* Icon location, WIN32 path */ 104*4882a593Smuzhiyun HICON hicon; /* LoadImage() result */ 105*4882a593Smuzhiyun } ICONITEM; 106*4882a593Smuzhiyun 107*4882a593Smuzhiyun /* To redefine styles for certain window types */ 108*4882a593Smuzhiyun typedef struct STYLEITEM { 109*4882a593Smuzhiyun char match[MENU_MAX + 1]; /* What string to search for? */ 110*4882a593Smuzhiyun unsigned long type; /* What should it do? */ 111*4882a593Smuzhiyun } STYLEITEM; 112*4882a593Smuzhiyun 113*4882a593Smuzhiyun typedef struct WINPREFS { 114*4882a593Smuzhiyun /* Menu information */ 115*4882a593Smuzhiyun MENUPARSED *menu; /* Array of created menus */ 116*4882a593Smuzhiyun int menuItems; /* How big? */ 117*4882a593Smuzhiyun 118*4882a593Smuzhiyun /* Taskbar menu settings */ 119*4882a593Smuzhiyun char rootMenuName[MENU_MAX + 1]; /* Menu for taskbar icon */ 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun /* System menu addition menus */ 122*4882a593Smuzhiyun SYSMENUITEM *sysMenu; 123*4882a593Smuzhiyun int sysMenuItems; 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun /* Which menu to add to unmatched windows? */ 126*4882a593Smuzhiyun char defaultSysMenuName[MENU_MAX + 1]; 127*4882a593Smuzhiyun MENUPOSITION defaultSysMenuPos; /* Where to place it */ 128*4882a593Smuzhiyun 129*4882a593Smuzhiyun /* Icon information */ 130*4882a593Smuzhiyun char iconDirectory[PATH_MAX + 1]; /* Where do the .icos lie? (Win32 path) */ 131*4882a593Smuzhiyun char defaultIconName[NAME_MAX + 1]; /* Replacement for x.ico */ 132*4882a593Smuzhiyun char trayIconName[NAME_MAX + 1]; /* Replacement for tray icon */ 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun ICONITEM *icon; 135*4882a593Smuzhiyun int iconItems; 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun STYLEITEM *style; 138*4882a593Smuzhiyun int styleItems; 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun /* Force exit flag */ 141*4882a593Smuzhiyun Bool fForceExit; 142*4882a593Smuzhiyun 143*4882a593Smuzhiyun /* Silent exit flag */ 144*4882a593Smuzhiyun Bool fSilentExit; 145*4882a593Smuzhiyun 146*4882a593Smuzhiyun } WINPREFS; 147*4882a593Smuzhiyun 148*4882a593Smuzhiyun /* The global pref settings structure loaded by the winprefyacc.y parser */ 149*4882a593Smuzhiyun extern WINPREFS pref; 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun /* Functions */ 152*4882a593Smuzhiyun void 153*4882a593Smuzhiyun LoadPreferences(void); 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun void 156*4882a593Smuzhiyun SetupRootMenu(HMENU root); 157*4882a593Smuzhiyun 158*4882a593Smuzhiyun void 159*4882a593Smuzhiyun SetupSysMenu(HWND hwnd); 160*4882a593Smuzhiyun 161*4882a593Smuzhiyun void 162*4882a593Smuzhiyun HandleCustomWM_INITMENU(HWND hwnd, HMENU hmenu); 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun Bool 165*4882a593Smuzhiyun HandleCustomWM_COMMAND(HWND hwnd, WORD command, winPrivScreenPtr pScreenPriv); 166*4882a593Smuzhiyun 167*4882a593Smuzhiyun int 168*4882a593Smuzhiyun winIconIsOverride(HICON hicon); 169*4882a593Smuzhiyun 170*4882a593Smuzhiyun HICON winOverrideIcon(char *res_name, char *res_class, char *wmName); 171*4882a593Smuzhiyun 172*4882a593Smuzhiyun unsigned long 173*4882a593Smuzhiyun winOverrideStyle(char *res_name, char *res_class, char *wmName); 174*4882a593Smuzhiyun 175*4882a593Smuzhiyun HICON winTaskbarIcon(void); 176*4882a593Smuzhiyun 177*4882a593Smuzhiyun HICON winOverrideDefaultIcon(int size); 178*4882a593Smuzhiyun #endif 179