JWM Source Documentation
Data Structures | Macros | Typedefs | Functions | Variables
icon.c File Reference

Icon functions. More...

#include "jwm.h"
#include "icon.h"
#include "client.h"
#include "render.h"
#include "main.h"
#include "image.h"
#include "misc.h"
#include "hint.h"
#include "color.h"
#include "settings.h"
#include "border.h"

Go to the source code of this file.

Data Structures

struct  IconPathNode
 Linked list of icon paths. More...
 

Macros

#define HASH_SIZE   128
 

Typedefs

typedef struct IconPathNode IconPathNode
 Linked list of icon paths.
 

Functions

static void DoDestroyIcon (int index, IconNode *icon)
 Helper method for destroy icons.
 
static IconNodeReadNetWMIcon (Window win)
 Read the icon property from a client.
 
static IconNodeReadWMHintIcon (Window win)
 Read the icon WMHint property from a client.
 
static IconNodeCreateIcon (const ImageNode *image)
 Create an empty icon node.
 
static IconNodeCreateIconFromDrawable (Drawable d, Pixmap mask)
 
static IconNodeCreateIconFromBinary (const unsigned long *input, unsigned int length)
 Create an icon from binary data (as specified via window properties).
 
static IconNodeLoadNamedIconHelper (const char *name, const char *path, char save, char preserveAspect)
 Helper for loading icons by name.
 
static ImageNodeGetBestImage (IconNode *icon, int rwidth, int rheight)
 Get the best image for the requested size.
 
static ScaledIconNodeGetScaledIcon (IconNode *icon, long fg, int rwidth, int rheight)
 Get a scaled icon.
 
static void InsertIcon (IconNode *icon)
 Insert an icon to the icon hash table.
 
static IconNodeFindIcon (const char *name)
 Find a icon in the icon hash table.
 
static unsigned int GetHash (const char *str)
 Get the hash for a string.
 
void InitializeIcons (void)
 Initialize icon data.
 
void StartupIcons (void)
 Startup icon support.
 
void ShutdownIcons (void)
 Shutdown icon support.
 
void DestroyIcons (void)
 Destroy icon data.
 
void AddIconPath (char *path)
 Add an icon search path.
 
void PutIcon (IconNode *icon, Drawable d, long fg, int x, int y, int width, int height)
 Draw an icon.
 
void LoadIcon (ClientNode *np)
 Load the icon for a client.
 
IconNodeLoadNamedIcon (const char *name, char save, char preserveAspect)
 Load an icon from a file.
 
IconNodeGetDefaultIcon (void)
 Create an icon from XPM image data.
 
void DestroyIcon (IconNode *icon)
 Destroy an icon.
 
void SetDefaultIcon (const char *name)
 Set the name of the default icon.
 

Variables

IconNode emptyIcon
 
const char * ICON_EXTENSIONS []
 
static const unsigned EXTENSION_COUNT = ARRAY_LENGTH(ICON_EXTENSIONS)
 
static const unsigned MAX_EXTENSION_LENGTH = 5
 
static IconNode ** iconHash
 
static IconPathNodeiconPaths
 
static IconPathNodeiconPathsTail
 
static GC iconGC
 
static char iconSizeSet = 0
 
static char * defaultIconName
 

Detailed Description

Icon functions.

Author
Joe Wingbermuehle
Date
2004-2006

Definition in file icon.c.

Macro Definition Documentation

#define HASH_SIZE   128

Definition at line 27 of file icon.c.

Referenced by GetHash(), InitializeIcons(), and ShutdownIcons().

Typedef Documentation

typedef struct IconPathNode IconPathNode

Linked list of icon paths.

Function Documentation

void AddIconPath ( char *  path)

Add an icon search path.

Add an icon path.

Definition at line 159 of file icon.c.

References Allocate, ExpandPath(), IconPathNode::next, IconPathNode::path, and Trim().

Referenced by Parse().

IconNode * CreateIcon ( const ImageNode image)
static
IconNode * CreateIconFromBinary ( const unsigned long *  input,
unsigned int  length 
)
static

Create an icon from binary data (as specified via window properties).

Definition at line 741 of file icon.c.

References CreateIcon(), CreateImage(), ImageNode::data, Debug(), IconNode::images, JUNLIKELY, and ImageNode::next.

Referenced by ReadNetWMIcon().

IconNode * CreateIconFromDrawable ( Drawable  d,
Pixmap  mask 
)
static

Definition at line 508 of file icon.c.

References CreateIcon(), IconNode::images, and LoadImageFromDrawable().

Referenced by ReadWMHintIcon().

void DestroyIcon ( IconNode icon)

Destroy an icon.

Definition at line 860 of file icon.c.

References DoDestroyIcon(), GetHash(), IconNode::name, and IconNode::transient.

Referenced by ApplyGroup(), LoadIcon(), LoadImageBackground(), and RemoveClient().

void DestroyIcons ( void  )

Destroy icon data.

Definition at line 138 of file icon.c.

References defaultIconName, IconPathNode::next, IconPathNode::path, and Release.

Referenced by Destroy().

void DoDestroyIcon ( int  index,
IconNode icon 
)
static
IconNode * FindIcon ( const char *  name)
static

Find a icon in the icon hash table.

Definition at line 885 of file icon.c.

