- XGCValues gcv;
- XSizeHints size_hints;
- XWMHints wm_hints;
- int status;
- int gravity = 0; /* Used to store the gravity value returned by XWMGeometry,
- but not used. */
-
- /* Opening a connection to the X server. */
- dockapp.display = XOpenDisplay( display_arg );
- if( dockapp.display == NULL ) {
- fprintf( stderr, "%s: Can't open display: %s\n", PACKAGE,
- XDisplayName( display_arg ) );
- ErrorLocation( __FILE__, __LINE__ );
- exit( EXIT_FAILURE );
- }
-
- dockapp.screen = DefaultScreen( dockapp.display );
- dockapp.root_win = RootWindow( dockapp.display, dockapp.screen );
- dockapp.d_depth = DefaultDepth( dockapp.display, dockapp.screen );
-
- /* Create a window to hold the stuff */
- size_hints.flags = USSize | USPosition;
- size_hints.x = 0;
- size_hints.y = 0;
-
- /* Constructing window's geometry information. */
- /* XWMGeometry() returns an 'int', but Xlib documentation doesn't explain
- it's meaning. */
- XWMGeometry( dockapp.display, dockapp.screen, geometry_arg, NULL, BWIDTH,
- &size_hints, &size_hints.x, &size_hints.y, &size_hints.width,
- &size_hints.height, &gravity );
-
- size_hints.width = ICON_SIZE;
- size_hints.height = ICON_SIZE;
- dockapp.back_pix = GetColor("white");
- dockapp.fore_pix = GetColor("black");
-
- dockapp.win = XCreateSimpleWindow( dockapp.display, dockapp.root_win,
- size_hints.x, size_hints.y,
- (unsigned int) size_hints.width,
- (unsigned int) size_hints.height,
- BWIDTH, dockapp.fore_pix,
- dockapp.back_pix );
-
- dockapp.iconwin = XCreateSimpleWindow( dockapp.display, dockapp.win,
- size_hints.x, size_hints.y,
- (unsigned int) size_hints.width,
- (unsigned int) size_hints.height,
- BWIDTH, dockapp.fore_pix,
- dockapp.back_pix );
-
- /* Configuring Client to Window Manager Communications. */
-
- /* WM_NORMAL_HINTS property: size hints for a window in it's normal state. */
- /* Replaces the size hints for the WM_NORMAL_HINTS property on the specified
- window. */
- XSetWMNormalHints( dockapp.display, dockapp.win, &size_hints );
-
- /* Setting the WM_CLASS property. */
- {
- char *app_name = argv[0];
- XClassHint wm_class;
-
- /* The res_name member contains the application name.
- The res_class member contains the application class. */
- /* The name set in this property may differ from the name set as WM_NAME.
- That is, WM_NAME specifies what should be displayed in the title bar and,
- therefore, can contain temporal information (for example, the name of a
- file currently in an editor's buffer). On the other hand, the name
- specified as part of WM_CLASS is the formal name of the application that
- should be used when retrieving the application's resources from the
- resource database. */
- wm_class.res_name = app_name;
- wm_class.res_class = app_name;
- (void) XSetClassHint( dockapp.display, dockapp.win, &wm_class );
- }
-
- /* Setting the WM_NAME property.
- This specifies what should be displayed in the title bar (usually the
- application name). */
- {
- XTextProperty text_prop;
-
- char *app_name = argv[0];
- const int string_count = 1;
-
- status = XStringListToTextProperty( &app_name, string_count, &text_prop );
- if( status == 0 ) {
- fprintf( stderr, "%s: XStringListToTextProperty() failed\n", PACKAGE );
- ErrorLocation( __FILE__, __LINE__ );
- exit( EXIT_FAILURE );
- }
-
- XSetWMName( dockapp.display, dockapp.win, &text_prop );
-
- /* Freing the storage for the value field. */
- (void) XFree( text_prop.value );
- }
-
- /* WM_HINTS --> Additional hints set by the client for use by the Window
- Manager. */
- /* XWMHints wm_hints; */
-
- /* WithdrawnState, NormalState or IconicState. Must be set to WithdrawnState
- for DockApp. */
- wm_hints.flags = StateHint | IconWindowHint | IconPositionHint |
- WindowGroupHint;
- wm_hints.initial_state = WithdrawnState; /* Withdrawn, Normal */
- wm_hints.icon_window = dockapp.iconwin;
- wm_hints.icon_x = size_hints.x;
- wm_hints.icon_y = size_hints.y;
- wm_hints.window_group = dockapp.win;
- (void) XSetWMHints( dockapp.display, dockapp.win, &wm_hints );
-
- /* Sets the WM_COMMAND property. This sets the command and arguments used to
- invoke the application. */
- (void) XSetCommand( dockapp.display, dockapp.win, argv, argc );
-
- /* ... */
- (void) XSelectInput( dockapp.display, dockapp.win,
- ButtonPressMask | ExposureMask | ButtonReleaseMask |
- PointerMotionMask | StructureNotifyMask );
-
- (void) XSelectInput( dockapp.display, dockapp.iconwin,
- ButtonPressMask | ExposureMask | ButtonReleaseMask |
- PointerMotionMask | StructureNotifyMask );
-
- /* Create GC for drawing */
- gcv.foreground = dockapp.fore_pix;
- gcv.background = dockapp.back_pix;
- gcv.graphics_exposures = 0;
- dockapp.NormalGC = XCreateGC( dockapp.display, dockapp.root_win,
- GCForeground | GCBackground |
- GCGraphicsExposures, &gcv );
-
- /* Convert XPM data to XImage */
- CreateIconFromXpmData( pixmap_data );
-
- XShapeCombineMask( dockapp.display, dockapp.win, ShapeBounding, 0, 0,
- dockapp.xpm_icon.shapemask, ShapeSet );
-
- XShapeCombineMask( dockapp.display, dockapp.iconwin, ShapeBounding, 0, 0,
- dockapp.xpm_icon.shapemask, ShapeSet );
-
- /* Making the new window visible. */
- (void) XMapWindow( dockapp.display, dockapp.win );
+ XGCValues gcv;
+ XSizeHints size_hints;
+ XWMHints wm_hints;
+ int status;
+ int gravity = 0; /*
+ * Used to store the gravity value returned by
+ * XWMGeometry, but not used.
+ */
+
+ /* Opening a connection to the X server. */
+ dockapp.display = XOpenDisplay(display_arg);
+ if (dockapp.display == NULL) {
+ fprintf(stderr, "%s: Can't open display: %s\n", PACKAGE,
+ XDisplayName(display_arg));
+ ErrorLocation(__FILE__, __LINE__);
+ exit(EXIT_FAILURE);
+ }
+
+ dockapp.screen = DefaultScreen(dockapp.display);
+ dockapp.root_win = RootWindow(dockapp.display, dockapp.screen);
+ dockapp.d_depth = DefaultDepth(dockapp.display, dockapp.screen);
+
+ /* Create a window to hold the stuff */
+ size_hints.flags = USSize | USPosition;
+ size_hints.x = 0;
+ size_hints.y = 0;
+
+ /*
+ * Constructing window's geometry information.
+ * XWMGeometry() returns an 'int', but Xlib documentation doesn't
+ * explain it's meaning.
+ */
+ XWMGeometry(dockapp.display, dockapp.screen, geometry_arg, NULL,
+ BWIDTH, &size_hints, &size_hints.x, &size_hints.y,
+ &size_hints.width, &size_hints.height, &gravity);
+
+ size_hints.width = ICON_SIZE;
+ size_hints.height = ICON_SIZE;
+ dockapp.back_pix = GetColor("white");
+ dockapp.fore_pix = GetColor("black");
+
+ dockapp.win =
+ XCreateSimpleWindow(dockapp.display, dockapp.root_win,
+ size_hints.x, size_hints.y,
+ (unsigned int) size_hints.width,
+ (unsigned int) size_hints.height, BWIDTH,
+ dockapp.fore_pix, dockapp.back_pix);
+
+ dockapp.iconwin = XCreateSimpleWindow(dockapp.display, dockapp.win,
+ size_hints.x, size_hints.y,
+ (unsigned int) size_hints.
+ width,
+ (unsigned int) size_hints.
+ height, BWIDTH,
+ dockapp.fore_pix,
+ dockapp.back_pix);
+
+ /* Configuring Client to Window Manager Communications. */
+
+ /*
+ * WM_NORMAL_HINTS property: size hints for a window in it's normal
+ * state.
+ * Replaces the size hints for the WM_NORMAL_HINTS property on the
+ * specified window.
+ */
+ XSetWMNormalHints(dockapp.display, dockapp.win, &size_hints);
+
+ /* Setting the WM_CLASS property. */
+ {
+ char *app_name = argv[0];
+ XClassHint wm_class;
+
+ /*
+ * The res_name member contains the application name.
+ * The res_class member contains the application class.
+ */
+ /*
+ * The name set in this property may differ from the name set as
+ * WM_NAME. That is, WM_NAME specifies what should be displayed
+ * in the title bar and, therefore, can contain temporal
+ * information (for example, the name of a file currently in an
+ * editor's buffer). On the other hand, the name specified as
+ * part of WM_CLASS is the formal name of the application that
+ * should be used when retrieving the application's resources
+ * from the resource database.
+ */
+ wm_class.res_name = app_name;
+ wm_class.res_class = app_name;
+ (void) XSetClassHint(dockapp.display, dockapp.win,
+ &wm_class);
+ }
+
+ /* Setting the WM_NAME property.
+ This specifies what should be displayed in the title bar (usually the
+ application name). */
+ {
+ XTextProperty text_prop;
+
+ char *app_name = argv[0];
+ const int string_count = 1;
+
+ status =
+ XStringListToTextProperty(&app_name, string_count,
+ &text_prop);
+ if (status == 0) {
+ fprintf(stderr,
+ "%s: XStringListToTextProperty() failed\n",
+ PACKAGE);
+ ErrorLocation(__FILE__, __LINE__);
+ exit(EXIT_FAILURE);
+ }
+
+ XSetWMName(dockapp.display, dockapp.win, &text_prop);
+
+ /* Freing the storage for the value field. */
+ (void) XFree(text_prop.value);
+ }
+
+ /* WM_HINTS --> Additional hints set by the client for use by the Window
+ Manager. */
+ /* XWMHints wm_hints; */
+
+ /*
+ * WithdrawnState, NormalState or IconicState. Must be set to
+ * WithdrawnState for DockApp.
+ */
+ wm_hints.flags = StateHint | IconWindowHint | IconPositionHint |
+ WindowGroupHint;
+ wm_hints.initial_state = WithdrawnState; /* Withdrawn, Normal */
+ wm_hints.icon_window = dockapp.iconwin;
+ wm_hints.icon_x = size_hints.x;
+ wm_hints.icon_y = size_hints.y;
+ wm_hints.window_group = dockapp.win;
+ (void) XSetWMHints(dockapp.display, dockapp.win, &wm_hints);
+
+ /*
+ * Sets the WM_COMMAND property. This sets the command and arguments
+ * used to invoke the application.
+ */
+ (void) XSetCommand(dockapp.display, dockapp.win, argv, argc);
+
+ /* ... */
+ (void) XSelectInput(dockapp.display, dockapp.win,
+ ButtonPressMask | ExposureMask |
+ ButtonReleaseMask | PointerMotionMask |
+ StructureNotifyMask);
+
+ (void) XSelectInput(dockapp.display, dockapp.iconwin,
+ ButtonPressMask | ExposureMask |
+ ButtonReleaseMask | PointerMotionMask |
+ StructureNotifyMask);
+
+ /* Create GC for drawing */
+ gcv.foreground = dockapp.fore_pix;
+ gcv.background = dockapp.back_pix;
+ gcv.graphics_exposures = 0;
+ dockapp.NormalGC = XCreateGC(dockapp.display, dockapp.root_win,
+ GCForeground | GCBackground |
+ GCGraphicsExposures, &gcv);
+
+ /* Convert XPM data to XImage */
+ CreateIconFromXpmData(pixmap_data);
+
+ XShapeCombineMask(dockapp.display, dockapp.win, ShapeBounding, 0,
+ 0, dockapp.xpm_icon.shapemask, ShapeSet);
+
+ XShapeCombineMask(dockapp.display, dockapp.iconwin, ShapeBounding,
+ 0, 0, dockapp.xpm_icon.shapemask, ShapeSet);
+
+ /* Making the new window visible. */
+ (void) XMapWindow(dockapp.display, dockapp.win);