1 #ifndef HINTS_H_HEADER_INCLUDED 2 #define HINTS_H_HEADER_INCLUDED 3 4 #include <X11/Xmd.h> 5 #include "clientprops.h" 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 struct ASRawHints; 12 struct MwmHints; 13 struct ASDatabaseRecord; 14 struct ASVector; 15 struct ScreenInfo; 16 struct ASFeel; 17 struct ASImage; 18 /***********************************************************************/ 19 /* AfterStep structure to hold summary of all the hints : */ 20 /***********************************************************************/ 21 22 /***********************************************************/ 23 /* AS Startup flags : */ 24 #define AS_StartPosition (1<<0) 25 #define AS_StartPositionUser (1<<1) 26 #define AS_Position (1<<1) 27 #define AS_StartSize (1<<2) 28 #define AS_Size (1<<2) 29 #define AS_StartSizeUser (1<<3) 30 #define AS_StartBorderWidth (1<<4) 31 #define AS_BorderWidth (1<<4) 32 /* Viewport cannot be changed after window is mapped : */ 33 #define AS_StartViewportX (1<<5) 34 #define AS_StartViewportY (1<<6) 35 #define AS_StartDesktop (1<<7) 36 #define AS_Desktop (1<<7) 37 #define AS_StartLayer (1<<8) 38 #define AS_Layer (1<<8) 39 /* the following are flags identifying client's status : */ 40 #define AS_StartsIconic (1<<9) 41 #define AS_Iconic (1<<9) 42 #define AS_StartsMaximizedX (1<<10) 43 #define AS_MaximizedX (1<<10) 44 #define AS_StartsMaximizedY (1<<11) 45 #define AS_MaximizedY (1<<11) 46 #define AS_StartsSticky (1<<12) 47 #define AS_Sticky (1<<12) 48 #define AS_StartsShaded (1<<13) 49 #define AS_Shaded (1<<13) 50 /* special state - client withdrawn itself */ 51 #define AS_Withdrawn (1<<14) 52 #define AS_Dead (1<<15) /* dead client - has been destroyd or about to be destroyed */ 53 /* special state - client is mapped - there is a small gap between MapRequest+XMapWindow and MapNotify event */ 54 #define AS_Mapped (1<<16) 55 #define AS_IconMapped (1<<17) 56 #define AS_Hidden (1<<18) 57 #define AS_Shaped (1<<19) /* client itself is shaped */ 58 #define AS_ShapedDecor (1<<20) /* frame decorations use shaped MyStyle */ 59 #define AS_ShapedIcon (1<<21) /* icon decorations use shaped MyStyle */ 60 #define AS_UnMapPending (1<<22) 61 #define AS_MoveresizeInProgress (1<<23) 62 #define AS_Fullscreen (1<<24) 63 #define AS_Urgent (1<<25) 64 #define AS_Focused (1<<26) 65 66 67 /***********************************************************/ 68 /* General flags */ 69 #define AS_MinSize (1<<0) 70 #define AS_MaxSize (1<<1) 71 #define AS_SizeInc (1<<2) 72 #define AS_Aspect (1<<3) 73 #define AS_BaseSize (1<<4) 74 #define AS_Gravity (1<<5) 75 #define AS_PID (1<<6) 76 #define AS_Transient (1<<7) 77 #define AS_AcceptsFocus (1<<8) 78 #define AS_ClickToFocus (1<<9) 79 #define AS_Titlebar (1<<10) 80 #define AS_VerticalTitle (1<<11) 81 #define AS_Border (1<<12) 82 #define AS_Handles (1<<13) 83 #define AS_Frame (1<<14) 84 #define AS_SkipWinList (1<<15) 85 #define AS_DontCirculate (1<<16) 86 #define AS_AvoidCover (1<<17) 87 #define AS_IconTitle (1<<18) 88 #define AS_Icon (1<<19) 89 #define AS_Windowbox (1<<20) 90 #define AS_FocusOnMap (1<<21) 91 #define AS_ShortLived (1<<22) 92 #define AS_Module (1<<23) 93 #define AS_IgnoreConfigRequest (1<<24) 94 #define AS_IgnoreRestackRequest (1<<25) 95 #define AS_WMDockApp (1<<26) /* res_class == "DockApp" and main 96 * window is 1x1 (just don't ask why) 97 * usually that means that icon 98 * window should be animated */ 99 #define AS_UseCurrentViewport (1<<27) 100 #define AS_WindowOpacity (1<<28) 101 #define AS_HitPager (1<<29) 102 103 #define NOLOOK_HINT_FLAGS (AS_IgnoreConfigRequest|AS_Module|AS_ShortLived| \ 104 AS_AvoidCover|AS_AcceptsFocus|AS_ClickToFocus| \ 105 AS_UseCurrentViewport) 106 107 108 /***********************************************************/ 109 /* AS supported protocols : */ 110 #define AS_DoesWmTakeFocus (1<<0) 111 #define AS_DoesWmDeleteWindow (1<<1) 112 #define AS_DoesWmPing (1<<2) 113 #define AS_NeedsVisibleName (1<<3) /* only if window has _NET_WM_NAME hint */ 114 #define AS_DoesKIPC (1<<4) 115 116 /***********************************************************/ 117 /* AS function masks : */ 118 #define AS_FuncPopup (1<<0) 119 #define AS_FuncMinimize (1<<1) 120 #define AS_FuncMaximize (1<<2) 121 #define AS_FuncResize (1<<3) 122 #define AS_FuncMove (1<<4) 123 #define AS_FuncClose (1<<7) 124 #define AS_FuncKill (1<<8) 125 #define AS_FuncPinMenu (1<<9) 126 /***********************************************************/ 127 /* AS layers : */ 128 #define AS_LayerLowest AS_LayerDesktop 129 #define AS_LayerDesktop -10000 /* our desktop - just for the heck of it */ 130 #define AS_LayerOtherDesktop -2 /* for all those other file managers, KDE, GNOME, etc. */ 131 #define AS_LayerBack -1 /* normal windows below */ 132 #define AS_LayerNormal 0 /* normal windows */ 133 #define AS_LayerTop 1 /* normal windows above */ 134 #define AS_LayerService 2 /* primarily for Wharfs, etc. */ 135 #define AS_LayerUrgent 3 /* for modal dialogs that needs urgent answer (System Modal)*/ 136 #define AS_LayerOtherMenu 4 /* for all those other menus - KDE, GNOME, etc. */ 137 #define AS_LayerMenu 10000 /* our menu - can't go wrong with that */ 138 #define AS_LayerHighest AS_LayerMenu 139 140 #define ASHINTS_STATIC_DATA 28 /* number of elements below that are not */ 141 /* dynamic arrays */ 142 143 typedef struct ASHints 144 { 145 /* NULL terminated list of names/aliases */ 146 #define MAX_WINDOW_NAMES 8 147 char *names[MAX_WINDOW_NAMES+1] ; 148 /* these are merely shortcuts to the above list DON'T FREE THEM !!! */ 149 char *res_name, *res_class, *icon_name ; 150 int res_name_idx, res_class_idx, icon_name_idx ; 151 152 unsigned char names_encoding[MAX_WINDOW_NAMES+1]; /* one of the AS_Text_ values */ 153 154 /* these are copy of above done, when ASDatabase was last matched */ 155 char *matched_name0 ; 156 unsigned char matched_name0_encoding; 157 158 ASFlagType flags ; 159 ASFlagType protocols ; 160 ASFlagType function_mask ; 161 162 #define AS_ClientIcon (1<<0) 163 #define AS_ClientIconPixmap (1<<1) 164 #define AS_ClientIconPosition (1<<2) 165 #define AS_ClientIconARGB (1<<3) 166 167 ASFlagType client_icon_flags ; 168 union { Window window; Pixmap pixmap; } icon ; 169 Pixmap icon_mask ; 170 CARD32 *icon_argb ; 171 int icon_x, icon_y ; 172 char *icon_file ; 173 174 int min_width, min_height ; 175 int max_width, max_height ; 176 int width_inc, height_inc ; 177 struct { int x; int y ; } min_aspect, max_aspect ; 178 int base_width, base_height ; 179 int gravity ; 180 unsigned int border_width ; /* this is border width that will be used 181 * in the frame decoration - not to confuse with border width 182 * of the initial withdrawn-to-normal transition */ 183 unsigned int handle_width ; 184 Window group_lead ; 185 Window transient_for; 186 187 CARD32 *cmap_windows ; /* terminated with None value (zero)*/ 188 189 int pid ; 190 191 char *frame_name ; 192 char *windowbox_name ; 193 char *mystyle_names[BACK_STYLES]; 194 195 ASFlagType disabled_buttons ; 196 197 ASFlagType hints_types_raw ; 198 ASFlagType hints_types_clean ; 199 200 char *client_host ; /* hostname of the computer on which client was executed */ 201 char *client_cmd ; /* preparsed command line of the client */ 202 CARD32 window_opacity ; 203 204 ASFlagType extwm_window_type; 205 } 206 ASHints; 207 208 /* the following flags will let us specify what exactly has 209 * changed when hints are updated : */ 210 #define AS_HintChangeName (1<<0) 211 #define AS_HintChangeClass (1<<1) 212 #define AS_HintChangeResName (1<<2) 213 #define AS_HintChangeIconName (1<<3) 214 215 #define AS_HintChangeEverything ASFLAGS_EVERYTHING 216 217 #define ASSTATUSHINTS_STATIC_DATA 11 /* number of elements below that are not */ 218 /* dynamic arrays */ 219 220 typedef struct ASStatusHints 221 { 222 ASFlagType flags ; 223 224 int x, y; 225 unsigned int width, height; 226 unsigned int border_width ; /* this border width is needed only to calculate 227 * reference point when we are starting up */ 228 int viewport_x, viewport_y; 229 int desktop ; 230 int layer ; 231 232 /* get's set by window manager - not read from hints: */ 233 Window icon_window; 234 unsigned int frame_size[FRAME_SIDES]; /* size of the frame decoration */ 235 236 unsigned int frame_border_width ; 237 }ASStatusHints; 238 239 /* 240 * This structure will hold pointers to merge function according to 241 * priorities set by user : 242 */ 243 typedef void (*hints_merge_func)(ASHints* clean, struct ASRawHints *raw, 244 struct ASDatabaseRecord *db_rec, 245 ASStatusHints *status, 246 ASFlagType what); /* see HINT_ flags above */ 247 248 typedef struct ASSupportedHints 249 { 250 ASFlagType hints_flags ; /* 0x1<<type */ 251 HintsTypes hints_types[HINTS_Supported]; 252 hints_merge_func merge_funcs[HINTS_Supported]; 253 int hints_num ; 254 }ASSupportedHints; 255 256 257 258 /*************************************************************************/ 259 /* Interface */ 260 /*************************************************************************/ 261 /* this calculates offset from the anchor position to the left/top corner of the frame : */ 262 #define APPLY_GRAVITY(grav,pos,size,bw1,bw2) \ 263 { switch( (grav) ) \ 264 {case 0 : (pos) -= ((int)(size)>>1)+(int)(bw1) ; break ; /* Center/Forget */ \ 265 case 1 : (pos) -= (int)(bw1)+(int)(bw2)+(int)(size) ; break ; /* South/East */ \ 266 case 2 : (pos) -= (int)(bw1) ; break ; /* Static */ \ 267 default : break ; /* North/West */ \ 268 }} 269 270 unsigned char get_hint_name_encoding( ASHints *hints, int name_idx ); 271 ASHints *merge_hints( struct ASRawHints *raw, struct ASDatabase *db, ASStatusHints *status, 272 ASSupportedHints *list, ASFlagType what, ASHints* reusable_memory, Window client ); 273 void merge_asdb_hints (ASHints * clean, struct ASRawHints * raw, struct ASDatabaseRecord * db_rec, ASStatusHints * status, ASFlagType what); 274 275 void check_motif_hints_sanity (struct MwmHints * motif_hints); 276 ASFlagType extwm_state2as_state_flags( ASFlagType extwm_flags ); 277 278 /* 279 * few function - shortcuts to implement update of selected hints : 280 */ 281 /* returns True if protocol/function hints actually changed :*/ 282 Bool update_protocols( struct ScreenInfo *scr, Window w, ASSupportedHints *list, ASFlagType *pprots, ASFlagType *pfuncs ); 283 Bool update_colormaps( struct ScreenInfo *scr, Window w, ASSupportedHints *list, CARD32 **pcmap_windows ); 284 Bool update_property_hints( Window w, Atom property, ASHints *hints, ASStatusHints *status ); 285 Bool update_property_hints_manager( Window w, Atom property, ASSupportedHints *list, 286 struct ASDatabase * db, ASHints *hints, ASStatusHints *status ); 287 void update_cmd_line_hints (Window w, Atom property, 288 ASHints * hints, ASStatusHints * status); 289 290 void check_hints_sanity (struct ScreenInfo * scr, ASHints * clean, ASStatusHints * status, Window client); 291 void check_status_sanity (struct ScreenInfo * scr, ASStatusHints * status); 292 293 294 void destroy_hints( ASHints *clean, Bool reusable ); 295 Bool compare_names( ASHints *old, ASHints *hints ); 296 ASFlagType compare_hints( ASHints *old, ASHints *hints ); 297 ASFlagType function2mask( int function ); 298 void constrain_size ( ASHints *hints, ASStatusHints *status, 299 int max_width, int max_height ); 300 void get_gravity_offsets (ASHints *hints, int *xp, int *yp); 301 int translate_asgeometry( struct ScreenInfo *scr, ASGeometry *asg, int *px, int *py, unsigned int *pwidth, unsigned int *pheight ); 302 void real2virtual (ASStatusHints *status, int *x, int *y, int vx, int vy ); 303 void virtual2real (ASStatusHints *status, int *x, int *y, int vx, int vy); 304 int make_anchor_pos (ASStatusHints * status, int pos, int size, int vpos, int grav, int max_pos); 305 void make_detach_pos (ASHints * hints, ASStatusHints * status, XRectangle *anchor, int *detach_x, int *detach_y); 306 ASFlagType change_placement( struct ScreenInfo *scr, ASHints *hints, ASStatusHints *status, XPoint *anchor, ASStatusHints *new_status, int vx, int vy, ASFlagType what ); 307 308 void status2anchor( XRectangle *anchor, struct ASHints *hints, struct ASStatusHints *status, int vwidth, int vheight ); 309 void anchor2status( struct ASStatusHints *status, struct ASHints *hints, XRectangle *anchor ); 310 311 int calculate_viewport( int *pos, int size, int scr_vpos, int scr_size, int max_viewport ); 312 char *make_client_geometry_string (struct ScreenInfo * scr, ASHints *hints, ASStatusHints *status, XRectangle *anchor, int vx, int vy, char **pure_geometry); 313 char *make_client_command( struct ScreenInfo *scr, ASHints *hints, ASStatusHints *status, XRectangle *anchor, int vx, int vy); 314 315 Bool set_all_client_hints( Window w, ASHints *hints, ASStatusHints *status, Bool set_command ); 316 struct ASImage* get_client_icon_image( struct ScreenInfo * scr, ASHints *hints, int desired_size); 317 CARD32 set_hints_window_opacity_percent( ASHints *clean, int opaque_percent ); 318 319 320 /* printing functions : 321 * if func and stream are not specified - fprintf(stderr) is used ! */ 322 void print_clean_hints( stream_func func, void* stream, ASHints *clean ); 323 void print_status_hints( stream_func func, void* stream, ASStatusHints *status ); 324 325 /* serialization so that we can send modules some data : */ 326 void serialize_string( char * string, struct ASVector *buf ); 327 void serialize_CARD32_zarray( CARD32 *array, struct ASVector *buf ); 328 Bool serialize_clean_hints( ASHints *clean, struct ASVector *buf ); 329 Bool serialize_names( ASHints *clean, struct ASVector *buf ); 330 Bool serialize_status_hints( ASStatusHints *status, struct ASVector *buf ); 331 332 /* deserialization so that module can read out communications: */ 333 char *deserialize_string( CARD32 **pbuf, size_t *buf_size ); 334 CARD32 *deserialize_CARD32_zarray( CARD32 **pbuf, size_t *buf_size ); 335 ASHints *deserialize_clean_hints( CARD32 **pbuf, size_t *buf_size, ASHints *reusable_memory ); 336 Bool deserialize_names( ASHints *clean, CARD32 **pbuf, size_t *buf_size ); 337 ASStatusHints *deserialize_status_hints( CARD32 **pbuf, size_t *buf_size, ASStatusHints *reusable_memory ); 338 339 340 /* This will let us to change what hints are actually applied and in what order */ 341 ASSupportedHints *create_hints_list(); 342 void destroy_hints_list( ASSupportedHints **plist ); 343 Bool enable_hints_support( ASSupportedHints *list, HintsTypes type ); 344 Bool disable_hints_support( ASSupportedHints *list, HintsTypes type ); 345 HintsTypes *supported_hints_types( ASSupportedHints *list, int *num_return ); 346 347 348 /*************************************************************************/ 349 /********************************THE END**********************************/ 350 /*************************************************************************/ 351 #ifdef __cplusplus 352 } 353 #endif 354 355 356 #endif /* HINTS_H_HEADER_INCLUDED */ 357