References GetHash(), IconNode::name, and IconNode::next.

Referenced by GetDefaultIcon(), and LoadNamedIcon().

ImageNode * GetBestImage ( IconNode icon,
int  rwidth,
int  rheight 
)
static

Get the best image for the requested size.

Definition at line 523 of file icon.c.

References ImageNode::height, IconNode::images, LoadImage(), Min, IconNode::name, ImageNode::next, IconNode::preserveAspect, and ImageNode::width.

Referenced by GetScaledIcon().

IconNode* GetDefaultIcon ( void  )

Create an icon from XPM image data.

Load the default icon.

Definition at line 446 of file icon.c.

References CopyString(), CreateIcon(), CreateImage(), ImageNode::data, defaultIconName, emptyIcon, FindIcon(), IconNode::images, InsertIcon(), LoadNamedIcon(), IconNode::name, and ImageNode::render.

Referenced by Render(), ShowClientList(), and StartupBorders().

unsigned int GetHash ( const char *  str)
static

Get the hash for a string.

Definition at line 900 of file icon.c.

References HASH_SIZE.

Referenced by DestroyIcon(), FindIcon(), and InsertIcon().

ScaledIconNode * GetScaledIcon ( IconNode icon,
long  fg,
int  rwidth,
int  rheight 
)
static
void InitializeIcons ( void  )

Initialize icon data.

This must be initialized before parsing the configuration.

Definition at line 92 of file icon.c.

References Allocate, defaultIconName, HASH_SIZE, and iconSizeSet.

Referenced by Initialize().

void InsertIcon ( IconNode icon)
static

Insert an icon to the icon hash table.

Definition at line 869 of file icon.c.

References Assert, GetHash(), IconNode::name, IconNode::next, IconNode::prev, and IconNode::transient.

Referenced by GetDefaultIcon(), LoadNamedIcon(), and LoadNamedIconHelper().

void LoadIcon ( ClientNode np)

Load the icon for a client.

Load an icon for a client.

Definition at line 251 of file icon.c.

References DestroyIcon(), ClientNode::icon, ClientNode::instanceName, LoadNamedIcon(), ClientNode::owner, ReadNetWMIcon(), ReadWMHintIcon(), and ClientNode::window.

Referenced by AddClientWindow(), and HandlePropertyNotify().

IconNode* LoadNamedIcon ( const char *  name,
char  save,
char  preserveAspect 
)
IconNode * LoadNamedIconHelper ( const char *  name,
const char *  path,
char  save,
char  preserveAspect 
)
static
void PutIcon ( IconNode icon,
Drawable  d,
long  fg,
int  x,
int  y,
int  width,
int  height 
)
IconNode * ReadNetWMIcon ( Window  win)
static

Read the icon property from a client.

Definition at line 403 of file icon.c.

References ATOM_NET_WM_ICON, atoms, CreateIconFromBinary(), display, JXFree, and JXGetWindowProperty.

Referenced by LoadIcon().

IconNode * ReadWMHintIcon ( Window  win)
static

Read the icon WMHint property from a client.

Definition at line 424 of file icon.c.

References CreateIconFromDrawable(), display, JXFree, and JXGetWMHints.

Referenced by LoadIcon().

void SetDefaultIcon ( const char *  name)

Set the name of the default icon.

Set the default icon.

Definition at line 914 of file icon.c.

References CopyString(), defaultIconName, and Release.

Referenced by Parse().

void ShutdownIcons ( void  )

Shutdown icon support.

Definition at line 126 of file icon.c.

References display, DoDestroyIcon(), HASH_SIZE, iconGC, and JXFreeGC.

Referenced by Shutdown().

void StartupIcons ( void  )

Startup icon support.

Definition at line 107 of file icon.c.

References display, GetBorderIconSize(), iconGC, JXCreateGC, JXSetIconSizes, and rootWindow.

Referenced by Startup().

Variable Documentation

char* defaultIconName
static

Definition at line 69 of file icon.c.

Referenced by DestroyIcons(), GetDefaultIcon(), InitializeIcons(), and SetDefaultIcon().

IconNode emptyIcon

Definition at line 22 of file icon.c.

Referenced by DrawButton(), GetDefaultIcon(), InitializeMenu(), and LoadNamedIcon().

const unsigned EXTENSION_COUNT = ARRAY_LENGTH(ICON_EXTENSIONS)
static

Definition at line 61 of file icon.c.

Referenced by LoadNamedIconHelper().

const char* ICON_EXTENSIONS[]
Initial value:
= {
"",
".png",
".PNG",
".xpm",
".XPM",
}

Definition at line 36 of file icon.c.

Referenced by LoadNamedIconHelper().

GC iconGC
static

Definition at line 67 of file icon.c.

Referenced by PutIcon(), ShutdownIcons(), and StartupIcons().

IconNode** iconHash
static

Definition at line 64 of file icon.c.

IconPathNode* iconPaths
static

Definition at line 65 of file icon.c.

IconPathNode* iconPathsTail
static

Definition at line 66 of file icon.c.

char iconSizeSet = 0
static

Definition at line 68 of file icon.c.

Referenced by InitializeIcons().

const unsigned MAX_EXTENSION_LENGTH = 5
static

Definition at line 62 of file icon.c.

Referenced by LoadNamedIconHelper().

joewing.net / Projects / JWM