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