File indexing completed on 2024-05-12 17:10:55

0001 #ifndef EMERALD_H
0002 #define EMERALD_H
0003 #ifdef HAVE_CONFIG_H
0004 #include <config.h>
0005 #endif
0006 
0007 #include <decoration.h>
0008 #if 0
0009 #include <X11/Xlib.h>
0010 #include <X11/Xatom.h>
0011 #include <X11/Xregion.h>
0012 #include <X11/cursorfont.h>
0013 #include <X11/extensions/Xrender.h>
0014 
0015 #ifndef GDK_DISABLE_DEPRECATED
0016 #define GDK_DISABLE_DEPRECATED
0017 #endif
0018 
0019 #ifndef GTK_DISABLE_DEPRECATED
0020 #define GTK_DISABLE_DEPRECATED
0021 #endif
0022 
0023 #include <gtk/gtk.h>
0024 #include <gtk/gtkwindow.h>
0025 #include <gdk/gdkx.h>
0026 
0027 #define IS_VALID(o) (o && o->parent_instance.ref_count)
0028 
0029 #ifdef USE_DBUS
0030 #define DBUS_API_SUBJECT_TO_CHANGE
0031 #include <dbus/dbus.h>
0032 #include <dbus/dbus-glib.h>
0033 #include <dbus/dbus-glib-lowlevel.h>
0034 #endif
0035 
0036 //#include <gconf/gconf-client.h>
0037 
0038 #define WNCK_I_KNOW_THIS_IS_UNSTABLE
0039 #include <libwnck/libwnck.h>
0040 #include <libwnck/window-action-menu.h>
0041 #endif
0042 #include <cairo.h>
0043 #include <cairo-xlib.h>
0044 
0045 #if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 1, 0)
0046 #define CAIRO_EXTEND_PAD CAIRO_EXTEND_NONE
0047 #endif
0048 #if 0
0049 #include <pango/pango-context.h>
0050 #include <pango/pangocairo.h>
0051 #endif
0052 #include <dlfcn.h>
0053 #include <glib.h>
0054 #include <glib/gstdio.h>
0055 #include <string.h>
0056 #include <stdlib.h>
0057 #include <math.h>
0058 #include <limits.h>
0059 #include <unistd.h>
0060 #include <sys/types.h>
0061 #include <signal.h>
0062 #include <sys/wait.h>
0063 #include<libintl.h>
0064 #include<locale.h>
0065 #define _(String) gettext (String)
0066 #define gettext_noop(String) String
0067 #define N_(String) gettext_noop (String)
0068 
0069 #define FAKE_WINDOW_ACTION_HELP (1 << 20)
0070 
0071 #define WM_MOVERESIZE_SIZE_TOPLEFT      0
0072 #define WM_MOVERESIZE_SIZE_TOP          1
0073 #define WM_MOVERESIZE_SIZE_TOPRIGHT     2
0074 #define WM_MOVERESIZE_SIZE_RIGHT        3
0075 #define WM_MOVERESIZE_SIZE_BOTTOMRIGHT  4
0076 #define WM_MOVERESIZE_SIZE_BOTTOM       5
0077 #define WM_MOVERESIZE_SIZE_BOTTOMLEFT   6
0078 #define WM_MOVERESIZE_SIZE_LEFT         7
0079 #define WM_MOVERESIZE_MOVE              8
0080 #define WM_MOVERESIZE_SIZE_KEYBOARD     9
0081 #define WM_MOVERESIZE_MOVE_KEYBOARD    10
0082 
0083 #define SHADOW_RADIUS      8.0
0084 #define SHADOW_OPACITY     0.5
0085 #define SHADOW_COLOR_RED   0x0000
0086 #define SHADOW_COLOR_GREEN 0x0000
0087 #define SHADOW_COLOR_BLUE  0x0000
0088 #define SHADOW_OFFSET_X    1
0089 #define SHADOW_OFFSET_Y    1
0090 
0091 #define MWM_HINTS_DECORATIONS (1L << 1)
0092 
0093 #define MWM_DECOR_ALL      (1L << 0)
0094 #define MWM_DECOR_BORDER   (1L << 1)
0095 #define MWM_DECOR_HANDLE   (1L << 2)
0096 #define MWM_DECOR_TITLE    (1L << 3)
0097 #define MWM_DECOR_MENU     (1L << 4)
0098 #define MWM_DECOR_MINIMIZE (1L << 5)
0099 #define MWM_DECOR_MAXIMIZE (1L << 6)
0100 
0101 #define BLUR_TYPE_NONE     0
0102 #define BLUR_TYPE_TITLEBAR 1
0103 #define BLUR_TYPE_ALL      2
0104 
0105 #define PROP_MOTIF_WM_HINT_ELEMENTS 3
0106 
0107 typedef struct {
0108     unsigned long flags;
0109     unsigned long functions;
0110     unsigned long decorations;
0111 } MwmHints;
0112 
0113 //static double decoration_alpha = 0.5; //Decoration Alpha
0114 
0115 #define SWITCHER_SPACE     40
0116 #define SWITCHER_TOP_EXTRA 4
0117 
0118 typedef struct _decor_color {
0119     double r;
0120     double g;
0121     double b;
0122 } decor_color_t;
0123 
0124 
0125 #include <titlebar.h>
0126 
0127 //typedef void (*event_callback) (WnckWindow *win, XEvent *event);
0128 
0129 #define ACOLOR(idn,zr,zg,zb,za) \
0130     pfs->idn.color.r = (zr);\
0131     pfs->idn.color.g = (zg);\
0132     pfs->idn.color.b = (zb);\
0133     pfs->idn.alpha   = (za);
0134 
0135 #define CCOLOR(idn,zc) \
0136     pfs->idn.color.r = (pfs->color_contrast * pfs->zc.color.r);\
0137     pfs->idn.color.g = (pfs->color_contrast * pfs->zc.color.g);\
0138     pfs->idn.color.b = (pfs->color_contrast * pfs->zc.color.b);\
0139     pfs->idn.alpha   = (pfs->alpha_contrast * pfs->zc.alpha);
0140 
0141 typedef struct _alpha_color
0142 {
0143     decor_color_t color;
0144     double alpha;
0145 } alpha_color;
0146 
0147 typedef struct _pos_t {
0148     int x, y, w, h;
0149     int xw, yh, ww, hh;
0150 } pos_t;
0151 
0152 typedef struct _frame_settings frame_settings;
0153 
0154 typedef struct _window_settings
0155 {
0156     void * engine_ws;
0157     gint button_offset;
0158     gint button_hoffset;
0159     gchar * tobj_layout;
0160     
0161     gint double_click_action;
0162     gint button_hover_cursor;
0163 
0164     gboolean round_top_left;
0165     gboolean round_top_right;
0166     gboolean round_bottom_left;
0167     gboolean round_bottom_right;
0168 
0169     frame_settings * fs_act;
0170     frame_settings * fs_inact;
0171     gint min_titlebar_height;
0172     gboolean use_pixmap_buttons;// = FALSE;
0173     double  corner_radius;//    =   5.0;
0174     PangoAlignment title_text_align;// = PANGO_ALIGN_CENTER;
0175     GdkPixbuf * ButtonPix[S_COUNT*B_COUNT];
0176     GdkPixbuf * ButtonArray[B_COUNT];
0177 
0178     gboolean    use_button_glow;
0179     gboolean    use_button_inactive_glow;
0180     gboolean    use_decoration_cropping;
0181     gboolean    use_button_fade;
0182     GdkPixbuf * ButtonGlowPix[B_COUNT];
0183     GdkPixbuf * ButtonGlowArray;
0184     GdkPixbuf * ButtonInactiveGlowArray;
0185     GdkPixbuf * ButtonInactiveGlowPix[B_COUNT];
0186     int         button_fade_num_steps;        // number of steps
0187     int         button_fade_step_duration;    // step duration in milliseconds
0188     int         button_fade_pulse_len_steps;  // length of pulse (number of steps)
0189     int         button_fade_pulse_wait_steps; // how much pulse waits before fade out
0190     /* = {
0191     { 0, 6, 16, 16,   1, 0, 0, 0 },
0192     { 0, 6, 16, 16,   1, 0, 0, 0 },
0193     { 0, 6, 16, 16,   1, 0, 0, 0 },
0194     { 0, 6, 16, 16,   1, 0, 0, 0 },
0195     };*/
0196     gdouble shadow_radius;
0197     gdouble shadow_opacity;
0198     gint    shadow_color[3];
0199     gint    shadow_offset_x;
0200     gint    shadow_offset_y;
0201     decor_extents_t shadow_extents;//   = { 0, 0, 0, 0 };
0202     decor_extents_t win_extents;//      = { 6, 6, 4, 6 };
0203     pos_t pos[3][3];
0204     gint left_space;//   = 6;
0205     gint right_space;//  = 6;
0206     gint top_space;//    = 4;
0207     gint bottom_space;// = 6;
0208 
0209     gint left_corner_space;//   = 0;
0210     gint right_corner_space;//  = 0;
0211     gint top_corner_space;//    = 0;
0212     gint bottom_corner_space;// = 0;
0213 
0214     gint titlebar_height;// = 17; //Titlebar Height
0215 
0216     gint normal_top_corner_space;//      = 0;
0217 
0218     gint shadow_left_space;//   = 0;
0219     gint shadow_right_space;//  = 0;
0220     gint shadow_top_space;//    = 0;
0221     gint shadow_bottom_space;// = 0;
0222 
0223     gint shadow_left_corner_space;//   = 0;
0224     gint shadow_right_corner_space;//  = 0;
0225     gint shadow_top_corner_space;//    = 0;
0226     gint shadow_bottom_corner_space;// = 0;
0227 
0228 
0229     GdkPixmap *shadow_pixmap;// = NULL;
0230     GdkPixmap *large_shadow_pixmap;// = NULL;
0231     GdkPixmap *decor_normal_pixmap;// = NULL;
0232     GdkPixmap *decor_active_pixmap;// = NULL;
0233 
0234     cairo_pattern_t *shadow_pattern;// = NULL;
0235 
0236     gint            text_height;
0237 
0238     PangoFontDescription *font_desc;
0239     PangoContext * pango_context;
0240 
0241     decor_extents_t switcher_extents;// = { 0, 0, 0, 0 };
0242     GdkPixmap *switcher_pixmap;// = NULL;
0243     GdkPixmap *switcher_buffer_pixmap;// = NULL;
0244     gint      switcher_width;
0245     gint      switcher_height;
0246 
0247     gint switcher_top_corner_space;//    = 0;
0248     gint switcher_bottom_corner_space;// = 0;
0249 
0250     struct _icon_size {
0251         int w, h;
0252     } c_icon_size[B_T_COUNT],
0253       c_glow_size; // one glow size for all buttons
0254                    // (buttons will be centered in their glows)
0255                    // active and inactive glow pixmaps are assumed to be of same size
0256     gboolean stretch_sides;
0257     gint blur_type;// = BLUR_TYPE_NONE;
0258     
0259 } window_settings;
0260 
0261 struct _frame_settings
0262 {
0263     void * engine_fs;
0264     window_settings *ws;
0265     alpha_color button;
0266     alpha_color button_halo;
0267     alpha_color text;
0268     alpha_color text_halo;
0269 };
0270 
0271 typedef struct _rectangle {
0272     gint        x1, y1, x2, y2;
0273 } rectangle_t;
0274 
0275 typedef struct _button_fade_info
0276 {
0277     gpointer * d; // needed by the timer function
0278     cairo_t * cr;
0279     double    y1;
0280     int  counters[B_T_COUNT]; // 0: not fading, > 0: fading in, < 0: fading out
0281                               // max value:  ws->button_fade_num_steps+1 (1 is reserved to indicate
0282                               //                                          fade-in initiation)
0283                               // min value: -ws->button_fade_num_steps
0284     gboolean pulsating[B_T_COUNT];
0285     gint    timer;
0286     gboolean first_draw;
0287 } button_fade_info_t;
0288 
0289 typedef struct _button_region_t {
0290     gint        base_x1, base_y1, base_x2, base_y2; // button coords with no glow
0291     gint        glow_x1, glow_y1, glow_x2, glow_y2; // glow coordinates
0292 
0293     // holds whether this button's glow overlap with the other button's non-glow (base) area
0294     gboolean    overlap_buttons[B_T_COUNT];
0295     GdkPixmap * bg_pixmap;
0296 } button_region_t;
0297 
0298 typedef struct _decor
0299 {
0300     Window        event_windows[3][3];
0301     Window        button_windows[B_T_COUNT];
0302     guint         button_states[B_T_COUNT];
0303     gint tobj_pos[3];
0304     gint tobj_size[3];
0305     gint tobj_item_pos[11];
0306     gint tobj_item_state[11];
0307     gint tobj_item_width[11];
0308     GdkPixmap         *pixmap;
0309     GdkPixmap         *buffer_pixmap;
0310     GdkGC         *gc;
0311     gint          width;
0312     gint          height;
0313     gint              client_width;
0314     gint              client_height;
0315     gboolean          decorated;
0316     gboolean          active;
0317     PangoLayout       *layout;
0318     gchar         *name;
0319     cairo_pattern_t   *icon;
0320     GdkPixmap         *icon_pixmap;
0321     GdkPixbuf         *icon_pixbuf;
0322     WnckWindowState   state;
0323     WnckWindowActions actions;
0324     XID           prop_xid;
0325     GtkWidget         *force_quit_dialog;
0326     frame_settings * fs;
0327     void          (*draw) (struct _decor *d);
0328     button_region_t   button_region[B_T_COUNT];
0329     rectangle_t       min_drawn_buttons_region; // minimal rectangle enclosing all drawn regions
0330     gboolean          draw_only_buttons_region;
0331     gint              button_last_drawn_state[B_T_COUNT]; // last drawn state or fade counter
0332     button_fade_info_t button_fade_info;
0333     GdkPixmap * p_active, * p_active_buffer;
0334     GdkPixmap * p_inactive, * p_inactive_buffer;
0335     button_region_t   button_region_inact[B_T_COUNT];
0336     gboolean only_change_active;
0337 } decor_t;
0338 
0339 #define LFACSS(zc,sec) \
0340     load_color_setting(f,&ws->fs_act->zc.color,"active_" #zc , #sec);\
0341     load_color_setting(f,&ws->fs_inact->zc.color,"inactive_" #zc , #sec);\
0342     load_float_setting(f,&ws->fs_act->zc.alpha,"active_" #zc "_alpha", #sec);\
0343     load_float_setting(f,&ws->fs_inact->zc.alpha,"inactive_" #zc "_alpha", #sec);
0344 
0345 #define SHADE_LEFT   (1 << 0)
0346 #define SHADE_RIGHT  (1 << 1)
0347 #define SHADE_TOP    (1 << 2)
0348 #define SHADE_BOTTOM (1 << 3)
0349 
0350 #define CORNER_TOPLEFT     (1 << 0)
0351 #define CORNER_TOPRIGHT    (1 << 1)
0352 #define CORNER_BOTTOMRIGHT (1 << 2)
0353 #define CORNER_BOTTOMLEFT  (1 << 3)
0354 
0355 #endif