---
name: "ggiWmhDetach"
section: "3"
platform: "linux"
package: "libggiwmh0-dev"
version: "0.3.2-2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/ggiWmhInit"
---

# ggiWmhDetach(3)

Initialize and Uninitialize LibGGIWmh

Part of [ggiWmhInit(3)](/ggiWmhInit/3.md).

## NAME

**ggiWmhInit**, **ggiWmhExit**, **ggiWmhAttach**, **ggiWmhDetach** - Initialize and Uninitialize LibGGIWmh

## SYNOPSIS

```
#include <ggi/wmh.h>
int ggiWmhInit(void);
int ggiWmhExit(void);
int ggiWmhAttach(ggi_visual_t vis);
int ggiWmhDetach(ggi_visual_t vis);
```

## DESCRIPTION

These are the standard LibGGI extension management functions for the LibGGIWmh extension. They allow initialization and deinitialization of the extension as a whole and of individual visuals.

**ggiWmhInit** will initialize an instance of the LibGGIWmh extension and prepare it to attach to visuals.

**ggiWmhAttach**, if successful, will allow LibGGIWmh functions to operate on the named visual.

**ggiWmhDetach**, if successful, will clean up all resources involved in providing the named visual with the LibGGIWmh API.

**ggiWmhExit** will free all resources associated with an instance of LibGGIWmh.

## RETURN VALUE

**ggiWmhInit** returns **0** for OK, otherwise an `ggi-error(3)` code.

**ggiWmhExit** returns:

- **0**

  after successfully cleaning up,

- **\>0**

  the number of 'open' **ggiWmhInit** calls, if there has been more than one call to **ggiWmhInit**. As **ggiWmhInit** and **ggiWmhExit** must be used in properly nested pairs, e.g. the first **ggiWmhExit** after two **ggiWmhInit**'s will return **1**.

- **\<0**

  `ggi-error(3)`, especially if more **ggiWmhExit** calls have been done than **ggiWmhInit** calls.

**ggiWmhAttach** returns:

- **\>=0**

  the number LibGGIWmh has been attached to this visual, whereas 0 means the first time.

- **\<0**

  indicates an `ggi-error(3)`.

**ggiWmhDetach** returns:

- **0**

  after successfully cleaning up,

- **\>0**

  the number of 'open' **ggiWmhAttach** calls, if there has been more than one call to **ggiWmhAttach**. As **ggiWmhAttach** and **ggiWmhDetach** must be used in properly nested pairs, e.g. the first **ggiWmhDetach** after two **ggiWmhInit\`s will return \`1**.

- **\<0**

  `ggi-error(3)`, especially if more **ggiWmhDetach** calls have been done than **ggiWmhAttach** calls.

## EXAMPLES

```
ggi_visual_t vis;
ggiInit();
ggiWmhInit();
vis = ggiOpen(NULL);
ggiWmhAttach(vis);
/* ... */
ggiWmhDetach(vis);
ggiWmhExit();
ggiExit();
```
