/*
 * src/client.h - client management
 *
 * Copyright (C) 1999, 2000 Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this package; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.  
 */

#ifndef __CLIENT_H__
#define __CLIENT_H__

#if HAVE_CONFIG_H
# include <config.h>
#endif 

#include <X11/Xlib.h>
#include <X11/Xutil.h>

typedef struct client * client_t;
struct client
{
  client_t next;		/* Next client in client list.  */
  Window window;		/* Window handle for the client.  */
  Window parent;		/* Window handle for the parent window.  */
  Window tab;			/* Window handle for the tab window */
  Window transient_for;		/* Window handle the client belongs
                                   to, if it is transient.  */
  char * name;			/* Window name.  */
  Colormap cmap;		/* Colormap for the client window. */
  XSizeHints * size;		/* Size hints for the window.  */
  int ignore_unmap;		/* Counter for unmap requests to be
                                   ignored.  */
  int tab_width;		/* Width of the tab.  */
  int title_height;		/* Height of the tab.  */
  int tab_offset;		/* X-offset of the tab.  */
  int tab_offset_goal;		/* Desirable tab X-offset.  */
  int tab_dir;			/* Direction the tab is moving. */

  int is_maximized;		/* True if client is maximized.  */
  int old_x;			/* Saved X value.  */
  int old_y;			/* Saved Y value.  */
  int old_width;		/* Saved width.  */
  int old_height;		/* Saved height.  */

  int x;			/* Current X.  */
  int y;			/* Current Y.  */
  int width;			/* Current width.  */
  int height;			/* Current height.  */

  int workset;			/* Working set to display on.  */
  
  int wm_state;			/* WM state of the client.  */
};

/*
 * CLIENT_ROOT is the root og the client structure chain.
 */
extern client_t client_root;

/*
 * CURRENT_CLIENT points to the client which has the input focus, or
 * is NULL if no client hash currently the focus.
 */
extern client_t current_client;

/*
 * Find the client structure which holds information about window W. W
 * is viewed as being the clients own window if FROM_PARENT is zero,
 * otherwise, W is considered being the parent window.
 *
 * Window w		Window to search for.
 * int from_parent	If zero, search for client window W, otherwise
 *			search for the parent window W.
 */
client_t find_client(Window w, int from_parent);

/* Find the client which belongs to the tab window @var{w}.  */
client_t find_client_from_tab (Window w);

/*
 * Remove the client C from the client list and free the resources it
 * allocated.
 *
 * client_t c	Client to remove.
 */
void remove_client(client_t c);

/*
 * Delete the window of client C.  Uses the DELETE client message if
 * the client window supports that message, kills the client otherwise.
 *
 * client_t c	The client window to remove.
 */
void send_wm_delete(client_t c);

/*
 * Send the current window configuration of the client C to its window.
 *
 * client_t c	Client whose configuration has been changed.
 */
void send_config(client_t c);

/*
 * Set the WM state of client C to STATE.
 *
 * client_t c	Client to change state.
 * int state	New state for the client.
 */
void set_wm_state(client_t c, int state);

/*
 * Return the current WM state of client c.
 *
 * client_t c	Client to request state for.
 */
int get_wm_state(client_t c);

/*
 * Redraw the parent window of client C.
 *
 * client_t c	Client whose frame is to be redrawn.
 */
void redraw(client_t c);

void set_shape (client_t c);

/*
 * Track mouse movement until the user clicks and releases the mouse
 * button.  Return the client the user has clicked or NULL, if the
 * root window was clicked.
 */
client_t manually_select_window (void);

/*
 * Allocate a new client structure for window WIN and insert it into
 * the global client list.
 */
void create_client_window (Window win, XWindowAttributes *attr);

/* Toggle the full-screen mode of the client window @var{c}.  */
void full_screen_client (client_t c);

void client_realize_size (client_t c);
void client_realize_move (client_t c);
void client_realize_tab_move (client_t c);
void client_raise (client_t c);
void client_lower (client_t c);

void client_adjust_tab_width (client_t c);

void client_tick (void);

#endif /* not __CLIENT_H__ */

