/** Startup tray buttons. */ void StartupTrayButtons() { TrayButtonType *bp; for(bp = buttons; bp; bp = bp->next) { if(bp->label) { bp->cp->requestedWidth = GetStringWidth(FONT_TRAYBUTTON, bp->label) + 4; bp->cp->requestedHeight = GetStringHeight(FONT_TRAYBUTTON); } else { bp->cp->requestedWidth = 0; bp->cp->requestedHeight = 0; } if(bp->iconName) { bp->icon = LoadNamedIcon(bp->iconName); if(JLIKELY(bp->icon)) { bp->cp->requestedWidth += bp->icon->image->width; bp->cp->requestedHeight += bp->icon->image->height; } else { Warning(_("could not load tray icon: \"%s\""), bp->iconName); } } bp->cp->requestedWidth += 2 * BUTTON_SIZE; bp->cp->requestedHeight += 2 * BUTTON_SIZE; } }
/** Startup tray buttons. */ void StartupTrayButtons(void) { TrayButtonType *bp; for(bp = buttons; bp; bp = bp->next) { if(bp->label) { bp->cp->requestedWidth = GetStringWidth(FONT_TRAY, bp->label) + 4; bp->cp->requestedHeight = GetStringHeight(FONT_TRAY); } else { bp->cp->requestedWidth = 0; bp->cp->requestedHeight = 0; } if(bp->iconName) { bp->icon = LoadNamedIcon(bp->iconName, 1, 1); if(JLIKELY(bp->icon)) { bp->cp->requestedWidth += bp->icon->images->width + 4; if(bp->label) { bp->cp->requestedWidth -= 2; } bp->cp->requestedHeight = Max(bp->icon->images->height + 4, bp->cp->requestedHeight); } else { Warning(_("could not load tray icon: \"%s\""), bp->iconName); } } } }
/** Load an image background. */ void LoadImageBackground(BackgroundNode *bp) { IconNode *ip; int width, height; /* Load the icon. */ ExpandPath(&bp->value); ip = LoadNamedIcon(bp->value); if(JUNLIKELY(!ip)) { bp->pixmap = None; bp->window = None; Warning(_("background image not found: \"%s\""), bp->value); return; } /* We can't use render on these. */ ip->useRender = 0; /* Determine the size of the background pixmap. */ if(bp->type == BACKGROUND_TILE) { width = ip->image->width; height = ip->image->height; } else { width = rootWidth; height = rootHeight; } /* Create the window. */ bp->window = JXCreateSimpleWindow(display, rootWindow, 0, 0, rootWidth, rootHeight, 0, 0, 0); /* Create the pixmap. */ bp->pixmap = JXCreatePixmap(display, bp->window, width, height, rootDepth); /* Clear the pixmap in case it is too small. */ JXSetForeground(display, rootGC, 0); JXFillRectangle(display, bp->pixmap, rootGC, 0, 0, width, height); /* Draw the icon on the background pixmap. */ PutIcon(ip, bp->pixmap, 0, 0, width, height); /* We don't need the icon anymore. */ DestroyIcon(ip); }
wxIcon GetApplicationIcon(int size) { HMODULE hParentExe = GetModuleHandle(NULL); if ( !hParentExe ) return wxNullIcon; LPTSTR iconName = 0; EnumResourceNames(hParentExe, RT_GROUP_ICON, GetFirstIconProc, (LONG_PTR)&iconName); if ( GetLastError() != ERROR_SUCCESS && GetLastError() != ERROR_RESOURCE_ENUM_USER_STOP ) return wxNullIcon; wxIcon icon = LoadNamedIcon(hParentExe, iconName, size); if ( !IS_INTRESOURCE(iconName) ) free(iconName); return icon; }
/** Load the icon for a client. */ void LoadIcon(ClientNode *np) { /* If client already has an icon, destroy it first. */ DestroyIcon(np->icon); np->icon = NULL; /* Attempt to read _NET_WM_ICON for an icon. */ np->icon = ReadNetWMIcon(np->window); if(np->icon) { return; } if(np->owner != None) { np->icon = ReadNetWMIcon(np->owner); if(np->icon) { return; } } /* Attempt to read an icon from XWMHints. */ np->icon = ReadWMHintIcon(np->window); if(np->icon) { return; } if(np->owner != None) { np->icon = ReadNetWMIcon(np->owner); if(np->icon) { return; } } /* Attempt to read an icon based on the window name. */ if(np->instanceName) { np->icon = LoadNamedIcon(np->instanceName, 1, 1); if(np->icon) { return; } } /* Load the default icon */ np->icon = GetDefaultIcon(); }
/** Apply a group to a client. */ void ApplyGroup(const GroupType *gp, ClientNode *np) { OptionListType *lp; Assert(gp); Assert(np); for(lp = gp->options; lp; lp = lp->next) { switch(lp->option) { case OPTION_STICKY: np->state.status |= STAT_STICKY; break; case OPTION_NOLIST: np->state.status |= STAT_NOLIST; break; case OPTION_NOPAGER: np->state.status |= STAT_NOPAGER; break; case OPTION_BORDER: np->state.border |= BORDER_OUTLINE; break; case OPTION_NOBORDER: np->state.border &= ~BORDER_OUTLINE; break; case OPTION_TITLE: np->state.border |= BORDER_TITLE; break; case OPTION_NOTITLE: np->state.border &= ~BORDER_TITLE; np->state.border &= ~BORDER_SHADE; break; case OPTION_LAYER: np->state.layer = lp->uvalue; break; case OPTION_DESKTOP: if(JLIKELY(lp->uvalue >= 1 && lp->uvalue <= settings.desktopCount)) { np->state.desktop = lp->uvalue - 1; } else { Warning(_("invalid group desktop: %d"), lp->uvalue); } break; case OPTION_ICON: DestroyIcon(np->icon); np->icon = LoadNamedIcon(lp->svalue, 1); break; case OPTION_PIGNORE: np->state.status |= STAT_PIGNORE; break; case OPTION_IIGNORE: np->state.status |= STAT_IIGNORE; break; case OPTION_MAXIMIZED: np->state.status |= STAT_HMAX | STAT_VMAX; break; case OPTION_MINIMIZED: np->state.status |= STAT_MINIMIZED; break; case OPTION_SHADED: np->state.status |= STAT_SHADED; break; case OPTION_OPACITY: np->state.opacity = lp->uvalue; np->state.status |= STAT_OPACITY; break; case OPTION_MAX_V: np->state.border &= ~BORDER_MAX_H; break; case OPTION_MAX_H: np->state.border &= ~BORDER_MAX_V; break; case OPTION_NOFOCUS: np->state.status |= STAT_NOFOCUS; break; case OPTION_NOSHADE: np->state.border &= ~BORDER_SHADE; break; case OPTION_CENTERED: np->state.status |= STAT_CENTERED; break; case OPTION_TILED: np->state.status |= STAT_TILED; break; case OPTION_NOTURGENT: np->state.status |= STAT_NOTURGENT; break; case OPTION_CONSTRAIN: np->state.border |= BORDER_CONSTRAIN; break; default: Debug("invalid option: %d", lp->option); break; } } }
/** Apply a group to a client. */ void ApplyGroup(const GroupType *gp, ClientNode *np) { OptionListType *lp; unsigned int temp; float tempf; Assert(gp); Assert(np); for(lp = gp->options; lp; lp = lp->next) { switch(lp->option) { case OPTION_STICKY: np->state.status |= STAT_STICKY; break; case OPTION_NOLIST: np->state.status |= STAT_NOLIST; break; case OPTION_BORDER: np->state.border |= BORDER_OUTLINE; break; case OPTION_NOBORDER: np->state.border &= ~BORDER_OUTLINE; break; case OPTION_TITLE: np->state.border |= BORDER_TITLE; break; case OPTION_NOTITLE: np->state.border &= ~BORDER_TITLE; break; case OPTION_LAYER: temp = atoi(lp->value); if(temp <= LAYER_COUNT) { SetClientLayer(np, temp); } else { Warning("invalid group layer: %s", lp->value); } break; case OPTION_DESKTOP: temp = atoi(lp->value); if(temp >= 1 && temp <= desktopCount) { np->state.desktop = temp - 1; } else { Warning("invalid group desktop: %s", lp->value); } break; case OPTION_ICON: DestroyIcon(np->icon); np->icon = LoadNamedIcon(lp->value); break; case OPTION_PIGNORE: np->state.status |= STAT_PIGNORE; break; case OPTION_MAXIMIZED: np->state.status |= STAT_HMAX | STAT_VMAX; break; case OPTION_MINIMIZED: np->state.status |= STAT_MINIMIZED; break; case OPTION_SHADED: np->state.status |= STAT_SHADED; break; case OPTION_OPACITY: tempf = atof(lp->value); if(tempf > 0.0 && tempf <= 1.0) { np->state.opacity = (unsigned int)(tempf * UINT_MAX); np->state.status |= STAT_OPACITY; } else { Warning("invalid group opacity: %s", lp->value); } break; case OPTION_MAX_V: np->state.border &= ~BORDER_MAX_H; break; case OPTION_MAX_H: np->state.border &= ~BORDER_MAX_V; break; case OPTION_NOFOCUS: np->state.status |= STAT_NOFOCUS; break; default: Debug("invalid option: %d", lp->option); break; } } }