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