/*
 *  WindowMaker window manager
 * 
 *  Copyright (c) 1997 Alfredo K. Kojima
 * 
 *  This program 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 of the License, or
 *  (at your option) any later version.
 *
 *  This program 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 program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef WMSCREEN_H_
#define WMSCREEN_H_

#include "wconfig.h"
#include "WindowMaker.h"
#include "texture.h"
#include <sys/types.h>

typedef struct WFont {
#ifndef I18N_MB
    XFontStruct *font;
#else
    XFontSet font;
#endif
    short height;
    short y;
} WFont;


/*
 * each WScreen is saved into a context associated with it's root window
 */
typedef struct WScreen {
    int	screen;			       /* screen number */
    Window root_win;		       /* root window of screen */
    int  depth;			       /* depth of the default visual */
    Colormap colormap;		       /* root colormap */
    
    Window w_win;		       /* window to use as drawable
					* for new GCs, pixmaps etc. */
    Visual *w_visual;
    int  w_depth;
    Colormap w_colormap;	       /* our colormap */
    
    Window no_focus_win;	       /* window to get focus when nobody
					* else can do it */

    Colormap current_colormap;	       /* the colormap installed now */
    struct WWindow *focused_window;    /* window that has the focus
					* Use this list if you want to
					* traverse the entire window list
					*/
#ifdef BUGGYSTACKING
    struct WCoreWindow *stacking_list; /* array of lists of windows
					* in stacking order.
					*/
#else
    struct WCoreWindow *stacking_list[MAX_WINDOW_LEVELS];
    				       /* array of lists of windows
					* in stacking order.
					* The array order is in window level
					* order and each list on the array
					* is ordered from the topmost to
					* the lowest window
					*/
    int window_level_count[MAX_WINDOW_LEVELS];
#endif 
    int window_count;		       /* number of windows in window_list */

    short workspace;		       /* current workspace number */
    short last_workspace;	       /* last workspace number */

    unsigned long black_pixel;
    unsigned long white_pixel;

    Pixmap stipple_bitmap;
    Pixmap transp_stipple;	       /* for making holes in icon masks for
					* transparent icon simulation */
    WFont title_font;		       /* default font for the titlebars */
    WFont menu_title_font;	       /* font for menu titlebars */
    WFont menu_entry_font;	       /* font for menu items */
    WFont icon_title_font;	       /* for icon titles */
    WFont panel_title_font;	       /* dialog box title */
    WFont panel_text_font;	       /* dialog box text */
    WFont info_text_font;	       /* text on things like geometry
					* hint boxes */

    int scr_width;		       /* size of the screen */
    int scr_height;

    /* foreground colors */
    unsigned long ftitle_pixel;	       /* focused titlebar text */
    unsigned long ptitle_pixel;	       /* semi-focused titlebar text */
    unsigned long utitle_pixel;	       /* unfocused titlebar text */
    unsigned long mtitle_pixel;	       /* menu titlebar text */
    unsigned long mtext_pixel;	       /* menu item text */
    unsigned long dtext_pixel;	       /* disabled menu item text */

    WTexture *appmenu_title_texture;   /* application menu titlebar texture*/
				       /* same as focused window texture */
    WTexture *menu_title_texture;      /* menu titlebar texture */
    WTexture *menu_item_texture;       /* menu item texture */
    WTexture *focused_texture;	       /* default focused win texture */
    WTexture *pfocused_texture;	       /* default semi-focused win texture */
    WTexture *unfocused_texture;       /* default unfocused win texture */
    WTexture *resizebar_texture;       /* window resizebar texture */
    WTexture *normal_button_texture;   /* unpushed buttons */
    WTexture *pushed_button_texture;   /* pushed buttons */
    WTexSolid *menu_item_auxtexture;   /* additional texture for menu
					* item */
    WTexSolid *icon_title_texture;     /* icon titles */

    GC focused_text_gc;		       /* def. focused text GC */
    GC pfocused_text_gc;	       /* def. focused text GC */
    GC unfocused_text_gc;	       /* def. unfocused text GC */
    GC icon_title_gc;		       /* icon title background */
    GC menu_title_gc;		       /* menu titles */
    GC menu_entry_gc;		       /* menu entries */
    GC select_menu_gc;		       /* selected menu entries */
    GC disabled_menu_entry_gc;	       /* disabled menu entries */
    GC info_text_gc;		       /* for size/position display */

    GC frame_gc;		       /* gc for resize/move frame (root) */
    GC line_gc;			       /* gc for drawing XORed lines (root) */
    GC copy_gc;			       /* gc for XCopyArea() */
    GC stipple_gc;		       /* gc for stippled filling */

    struct WPixmap *b_pixmaps[PRED_BPIXMAPS]; /* internal pixmaps for buttons*/

    struct WPixmap *button_arrow;       /* arrow pixmap for panel buttons */
    int app_menu_x, app_menu_y;	       /* position for application menus */

    struct WMenu *root_menu;	       /* root window menu */
    struct WMenu *workspace_menu;      /* workspace operation */
    struct WMenu *switch_menu;	       /* window list menu */
    struct WMenu *window_menu;	       /* window command menu */

#ifdef DOCK
    struct WDock *dock;		       /* the application dock */
    struct WPixmap *dock_dots;	       /* 3 dots for the Dock */
    struct WPixmap *dock_tbolt;	       /* autostart indicator */
    Window dock_shadow;		       /* shadow for dock buttons */
#endif
    
    Window geometry_display;	       /* displays the geometry during
					* window resize, move etc. */

    struct RContext *rcontext;
    struct RImage *icon_tile;
    Pixmap icon_tile_pixmap;	       /* for app supplied icons */
    
    Pixmap def_icon_pixmap;	       /* default icons */
    Pixmap def_ticon_pixmap;

    /* state and other informations */
    short cascade_index;	       /* for cascade window placement */

    short icon_aux;
    struct {
	unsigned int startup:1;	       /* during window manager startup */
    } flags;
} WScreen;


#define WSS_ROOTMENU	(1<<0)
#define WSS_SWITCHMENU	(1<<1)
#define WSS_WSMENU	(1<<2)

typedef struct WWorkspaceState {
    short flags;
    short workspace;
    int dock_position;
    int menu_x, menu_y;
    int smenu_x, smenu_y;
    int wmenu_x, wmenu_y;
} WWorkspaceState;


WScreen *wScreenInit(int screen_number);
void wScreenSaveState(WScreen *scr);

#endif
