util: Value stored to 'ret' is never read
[wmaker-crm.git] / WINGs / WINGs / WINGsP.h
blob5a6e61263a27f7a5b8e528e5068b5eb2a9b98545
1 #ifndef _WINGSP_H_
2 #define _WINGSP_H_
5 #include <X11/Xlib.h>
6 #include <X11/Xutil.h>
9 #include <WINGs/WINGs.h>
11 #if WINGS_H_VERSION < 20041030
12 #error There_is_an_old_WINGs.h_file_somewhere_in_your_system._Please_remove_it.
13 #endif
15 #include <assert.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <strings.h>
20 #include <stdio.h>
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
26 /* ---[ global settigns ]------------------------------------------------- */
28 #define DOUBLE_BUFFER 1
30 #define SCROLLER_WIDTH 20
32 typedef struct _WINGsConfiguration {
33 char *systemFont;
34 char *boldSystemFont;
35 int defaultFontSize;
36 Bool antialiasedText;
37 char *floppyPath;
38 unsigned doubleClickDelay;
39 unsigned mouseWheelUp;
40 unsigned mouseWheelDown;
41 } _WINGsConfiguration;
43 extern char *_WINGS_progname;
44 extern _WINGsConfiguration WINGsConfiguration;
45 extern struct W_Application WMApplication;
48 /* ---[ drag*.c ]--------------------------------------------------------- */
51 * We need to define these structure first because they are used in W_Screen
52 * below. The rest of drag-related stuff if after because it needs W_Screen
54 #define XDND_VERSION 3
56 typedef struct W_DraggingInfo {
57 unsigned char protocolVersion; /* version supported on the other side */
58 Time timestamp;
60 Atom sourceAction;
61 Atom destinationAction;
63 struct W_DragSourceInfo* sourceInfo; /* infos needed by source */
64 struct W_DragDestinationInfo* destInfo; /* infos needed by destination */
65 } W_DraggingInfo;
67 /* ---[ Structures from WINGs.h ]----------------------------------------- */
69 /* Pre-definition of internal structs */
70 typedef struct W_Color W_Color;
71 typedef struct W_Pixmap W_Pixmap;
72 typedef struct W_View W_View;
74 typedef struct W_FocusInfo {
75 W_View *toplevel;
76 W_View *focused; /* view that has the focus in this toplevel */
77 struct W_FocusInfo *next;
78 } W_FocusInfo;
80 typedef struct W_Screen {
81 Display *display;
82 int screen;
83 int depth;
85 Colormap colormap;
87 Visual *visual;
89 Time lastEventTime;
91 Window rootWin;
93 W_View *rootView;
95 RContext *rcontext;
97 struct W_IMContext *imctx;
99 struct _XftDraw *xftdraw; /* shared XftDraw */
101 /* application related */
103 W_FocusInfo *focusInfo;
105 RImage *applicationIconImage; /* image (can have alpha channel) */
106 W_Pixmap *applicationIconPixmap; /* pixmap - no alpha channel */
107 Window applicationIconWindow;
109 struct W_Window *windowList; /* list of windows in the app */
111 Window groupLeader; /* the leader of the application */
112 /* also used for other things */
114 struct W_SelectionHandlers *selectionHandlerList;
116 struct {
117 unsigned int hasAppIcon:1;
118 unsigned int simpleApplication:1;
119 } aflags;
121 WMOpenPanel *sharedOpenPanel;
122 WMSavePanel *sharedSavePanel;
124 struct W_FontPanel *sharedFontPanel;
126 struct W_ColorPanel *sharedColorPanel;
128 Pixmap stipple;
130 W_View *dragSourceView;
131 W_DraggingInfo dragInfo;
133 /* colors */
134 W_Color *white;
135 W_Color *black;
136 W_Color *gray;
137 W_Color *darkGray;
139 GC stippleGC;
141 GC copyGC;
142 GC clipGC;
144 GC monoGC; /* GC for 1bpp visuals */
146 GC xorGC;
148 GC ixorGC; /* IncludeInferiors XOR */
150 GC drawStringGC; /* for WMDrawString() */
152 GC drawImStringGC; /* for WMDrawImageString() */
154 struct W_Font *normalFont;
156 struct W_Font *boldFont;
158 WMHashTable *fontCache;
160 Bool antialiasedText;
162 unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */
164 struct W_Balloon *balloon;
167 W_Pixmap *checkButtonImageOn;
168 W_Pixmap *checkButtonImageOff;
170 W_Pixmap *radioButtonImageOn;
171 W_Pixmap *radioButtonImageOff;
173 W_Pixmap *buttonArrow;
174 W_Pixmap *pushedButtonArrow;
176 W_Pixmap *scrollerDimple;
178 W_Pixmap *upArrow;
179 W_Pixmap *downArrow;
180 W_Pixmap *leftArrow;
181 W_Pixmap *rightArrow;
183 W_Pixmap *hiUpArrow;
184 W_Pixmap *hiDownArrow;
185 W_Pixmap *hiLeftArrow;
186 W_Pixmap *hiRightArrow;
188 W_Pixmap *pullDownIndicator;
189 W_Pixmap *popUpIndicator;
191 W_Pixmap *checkMark;
193 W_Pixmap *homeIcon;
194 W_Pixmap *altHomeIcon;
196 W_Pixmap *trashcanIcon;
197 W_Pixmap *altTrashcanIcon;
199 W_Pixmap *createDirIcon;
200 W_Pixmap *altCreateDirIcon;
202 W_Pixmap *disketteIcon;
203 W_Pixmap *altDisketteIcon;
204 W_Pixmap *unmountIcon;
205 W_Pixmap *altUnmountIcon;
207 W_Pixmap *magnifyIcon;
208 /*W_Pixmap *altMagnifyIcon;*/
209 W_Pixmap *wheelIcon;
210 W_Pixmap *grayIcon;
211 W_Pixmap *rgbIcon;
212 W_Pixmap *cmykIcon;
213 W_Pixmap *hsbIcon;
214 W_Pixmap *customPaletteIcon;
215 W_Pixmap *colorListIcon;
217 W_Pixmap *defaultObjectIcon;
219 Cursor defaultCursor;
221 Cursor textCursor;
223 Cursor invisibleCursor;
225 Atom attribsAtom; /* GNUstepWindowAttributes */
227 Atom deleteWindowAtom; /* WM_DELETE_WINDOW */
229 Atom protocolsAtom; /* _XA_WM_PROTOCOLS */
231 Atom clipboardAtom; /* CLIPBOARD */
233 Atom xdndAwareAtom; /* XdndAware */
234 Atom xdndSelectionAtom;
235 Atom xdndEnterAtom;
236 Atom xdndLeaveAtom;
237 Atom xdndPositionAtom;
238 Atom xdndDropAtom;
239 Atom xdndFinishedAtom;
240 Atom xdndTypeListAtom;
241 Atom xdndActionListAtom;
242 Atom xdndActionDescriptionAtom;
243 Atom xdndStatusAtom;
245 Atom xdndActionCopy;
246 Atom xdndActionMove;
247 Atom xdndActionLink;
248 Atom xdndActionAsk;
249 Atom xdndActionPrivate;
251 Atom wmIconDragOffsetAtom;
253 Atom wmStateAtom; /* WM_STATE */
255 Atom utf8String;
257 Atom netwmName;
258 Atom netwmIconName;
259 Atom netwmIcon;
261 /* stuff for detecting double-clicks */
262 Time lastClickTime; /* time of last mousedown event */
263 Window lastClickWindow; /* window of the last mousedown */
265 struct W_View *modalView;
266 unsigned modalLoop:1;
267 unsigned ignoreNextDoubleClick:1;
268 } W_Screen;
270 #define W_DRAWABLE(scr) (scr)->rcontext->drawable
273 /* ---[ configuration.c ]------------------------------------------------- */
275 void W_ReadConfigurations(void);
278 /* ---[ drag*.c ]--------------------------------------------------------- */
280 typedef struct W_DragOperationItem {
281 WMDragOperationType type;
282 char* text;
283 } W_DragOperationItem;
285 typedef void* W_DndState(WMView *destView, XClientMessageEvent *event,
286 WMDraggingInfo *info);
288 typedef struct W_DragSourceInfo {
289 WMView *sourceView;
290 Window destinationWindow;
291 W_DndState *state;
292 WMSelectionProcs *selectionProcs;
293 Window icon;
294 WMPoint imageLocation;
295 WMPoint mouseOffset; /* mouse pos in icon */
296 Cursor dragCursor;
297 WMRect noPositionMessageZone;
298 Atom firstThreeTypes[3];
299 } W_DragSourceInfo;
301 typedef struct W_DragDestinationInfo {
302 WMView *destView;
303 WMView *xdndAwareView;
304 Window sourceWindow;
305 W_DndState *state;
306 Bool sourceActionChanged;
307 WMArray *sourceTypes;
308 WMArray *requiredTypes;
309 Bool typeListAvailable;
310 WMArray *dropDatas;
311 } W_DragDestinationInfo;
313 /* -- Functions -- */
315 void W_HandleDNDClientMessage(WMView *toplevel, XClientMessageEvent *event);
317 Atom W_OperationToAction(WMScreen *scr, WMDragOperationType operation);
319 WMDragOperationType W_ActionToOperation(WMScreen *scr, Atom action);
321 void W_FreeDragOperationItem(void* item);
323 Bool W_SendDnDClientMessage(Display *dpy, Window win, Atom message,
324 unsigned long data1, unsigned long data2,
325 unsigned long data3, unsigned long data4,
326 unsigned long data5);
328 void W_DragSourceStartTimer(WMDraggingInfo *info);
330 void W_DragSourceStopTimer(void);
332 void W_DragSourceStateHandler(WMDraggingInfo *info, XClientMessageEvent *event);
334 void W_DragDestinationStartTimer(WMDraggingInfo *info);
336 void W_DragDestinationStopTimer(void);
338 void W_DragDestinationStoreEnterMsgInfo(WMDraggingInfo *info, WMView *toplevel,
339 XClientMessageEvent *event);
341 void W_DragDestinationStorePositionMsgInfo(WMDraggingInfo *info,
342 WMView *toplevel,
343 XClientMessageEvent *event);
345 void W_DragDestinationCancelDropOnEnter(WMView *toplevel, WMDraggingInfo *info);
347 void W_DragDestinationStateHandler(WMDraggingInfo *info,
348 XClientMessageEvent *event);
350 void W_DragDestinationInfoClear(WMDraggingInfo *info);
352 void W_FreeViewXdndPart(WMView *view);
355 /* ---[ handlers.c ]------------------------------------------------------ */
357 Bool W_CheckIdleHandlers(void);
359 void W_CheckTimerHandlers(void);
361 Bool W_HandleInputEvents(Bool waitForInput, int inputfd);
364 /* ---[ notification.c ]-------------------------------------------------- */
366 void W_InitNotificationCenter(void);
368 void W_ReleaseNotificationCenter(void);
370 void W_FlushASAPNotificationQueue(void);
372 void W_FlushIdleNotificationQueue(void);
375 /* ---[ selection.c ]----------------------------------------------------- */
377 void W_HandleSelectionEvent(XEvent *event);
380 /* ---[ wapplication.c ]-------------------------------------------------- */
382 typedef struct W_Application {
383 char *applicationName;
384 int argc;
385 char **argv;
386 char *resourcePath;
387 } W_Application;
389 /* -- Functions -- */
391 void W_InitApplication(WMScreen *scr);
393 Bool W_ApplicationInitialized(void);
396 /* ---[ wballoon.c ]------------------------------------------------------ */
398 struct W_Balloon *W_CreateBalloon(WMScreen *scr);
400 void W_BalloonHandleEnterView(WMView *view);
402 void W_BalloonHandleLeaveView(WMView *view);
405 /* ---[ wcolor.c ]-------------------------------------------------------- */
407 struct W_Color {
408 struct W_Screen *screen;
410 XColor color;
411 unsigned short alpha;
412 short refCount;
413 GC gc;
414 struct {
415 unsigned int exact:1;
416 } flags;
419 #define W_PIXEL(c) (c)->color.pixel
422 /* ---[ wevent.c ]-------------------------------------------------------- */
424 typedef struct W_EventHandler {
425 unsigned long eventMask;
427 WMEventProc *proc;
429 void *clientData;
430 } W_EventHandler;
432 /* -- Functions -- */
434 void W_CallDestroyHandlers(W_View *view);
437 /* ---[ wfont.c ]--------------------------------------------------------- */
439 typedef struct W_Font {
440 struct W_Screen *screen;
442 struct _XftFont *font;
444 short height;
445 short y;
446 short refCount;
447 char *name;
448 } W_Font;
450 #define W_FONTID(f) (f)->font->fid
453 /* ---[ widgets.c ]------------------------------------------------------- */
455 #define WC_UserWidget 128
457 #define CHECK_CLASS(widget, class) assert(W_CLASS(widget)==(class))
459 #define W_CLASS(widget) (((W_WidgetType*)(widget))->widgetClass)
460 #define W_VIEW(widget) (((W_WidgetType*)(widget))->view)
462 /* -- Functions -- */
464 W_Class W_RegisterUserWidget(void);
467 /* ---[ winputmethod.c ]-------------------------------------------------- */
469 void W_InitIM(WMScreen *scr);
471 void W_CreateIC(WMView *view);
473 void W_DestroyIC(WMView *view);
475 void W_FocusIC(WMView *view);
477 void W_UnFocusIC(WMView *view);
479 void W_SetPreeditPositon(W_View *view, int x, int y);
481 int W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer,
482 int buflen, KeySym *keysym, Status *status);
485 /* ---[ wmisc.c ]--------------------------------------------------------- */
487 void W_DrawRelief(W_Screen *scr, Drawable d, int x, int y, unsigned int width,
488 unsigned int height, WMReliefType relief);
490 void W_DrawReliefWithGC(W_Screen *scr, Drawable d, int x, int y,
491 unsigned int width, unsigned int height,
492 WMReliefType relief,
493 GC black, GC dark, GC light, GC white);
495 void W_PaintTextAndImage(W_View *view, int wrap, WMColor *textColor,
496 W_Font *font, WMReliefType relief, const char *text,
497 WMAlignment alignment, W_Pixmap *image,
498 WMImagePosition position, WMColor *backColor, int ofs);
500 void W_PaintText(W_View *view, Drawable d, WMFont *font, int x, int y,
501 int width, WMAlignment alignment, WMColor *color,
502 int wrap, const char *text, int length);
504 int W_GetTextHeight(WMFont *font, const char *text, int width, int wrap);
507 /* ---[ wpixmap.c ]------------------------------------------------------- */
509 struct W_Pixmap {
510 struct W_Screen *screen;
511 Pixmap pixmap;
512 Pixmap mask;
513 unsigned short width;
514 unsigned short height;
515 short depth;
516 short refCount;
520 /* ---[ wview.c ]--------------------------------------------------------- */
522 typedef struct W_ViewDelegate {
523 void *data;
524 void (*didMove)(struct W_ViewDelegate*, WMView*);
525 void (*didResize)(struct W_ViewDelegate*, WMView*);
526 void (*willMove)(struct W_ViewDelegate*, WMView*, int*, int*);
527 void (*willResize)(struct W_ViewDelegate*, WMView*,
528 unsigned int*, unsigned int*);
529 } W_ViewDelegate;
531 struct W_View {
532 struct W_Screen *screen;
534 WMWidget *self; /* must point to the widget the view belongs to */
536 W_ViewDelegate *delegate;
538 Window window;
540 WMSize size;
542 short topOffs;
543 short leftOffs;
544 short bottomOffs;
545 short rightOffs;
547 WMPoint pos;
549 struct W_View *nextFocusChain; /* next/prev in focus chain */
550 struct W_View *prevFocusChain;
552 struct W_View *nextResponder; /* next to receive keyboard events */
554 struct W_View *parent; /* parent WMView */
556 struct W_View *childrenList; /* first in list of child windows */
558 struct W_View *nextSister; /* next on parent's children list */
560 WMArray *eventHandlers; /* event handlers for this window */
562 unsigned long attribFlags;
563 XSetWindowAttributes attribs;
565 void *hangedData; /* data holder for user program */
567 WMColor *backColor;
569 Cursor cursor;
571 Atom *droppableTypes;
572 struct W_DragSourceProcs *dragSourceProcs;
573 struct W_DragDestinationProcs *dragDestinationProcs;
574 WMPixmap *dragImage;
575 int helpContext;
577 XIC xic;
579 struct {
580 unsigned int realized:1;
581 unsigned int mapped:1;
582 unsigned int parentDying:1;
583 unsigned int dying:1; /* the view is being destroyed */
584 unsigned int topLevel:1; /* is a top level window */
585 unsigned int root:1; /* is the root window */
586 unsigned int mapWhenRealized:1; /* map the view when it's realized */
587 unsigned int alreadyDead:1; /* view was freed */
589 unsigned int dontCompressMotion:1; /* motion notify event compress */
590 unsigned int notifySizeChanged:1;
591 unsigned int dontCompressExpose:1; /* expose event compress */
593 /* toplevel only */
594 unsigned int worksWhenModal:1;
595 unsigned int pendingRelease1:1;
596 unsigned int pendingRelease2:1;
597 unsigned int pendingRelease3:1;
598 unsigned int pendingRelease4:1;
599 unsigned int pendingRelease5:1;
600 unsigned int xdndHintSet:1;
601 } flags;
603 int refCount;
606 #define W_VIEW_REALIZED(view) (view)->flags.realized
607 #define W_VIEW_MAPPED(view) (view)->flags.mapped
609 #define W_VIEW_DISPLAY(view) (view)->screen->display
610 #define W_VIEW_SCREEN(view) (view)->screen
611 #define W_VIEW_DRAWABLE(view) (view)->window
613 #define W_VIEW_WIDTH(view) (view)->size.width
614 #define W_VIEW_HEIGHT(view) (view)->size.height
616 /* -- Functions -- */
618 W_View *W_GetViewForXWindow(Display *display, Window window);
620 W_View *W_CreateView(W_View *parent);
622 W_View *W_CreateTopView(W_Screen *screen);
624 W_View *W_CreateUnmanagedTopView(W_Screen *screen);
626 W_View *W_CreateRootView(W_Screen *screen);
628 void W_DestroyView(W_View *view);
630 void W_RealizeView(W_View *view);
632 void W_RedisplayView(WMView *view);
634 void W_ReparentView(W_View *view, W_View *newParent, int x, int y);
636 void W_RaiseView(W_View *view);
638 void W_LowerView(W_View *view);
640 void W_MapView(W_View *view);
642 void W_MapSubviews(W_View *view);
644 void W_UnmapSubviews(W_View *view);
646 W_View *W_TopLevelOfView(W_View *view);
648 void W_UnmapView(W_View *view);
650 WMView *W_RetainView(WMView *view);
652 void W_ReleaseView(WMView *view);
654 void W_MoveView(W_View *view, int x, int y);
656 void W_ResizeView(W_View *view, unsigned int width, unsigned int height);
658 void W_SetViewBackgroundColor(W_View *view, WMColor *color);
660 void W_SetViewCursor(W_View *view, Cursor cursor);
662 void W_SetFocusOfTopLevel(W_View *toplevel, W_View *view);
664 W_View *W_FocusedViewOfToplevel(W_View *view);
666 void W_BroadcastMessage(W_View *targetParent, XEvent *event);
668 void W_DispatchMessage(W_View *target, XEvent *event);
671 #ifdef __cplusplus
673 #endif /* __cplusplus */
675 #endif /* _WINGSP_H_ */