summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-03-12 09:02:30 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-03-12 09:02:30 +0800
commit74014eb2739cef667845d3155b7fb594359e1774 (patch)
tree57c8fe59bae836f809621c06534aa361a37396dd
parent5eabaf50f1c98fb1bcdf8e453be3a2743f465f2b (diff)
downloadgtk-window-decorator-2d-testing-74014eb2739cef667845d3155b7fb594359e1774.tar.gz
gtk-window-decorator-2d-testing-74014eb2739cef667845d3155b7fb594359e1774.tar.bz2
Mostly works nowHEADmaster
-rw-r--r--window-decorator/gtk-window-decorator.c267
-rw-r--r--window-decorator/gtk-window-decorator.c~2644
2 files changed, 1820 insertions, 1091 deletions
diff --git a/window-decorator/gtk-window-decorator.c b/window-decorator/gtk-window-decorator.c
index ff3a542..8b82173 100644
--- a/window-decorator/gtk-window-decorator.c
+++ b/window-decorator/gtk-window-decorator.c
@@ -377,6 +377,7 @@ typedef struct _decor_color {
double b;
} decor_color_t;
+
#define IN_EVENT_WINDOW (1 << 0)
#define PRESSED_EVENT_WINDOW (1 << 1)
@@ -419,7 +420,7 @@ typedef struct _decor {
void (*draw) (struct _decor *d);
} decor_t;
-typedef struct _GTKWDButtonEvent {
+typedef struct _decor_event {
guint time;
guint window;
guint x;
@@ -427,15 +428,15 @@ typedef struct _GTKWDButtonEvent {
guint x_root;
guint y_root;
guint button;
-} GTKWDButtonEvent;
+} decor_event;
-typedef enum _GTKWDEventType {
+typedef enum _decor_event_type {
GButtonPress = 1,
GButtonRelease,
GEnterNotify,
GLeaveNotify,
GMotionNotify
-} GTKWDEventType;
+} decor_event_type;
void (*theme_draw_window_decoration) (decor_t *d);
gboolean (*theme_calc_decoration_size) (decor_t *d,
@@ -463,7 +464,7 @@ gboolean (*theme_get_button_position) (decor_t *d,
gint *w,
gint *h);
-typedef void (*event_callback) (WnckWindow *win, GTKWDButtonEvent *bevent, GTKWDEventType gType);
+typedef void (*event_callback) (WnckWindow *win, decor_event *bevent, decor_event_type gType);
static char *program_name;
@@ -3240,8 +3241,6 @@ meta_get_button_position (decor_t *d,
#endif
- // TODO: put region handlers here
-
static void
update_event_windows (WnckWindow *win)
{
@@ -3711,12 +3710,11 @@ meta_calc_decoration_size (decor_t *d,
{
if (TRUE)
{
- *width = layout.width + _win_extents.left + _win_extents.right + 2;
- *height = layout.height + _win_extents.top + _win_extents.bottom - 2;
+ *width = d->client_width + _win_extents.left + _win_extents.right + 2;
+ *height = d->client_height + layout.height + _win_extents.top + _win_extents.bottom - 2;
d->border_layout = layout;
d->context = context;
- //d->shadow = shadow;
meta_calc_button_size (d);
@@ -3738,9 +3736,6 @@ update_window_decoration_size (WnckWindow *win)
gint w, h, name_width;
gint x, y;
Display *xdisplay;
-
- if (d->pixmap)
- fprintf (stderr, "pixmap exists\n");
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
@@ -3831,7 +3826,7 @@ update_window_decoration_size (WnckWindow *win)
static void
move_resize_window (WnckWindow *win,
int direction,
- GTKWDButtonEvent *bevent)
+ decor_event *bevent)
{
Display *xdisplay;
GdkDisplay *gdkdisplay;
@@ -4081,8 +4076,8 @@ create_tooltip_window (void)
static void
handle_tooltip_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType,
+ decor_event *bevent,
+ decor_event_type gType,
guint state,
const char *tip)
{
@@ -4109,8 +4104,8 @@ handle_tooltip_event (WnckWindow *win,
static void
common_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType,
+ decor_event *bevent,
+ decor_event_type gType,
int button,
int max,
char *tooltip)
@@ -4130,17 +4125,15 @@ common_button_event (WnckWindow *win,
d->button_states[button] &= ~PRESSED_EVENT_WINDOW;
break;
case GEnterNotify:
- //fprintf (stderr, "I haz enter notify\n");
d->button_states[button] |= IN_EVENT_WINDOW;
break;
case GLeaveNotify:
- //fprintf (stderr, "I haz leave notify\n");
d->button_states[button] &= ~IN_EVENT_WINDOW;
break;
default:
break;
}
-
+
if (state != d->button_states[button])
{
queue_decor_draw (d);
@@ -4151,8 +4144,8 @@ common_button_event (WnckWindow *win,
static void
close_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_CLOSE];
@@ -4177,8 +4170,8 @@ close_button_event (WnckWindow *win,
static void
max_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_MAX];
@@ -4227,8 +4220,8 @@ max_button_event (WnckWindow *win,
static void
min_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_MIN];
@@ -4359,8 +4352,8 @@ action_menu_map (WnckWindow *win,
static void
menu_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
common_button_event (win, bevent, gType,
BUTTON_MENU, 1, _("Window Menu"));
@@ -4379,8 +4372,8 @@ menu_button_event (WnckWindow *win,
static void
shade_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_SHADE];
@@ -4403,8 +4396,8 @@ shade_button_event (WnckWindow *win,
static void
above_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_ABOVE];
@@ -4433,8 +4426,8 @@ above_button_event (WnckWindow *win,
static void
stick_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_STICK];
@@ -4457,8 +4450,8 @@ stick_button_event (WnckWindow *win,
static void
unshade_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_UNSHADE];
@@ -4481,8 +4474,8 @@ unshade_button_event (WnckWindow *win,
static void
unabove_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_UNABOVE];
@@ -4511,8 +4504,8 @@ unabove_button_event (WnckWindow *win,
static void
unstick_button_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_UNSTICK];
@@ -4536,7 +4529,7 @@ unstick_button_event (WnckWindow *win,
static void
handle_title_button_event (WnckWindow *win,
int action,
- GTKWDButtonEvent *bevent)
+ decor_event *bevent)
{
switch (action) {
case CLICK_ACTION_SHADE:
@@ -4604,8 +4597,8 @@ dist (double x1, double y1,
static void
title_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
static int last_button_num = 0;
static Window last_button_xwindow = None;
@@ -4613,6 +4606,16 @@ title_event (WnckWindow *win,
static int last_button_x = 0;
static int last_button_y = 0;
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
if (gType != GButtonPress)
return;
@@ -4666,8 +4669,8 @@ title_event (WnckWindow *win,
static void
frame_common_event (WnckWindow *win,
int direction,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
if (gType != GButtonPress)
return;
@@ -4690,65 +4693,145 @@ frame_common_event (WnckWindow *win,
static void
top_left_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_TOPLEFT, bevent, gType);
}
static void
top_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_TOP, bevent, gType);
}
static void
top_right_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_TOPRIGHT, bevent, gType);
}
static void
left_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_LEFT, bevent, gType);
}
static void
right_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_RIGHT, bevent, gType);
}
static void
bottom_left_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMLEFT, bevent, gType);
}
static void
bottom_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOM, bevent, gType);
}
static void
bottom_right_event (WnckWindow *win,
- GTKWDButtonEvent *bevent,
- GTKWDEventType gType)
+ decor_event *bevent,
+ decor_event_type gType)
{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->frame_window)
+ {
+ GdkCursor* cursor;
+ cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ gdk_window_set_cursor (d->frame_window, cursor);
+ gdk_cursor_unref (cursor);
+ }
+
frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMRIGHT, bevent, gType);
}
@@ -4846,8 +4929,8 @@ frame_handle_button_press (GtkWidget *widget,
if (d->decorated)
{
- GTKWDButtonEvent bevent;
- GTKWDEventType gType;
+ decor_event bevent;
+ decor_event_type gType;
gType = GButtonPress;
@@ -4948,8 +5031,8 @@ frame_handle_button_release (GtkWidget *widget,
if (d->decorated)
{
- GTKWDButtonEvent bevent;
- GTKWDEventType gType;
+ decor_event bevent;
+ decor_event_type gType;
gType = GButtonRelease;
@@ -5020,11 +5103,8 @@ frame_handle_motion (GtkWidget *widget,
{
found = TRUE;
- //fprintf (stderr, "pointer is in %i\n", i);
-
if (d->last_pos_entered != &(d->button_window_pos[i]))
{
- //printf (stderr, "newly entered area\n");
send_enter = TRUE;
if (d->last_pos_entered)
{
@@ -5046,9 +5126,6 @@ frame_handle_motion (GtkWidget *widget,
{
for (j = 0; j < 3; j++)
{
-
- //fprintf (stderr, "event is %f %f pos is %i %i %i %i\n", event->x_root, event->y_root, d->event_window_pos[i][j].x1, d->event_window_pos[i][j].x2, d->event_window_pos[i][j].y1, d->event_window_pos[i][j].y2);
-
if (event->x >= d->event_window_pos[i][j].x1 &&
event->x <= d->event_window_pos[i][j].x2 &&
event->y >= d->event_window_pos[i][j].y1 &&
@@ -5056,12 +5133,9 @@ frame_handle_motion (GtkWidget *widget,
{
found = TRUE;
event_area = TRUE;
-
- //fprintf (stderr, "pointer is in %i\n", i);
if (d->last_pos_entered != &(d->event_window_pos[i][j]))
{
- //fprintf (stderr, "newly entered area\n");
send_enter = TRUE;
if (d->last_pos_entered)
{
@@ -5084,8 +5158,8 @@ frame_handle_motion (GtkWidget *widget,
{
if (d->decorated)
{
- GTKWDButtonEvent bevent;
- GTKWDEventType gType;
+ decor_event bevent;
+ decor_event_type gType;
bevent.window = GDK_WINDOW_XID (d->frame_window);
bevent.x = event->x;
@@ -5098,10 +5172,6 @@ frame_handle_motion (GtkWidget *widget,
{
gType = GEnterNotify;
- //fprintf (stderr, "sending enter notify\n");
-
- //fprintf (stderr, "i and j are %i %i\n", i, j);
-
if (event_area)
(*callback[i][j]) (d->win, &bevent, gType);
else
@@ -5117,8 +5187,6 @@ frame_handle_motion (GtkWidget *widget,
gType = GLeaveNotify;
- //fprintf (stderr, "sending leave notify\n");
-
for (k = 0; k < 3; k++)
{
if (d->last_pos_entered == &(d->button_window_pos[k]))
@@ -5177,8 +5245,8 @@ frame_handle_motion (GtkWidget *widget,
* and set it to NULL
*/
- GTKWDButtonEvent bevent;
- GTKWDEventType gType;
+ decor_event bevent;
+ decor_event_type gType;
bevent.window = GDK_WINDOW_XID (d->frame_window);
bevent.x = event->x;
@@ -5362,10 +5430,8 @@ add_frame_window (WnckWindow *win,
if (d->created)
{
- fprintf (stderr, "we are already created\n");
if ((mode && d->frame_window) || (!mode && !d->frame_window))
{
- fprintf (stderr, "returning\n");
return;
}
}
@@ -5379,8 +5445,6 @@ add_frame_window (WnckWindow *win,
attr.override_redirect = TRUE;
gdk_error_trap_push ();
-
- fprintf (stderr, "mode is %i\n", mode);
if (mode)
{
@@ -5777,29 +5841,27 @@ remove_frame_window (WnckWindow *win)
if (d->frame_window)
{
- gdk_window_destroy (d->frame_window);
+ //gdk_window_destroy (d->frame_window);
d->frame_window = NULL;
}
if (d->decor_image)
{
- g_object_unref (d->decor_window);
+ //g_object_unref (d->decor_image);
d->decor_image = NULL;
}
if (d->decor_event_box)
{
- g_object_unref (d->decor_event_box);
+ //g_object_unref (d->decor_event_box);
d->decor_event_box = NULL;
}
if (d->decor_window)
{
- g_object_unref (d->decor_window);
+ //g_object_unref (d->decor_window);
d->decor_window = NULL;
- }
-
-
+ }
d->width = 0;
d->height = 0;
@@ -5871,11 +5933,6 @@ window_opened (WnckScreen *screen,
d->picture = None;
connect_window (win);
-
- fprintf (stderr, "made a windopw\n");
-
- if (d->pixmap)
- fprintf (stderr, "after connnection, d->pixmap exists\n");
g_object_set_data (G_OBJECT (win), "decor", d);
@@ -6310,8 +6367,8 @@ event_filter_func (GdkXEvent *gdkxevent,
if (d->decorated)
{
gint i, j;
- GTKWDButtonEvent bevent;
- GTKWDEventType gType;
+ decor_event bevent;
+ decor_event_type gType;
bevent.window = xevent->xany.window;
@@ -6649,9 +6706,6 @@ draw_border_shape (Display *xdisplay,
else
colormap = gdk_screen_get_rgb_colormap (screen);
- fprintf (stderr, "depths for colormap are %i %i\n", gdk_drawable_get_depth (GDK_DRAWABLE (d.pixmap)),
- colormap->visual->depth);
-
gdk_drawable_set_colormap (d.pixmap, colormap);
/* create shadow from opaque decoration */
@@ -8163,7 +8217,6 @@ main (int argc, char *argv[])
xformat24 = XRenderFindStandardFormat (xdisplay, PictStandardRGB24);
frame_table = g_hash_table_new (NULL, NULL);
- //rame_window_table = g_hash_table_new (NULL, NULL);
if (!create_tooltip_window ())
{
diff --git a/window-decorator/gtk-window-decorator.c~ b/window-decorator/gtk-window-decorator.c~
index 393fe95..ff3a542 100644
--- a/window-decorator/gtk-window-decorator.c~
+++ b/window-decorator/gtk-window-decorator.c~
@@ -242,9 +242,9 @@ static double decoration_alpha = 0.5;
#define SWITCHER_SPACE 40
static decor_extents_t _shadow_extents = { 0, 0, 0, 0 };
-static decor_extents_t _win_extents = { 6, 6, 4, 6 };
+static decor_extents_t _win_extents = { 6, 6, 6, 6 };
static decor_extents_t _max_win_extents = { 6, 6, 4, 6 };
-static decor_extents_t _default_win_extents = { 6, 6, 4, 6 };
+static decor_extents_t _default_win_extents = { 6, 6, 6, 6 };
static decor_extents_t _switcher_extents = { 6, 6, 6, 6 + SWITCHER_SPACE };
static int titlebar_height = 17;
@@ -381,12 +381,19 @@ typedef struct _decor_color {
#define PRESSED_EVENT_WINDOW (1 << 1)
typedef struct _decor {
+ WnckWindow *win;
Window event_windows[3][3];
Window button_windows[BUTTON_NUM];
+ Box event_window_pos[3][3];
+ Box button_window_pos[BUTTON_NUM];
+ Box *last_pos_entered;
guint button_states[BUTTON_NUM];
GdkPixmap *pixmap;
GdkPixmap *buffer_pixmap;
GdkWindow *frame_window;
+ GtkWidget *decor_window;
+ GtkWidget *decor_event_box;
+ GtkWidget *decor_image;
GdkGC *gc;
decor_layout_t border_layout;
decor_context_t *context;
@@ -408,9 +415,28 @@ typedef struct _decor {
WnckWindowActions actions;
XID prop_xid;
GtkWidget *force_quit_dialog;
+ Bool created;
void (*draw) (struct _decor *d);
} decor_t;
+typedef struct _GTKWDButtonEvent {
+ guint time;
+ guint window;
+ guint x;
+ guint y;
+ guint x_root;
+ guint y_root;
+ guint button;
+} GTKWDButtonEvent;
+
+typedef enum _GTKWDEventType {
+ GButtonPress = 1,
+ GButtonRelease,
+ GEnterNotify,
+ GLeaveNotify,
+ GMotionNotify
+} GTKWDEventType;
+
void (*theme_draw_window_decoration) (decor_t *d);
gboolean (*theme_calc_decoration_size) (decor_t *d,
int client_width,
@@ -437,14 +463,16 @@ gboolean (*theme_get_button_position) (decor_t *d,
gint *w,
gint *h);
-typedef void (*event_callback) (WnckWindow *win, XEvent *event);
+typedef void (*event_callback) (WnckWindow *win, GTKWDButtonEvent *bevent, GTKWDEventType gType);
static char *program_name;
-static GtkWidget *style_window;
+static GtkWidget *style_window32;
+static GtkWidget *style_window24;
static GtkWidget *switcher_label;
static GHashTable *frame_table;
+static GHashTable *frame_window_table;
static GtkWidget *action_menu = NULL;
static gboolean action_menu_mapped = FALSE;
static decor_color_t _title_color[2];
@@ -475,7 +503,8 @@ static gint switcher_width;
static gint switcher_height;
static Window switcher_selected_window = None;
-static XRenderPictFormat *xformat;
+static XRenderPictFormat *xformat32;
+static XRenderPictFormat *xformat24;
static void
decor_update_blur_property (decor_t *d,
@@ -653,9 +682,6 @@ create_gdk_window (Window xframe)
GdkWindow *window = gdk_window_foreign_new (xframe);
GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
GdkColormap *cmap = gdk_screen_get_rgb_colormap (screen);
-
- fprintf (stderr, "Creating window %i %i\n", cmap->visual->depth,
- gdk_drawable_get_depth (GDK_DRAWABLE (window)));
gdk_drawable_set_colormap (GDK_DRAWABLE (window), cmap);
return window;
@@ -669,7 +695,7 @@ create_pixmap (int w,
if (w == 0 || h ==0)
abort ();
- return gdk_pixmap_new (GDK_DRAWABLE (style_window->window), w, h, depth);
+ return gdk_pixmap_new (GDK_DRAWABLE (style_window32->window), w, h, depth);
}
#define CORNER_TOPLEFT (1 << 0)
@@ -946,44 +972,6 @@ button_state_paint (cairo_t *cr,
}
}
-/* Cut and paste from GDK */
-static GdkGC *
-get_bg_gc (GdkWindow *window, int x_offset, int y_offset)
-{
- GdkWindowObject *private = (GdkWindowObject *)window;
- guint gc_mask = 0;
- GdkGCValues gc_values;
-
- if (private->bg_pixmap == GDK_PARENT_RELATIVE_BG && private->parent)
- {
- return get_bg_gc (GDK_WINDOW (private->parent),
- x_offset + private->x,
- y_offset + private->y);
- }
- else if (private->bg_pixmap &&
- private->bg_pixmap != GDK_PARENT_RELATIVE_BG &&
- private->bg_pixmap != GDK_NO_BG)
- {
- gc_values.fill = GDK_TILED;
- gc_values.tile = private->bg_pixmap;
- gc_values.ts_x_origin = x_offset;
- gc_values.ts_y_origin = y_offset;
-
- gc_mask = GDK_GC_FILL | GDK_GC_TILE | GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN;
-
- return gdk_gc_new_with_values (window, &gc_values, gc_mask);
- }
- else
- {
- GdkGC *gc = gdk_gc_new (window);
-
- gdk_gc_set_foreground (gc, &(private->bg_color));
-
- return gc;
- }
-}
-
-
static void
draw_window_decoration (decor_t *d)
{
@@ -1000,7 +988,7 @@ draw_window_decoration (decor_t *d)
if (!d->pixmap)
return;
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY |
@@ -1021,9 +1009,6 @@ draw_window_decoration (decor_t *d)
else
cmap = gdk_screen_get_rgb_colormap (screen);
- fprintf (stderr, "setting colormap %i %i\n", cmap->visual->depth,
- gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)));
-
gdk_drawable_set_colormap (GDK_DRAWABLE (d->pixmap), cmap);
gdk_drawable_set_colormap (GDK_DRAWABLE (d->buffer_pixmap), cmap);
@@ -1035,6 +1020,9 @@ draw_window_decoration (decor_t *d)
drawable = GDK_DRAWABLE (d->pixmap);
cr = gdk_cairo_create (GDK_DRAWABLE (drawable));
+
+ if (!cr)
+ return;
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
@@ -1044,8 +1032,6 @@ draw_window_decoration (decor_t *d)
y1 = d->context->top_space - _win_extents.top - titlebar_height;
x2 = d->width - d->context->right_space + _win_extents.right;
y2 = d->height - d->context->bottom_space + _win_extents.bottom;
-
- fprintf (stderr, "x1 %f x2 %f y1 %f y2 %f\n", x1, x2, y1, y2);
h = d->height - d->context->top_space - d->context->bottom_space;
@@ -1209,10 +1195,7 @@ draw_window_decoration (decor_t *d)
(CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT |
CORNER_BOTTOMRIGHT) & corners);
- if (!d->frame_window)
- cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.4);
- else
- cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
+ cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.4);
cairo_stroke (cr);
@@ -1225,10 +1208,7 @@ draw_window_decoration (decor_t *d)
(CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT |
CORNER_BOTTOMRIGHT) & corners);
- if (!d->frame_window)
- cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.1);
- else
- cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
+ cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.1);
cairo_stroke (cr);
@@ -1243,12 +1223,9 @@ draw_window_decoration (decor_t *d)
(CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT |
CORNER_BOTTOMRIGHT) & corners);
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- alpha);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ alpha);
cairo_stroke (cr);
@@ -1273,12 +1250,9 @@ draw_window_decoration (decor_t *d)
}
else
{
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- alpha * 0.75);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ alpha * 0.75);
cairo_move_to (cr, x, y);
draw_close_button (d, cr, 3.0);
@@ -1298,12 +1272,9 @@ draw_window_decoration (decor_t *d)
if (d->active)
{
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- STROKE_ALPHA);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ STROKE_ALPHA);
cairo_move_to (cr, x, y);
@@ -1318,12 +1289,9 @@ draw_window_decoration (decor_t *d)
}
else
{
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- alpha * 0.75);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ alpha * 0.75);
cairo_move_to (cr, x, y);
@@ -1347,12 +1315,9 @@ draw_window_decoration (decor_t *d)
if (d->active)
{
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- STROKE_ALPHA);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ STROKE_ALPHA);
cairo_move_to (cr, x, y);
@@ -1362,12 +1327,9 @@ draw_window_decoration (decor_t *d)
}
else
{
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- alpha * 0.75);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ alpha * 0.75);
cairo_move_to (cr, x, y);
draw_min_button (d, cr, 4.0);
@@ -1383,12 +1345,9 @@ draw_window_decoration (decor_t *d)
d->context->left_space + 21.0,
y1 + 2.0 + (titlebar_height - text_height) / 2.0);
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- STROKE_ALPHA);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ STROKE_ALPHA);
pango_cairo_layout_path (cr, d->layout);
cairo_stroke (cr);
@@ -1397,12 +1356,9 @@ draw_window_decoration (decor_t *d)
}
else
{
- if (!d->frame_window)
- gdk_cairo_set_source_color_alpha (cr,
- &style->fg[GTK_STATE_NORMAL],
- alpha);
- else
- gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color_alpha (cr,
+ &style->fg[GTK_STATE_NORMAL],
+ alpha);
}
cairo_move_to (cr,
@@ -1414,14 +1370,13 @@ draw_window_decoration (decor_t *d)
if (d->icon)
{
- fprintf (stderr, "drawing icon\n");
cairo_translate (cr, d->context->left_space + 1,
y1 - 5.0 + titlebar_height / 2);
cairo_set_source (cr, d->icon);
cairo_rectangle (cr, 0.0, 0.0, 16.0, 16.0);
cairo_clip (cr);
- if (d->active || d->frame_window)
+ if (d->active)
cairo_paint (cr);
else
cairo_paint_with_alpha (cr, alpha);
@@ -1442,68 +1397,8 @@ draw_window_decoration (decor_t *d)
if (d->frame_window)
{
- //Pixmap pix = gdk_x11_drawable_get_id (d->pixmap);,
- //XGCValues gcv;
- //Window winner = GDK_WINDOW_XID (d->frame_window);
-
- //gcv.foreground = BlackPixelOfScreen (GDK_SCREEN (gdk_display_get_default_screen (gdk_display_get_default ())));
-
- //GC wingc = XCreateGC (GDK_DISPLAY (),
- // GDK_SCREEN (gdk_display_get_default_screen (gdk_display_get_default ())),
- // GCForeground, &gcv));
-
- //XDrawRectangle (GDK_DISPLAY (gdk_display_get_default ()), winner, wingc, 0, 0, d->width, d->height);
- gdk_window_set_back_pixmap (d->frame_window, d->pixmap, FALSE);
- //gdk_window_clear (d->frame_window);
- //GdkPixmap *gpixmaptest;
- //GError *error = NULL;
- //char buf_p[256];
- //char buf_w[256];
- //char buf_tp[256];
- //file_inc++;
- //sprintf (buf_p, "/home/smspillaz/test%i.png", file_inc);
- //sprintf (buf_w, "/home/smspillaz/test_w%i.png", file_inc);
- //cairo_surface_t *png = cairo_image_surface_create_from_png ("/home/smspillaz/test.png");
- //GdkPixbuf *pixbufImg = gdk_pixbuf_get_from_drawable (NULL, d->pixmap, NULL, 0, 0, 0, 0, d->width, d->height);
-
- //gdk_pixbuf_save (pixbufImg, buf_p, "png", &error, NULL);
- //error = NULL;
- //Pixmap pix;
- //Pixmap mask_return;
- //int alpha_threshold;
- //gdk_pixbuf_xlib_render_pixmap_and_mask (pixbufImg,
- // &pix,
- // &mask_return,
- // 1.0);
- //sprintf (buf_tp, "/home/smspillaz/test%i.png", file_inc);
- //gpixmaptest = gdk_pixmap_foreign_new_for_display (gdk_display_get_default (),
- // pix);
- //pixbufImg = gdk_pixbuf_get_from_drawable (NULL, gpixmaptest, NULL, 0, 0, 0, 0, d->width, d->height);
- //gdk_pixbuf_save (pixbufImg, buf_tp, "png", &error, NULL);
- //error = NULL;
- //
- //pixbufImg = gdk_pixbuf_get_from_drawable (NULL, d->frame_window, NULL, 0, 0, 0, 0, d->width, d->height);
- //gdk_pixbuf_save (pixbufImg, buf_w, "png", &error, NULL);
- //gdk_draw_pixbuf (GDK_DRAWABLE (d->frame_window),
- // NULL,
- // pixbufImg,
- // 0, 0,
- // 0, 0,
- // d->width,
- // d->height,
- // GDK_RGB_DITHER_NONE,
- // 0,
- // 0);
- //pixbufImg = gdk_pixbuf_get_from_drawable (NULL, d->frame_window, NULL, 0, 0, 0, 0, d->width, d->height);
- //gdk_pixbuf_save (pixbufImg, buf_w, "png", &error, NULL);
- //fprintf (stderr, "drawed deco\n");
- //XClearWindow (xdisplay, GDK_WINDOW_XID (d->frame_window));
-
- //GdkGC *gc = get_bg_gc (d->frame_window, 0, 0);
-
- //gdk_window_set_back_pixmap (d->frame_window, d->pixmap, FALSE);
-
-
+ gtk_image_set_from_pixmap (GTK_IMAGE (d->decor_image), d->pixmap, NULL);
+ gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height);
}
if (d->prop_xid)
@@ -2050,6 +1945,7 @@ meta_draw_window_decoration (decor_t *d)
gboolean shade_alpha = (d->active) ? meta_active_shade_opacity :
meta_shade_opacity;
MetaFrameStyle *frame_style;
+ GtkWidget *style_window;
GdkColor bg_color;
double bg_alpha;
@@ -2066,9 +1962,6 @@ meta_draw_window_decoration (decor_t *d)
else
cmap = gdk_screen_get_rgb_colormap (screen);
- fprintf (stderr, "setting colormap %i %i\n", cmap->visual->depth,
- gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)));
-
gdk_drawable_set_colormap (GDK_DRAWABLE (d->pixmap), cmap);
gdk_drawable_set_colormap (GDK_DRAWABLE (d->buffer_pixmap), cmap);
}
@@ -2076,7 +1969,16 @@ meta_draw_window_decoration (decor_t *d)
if (decoration_alpha == 1.0)
alpha = 1.0;
- style = gtk_widget_get_style (style_window);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32)
+ {
+ style = gtk_widget_get_style (style_window32);
+ style_window = style_window32;
+ }
+ else
+ {
+ style = gtk_widget_get_style (style_window24);
+ style_window = style_window24;
+ }
drawable = d->buffer_pixmap ? d->buffer_pixmap : d->pixmap;
@@ -2126,7 +2028,19 @@ meta_draw_window_decoration (decor_t *d)
if (rect.width && size)
{
if (d->frame_window)
+ {
pixmap = create_pixmap (rect.width, size, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
+
+ GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
+ GdkColormap *cmap;
+
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32)
+ cmap = gdk_screen_get_rgba_colormap (screen);
+ else
+ cmap = gdk_screen_get_rgb_colormap (screen);
+
+ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap);
+ }
else
pixmap = create_pixmap (rect.width, size, 32);
@@ -2134,9 +2048,15 @@ meta_draw_window_decoration (decor_t *d)
gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- src = XRenderCreatePicture (xdisplay,
- GDK_PIXMAP_XID (pixmap),
- xformat, 0, NULL);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (pixmap)) == 32 ||
+ !d->frame_window)
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat32, 0, NULL);
+ else
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat24, 0, NULL);
if (fgeom.top_height)
{
@@ -2231,17 +2151,35 @@ meta_draw_window_decoration (decor_t *d)
if (size && rect.height)
{
if (d->frame_window)
- pixmap = create_pixmap (size, rect.height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
+ {
+ pixmap = create_pixmap (rect.width, size, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
+
+ GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
+ GdkColormap *cmap;
+
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->pixmap)) == 32)
+ cmap = gdk_screen_get_rgba_colormap (screen);
+ else
+ cmap = gdk_screen_get_rgb_colormap (screen);
+
+ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), cmap);
+ }
else
- pixmap = create_pixmap (size, rect.height, 32);
+ pixmap = create_pixmap (rect.width, size, 32);
cr = gdk_cairo_create (GDK_DRAWABLE (pixmap));
gdk_cairo_set_source_color_alpha (cr, &bg_color, bg_alpha);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- src = XRenderCreatePicture (xdisplay,
- GDK_PIXMAP_XID (pixmap),
- xformat, 0, NULL);
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (pixmap)) == 32 ||
+ !d->frame_window)
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat32, 0, NULL);
+ else
+ src = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (pixmap),
+ xformat24, 0, NULL);
if (fgeom.left_width)
{
@@ -2342,15 +2280,10 @@ meta_draw_window_decoration (decor_t *d)
d->height);
if (d->frame_window)
- gdk_draw_drawable (d->frame_window,
- d->gc,
- d->pixmap,
- 0,
- 0,
- 0,
- 0,
- -1,
- -1);
+ {
+ gtk_image_set_from_pixmap (GTK_IMAGE (d->decor_image), d->pixmap, NULL);
+ gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height);
+ }
if (d->prop_xid)
{
@@ -2405,7 +2338,7 @@ decor_update_switcher_property (decor_t *d)
&_switcher_extents, &_switcher_extents,
0, 0, quads, nQuad);
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
fgColor[0] = style->fg[GTK_STATE_NORMAL].red;
fgColor[1] = style->fg[GTK_STATE_NORMAL].green;
@@ -2440,7 +2373,7 @@ draw_switcher_background (decor_t *d)
if (!d->buffer_pixmap)
return;
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
color.r = style->bg[GTK_STATE_NORMAL].red / 65535.0;
color.g = style->bg[GTK_STATE_NORMAL].green / 65535.0;
@@ -2639,7 +2572,7 @@ draw_switcher_foreground (decor_t *d)
if (!d->pixmap || !d->buffer_pixmap)
return;
- style = gtk_widget_get_style (style_window);
+ style = gtk_widget_get_style (style_window32);
cr = gdk_cairo_create (GDK_DRAWABLE (d->buffer_pixmap));
@@ -2720,13 +2653,6 @@ draw_decor_list (void *data)
static void
queue_decor_draw (decor_t *d)
{
- if (d->frame_window)
- {
- (*d->draw) (d);
- gdk_window_clear (d->frame_window);
- return;
- }
-
if (g_slist_find (draw_list, d))
return;
@@ -2736,6 +2662,13 @@ queue_decor_draw (decor_t *d)
draw_idle_id = g_idle_add (draw_decor_list, NULL);
}
+/*static void
+queue_add_frame_window (WnckWindow *win,
+ Window frame,
+ Bool mode)
+{
+ if (g_s
+*/
static GdkPixmap *
pixmap_new_from_pixbuf (GdkPixbuf *pixbuf, Bool alpha)
{
@@ -2854,7 +2787,7 @@ update_default_decorations (GdkScreen *screen)
d.active = FALSE;
d.picture = XRenderCreatePicture (xdisplay,
GDK_PIXMAP_XID (d.pixmap),
- xformat, 0, NULL);
+ xformat32, 0, NULL);
(*d.draw) (&d);
@@ -2881,7 +2814,7 @@ update_default_decorations (GdkScreen *screen)
d.active = TRUE;
d.picture = XRenderCreatePicture (xdisplay,
GDK_PIXMAP_XID (d.pixmap),
- xformat, 0, NULL);
+ xformat32, 0, NULL);
(*d.draw) (&d);
@@ -3307,6 +3240,8 @@ meta_get_button_position (decor_t *d,
#endif
+ // TODO: put region handlers here
+
static void
update_event_windows (WnckWindow *win)
{
@@ -3360,13 +3295,20 @@ update_event_windows (WnckWindow *win)
(*theme_get_event_window_position) (d, i, j, width, height,
&x, &y, &w, &h);
- if (w != 0 && h != 0)
+ if (d->frame_window)
+ {
+ d->event_window_pos[i][j].x1 = x;
+ d->event_window_pos[i][j].x2 = x + w;
+ d->event_window_pos[i][j].y1 = y;
+ d->event_window_pos[i][j].y2 = y + h;
+ }
+ else if (!d->frame_window && w != 0 && h != 0)
{
XMapWindow (xdisplay, d->event_windows[i][j]);
XMoveResizeWindow (xdisplay, d->event_windows[i][j],
x, y, w, h);
}
- else
+ else if (!d->frame_window)
{
XUnmapWindow (xdisplay, d->event_windows[i][j]);
}
@@ -3402,18 +3344,36 @@ update_event_windows (WnckWindow *win)
};
- if (button_actions[i] && !(actions & button_actions[i]))
+ if (d->frame_window &&
+ button_actions[i] && !(actions & button_actions[i]))
+ {
+ d->button_window_pos[i].x1 = 0;
+ d->button_window_pos[i].y1 = 0;
+ d->button_window_pos[i].x2 = 0;
+ d->button_window_pos[i].y2 = 0;
+ }
+ else if (!d->frame_window &&
+ button_actions[i] && !(actions & button_actions[i]))
{
XUnmapWindow (xdisplay, d->button_windows[i]);
continue;
}
- if ((*theme_get_button_position) (d, i, width, height, &x, &y, &w, &h))
+ if (d->frame_window &&
+ (*theme_get_button_position) (d, i, width, height, &x, &y, &w, &h))
+ {
+ d->button_window_pos[i].x1 = x;
+ d->button_window_pos[i].y1 = y;
+ d->button_window_pos[i].x2 = x + w;
+ d->button_window_pos[i].y2 = y + h;
+ }
+ else if (!d->frame_window &&
+ (*theme_get_button_position) (d, i, width, height, &x, &y, &w, &h))
{
XMapWindow (xdisplay, d->button_windows[i]);
XMoveResizeWindow (xdisplay, d->button_windows[i], x, y, w, h);
}
- else
+ else if (!d->frame_window)
{
XUnmapWindow (xdisplay, d->button_windows[i]);
}
@@ -3653,9 +3613,6 @@ calc_decoration_size (decor_t *d,
decor_get_default_layout (&window_context, top_width, 1, &layout);
- //if (d->context)
- // fprintf (stderr, "d->context is non null\n");
-
if (TRUE)
{
*width = d->client_width + _win_extents.left + _win_extents.right + 2;
@@ -3665,8 +3622,6 @@ calc_decoration_size (decor_t *d,
d->context = &window_context;
d->shadow = border_shadow;
- //fprintf (stderr, "calculated width and height are %i %i\n", *width, *height);
-
return TRUE;
}
}
@@ -3783,336 +3738,64 @@ update_window_decoration_size (WnckWindow *win)
gint w, h, name_width;
gint x, y;
Display *xdisplay;
+
+ if (d->pixmap)
+ fprintf (stderr, "pixmap exists\n");
xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
wnck_window_get_client_window_geometry (win, &x, &y, &w, &h);
name_width = max_window_name_width (win);
-
- //fprintf (stderr, "got update size\n");
if (!(*theme_calc_decoration_size) (d, w, h, name_width, &width, &height))
{
update_window_decoration_name (win);
- //fprintf (stderr, "returning because calc_deco_size returned false\n");
return FALSE;
}
+ gdk_error_trap_push ();
+
+
if (d->frame_window)
pixmap = create_pixmap (width, height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
else
pixmap = create_pixmap (width, height, 32);
- if (!pixmap)
- {
- //fprintf (stderr, "returning because pixmap is null\n");
- return FALSE;
- }
-
- if (d->frame_window)
- buffer_pixmap = create_pixmap (width, height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
- else
- buffer_pixmap = create_pixmap (width, height, 32);
+ gdk_flush ();
- if (!buffer_pixmap)
+ if (!pixmap || gdk_error_trap_pop ())
{
- //fprintf (stderr, "returning because no buffer pixmap\n");
- g_object_unref (G_OBJECT (pixmap));
+ memset (pixmap, 0, sizeof (pixmap));
return FALSE;
}
- picture = XRenderCreatePicture (xdisplay, GDK_PIXMAP_XID (buffer_pixmap),
- xformat, 0, NULL);
-
- if (d->pixmap)
- g_object_unref (G_OBJECT (d->pixmap));
-
- if (d->buffer_pixmap)
- g_object_unref (G_OBJECT (d->buffer_pixmap));
-
- if (d->gc)
- g_object_unref (G_OBJECT (d->gc));
-
- if (d->picture)
- XRenderFreePicture (xdisplay, d->picture);
-
- d->pixmap = pixmap;
- d->buffer_pixmap = buffer_pixmap;
- d->gc = gdk_gc_new (pixmap);
-
- d->picture = picture;
-
- d->width = width;
- d->height = height;
-
- d->prop_xid = wnck_window_get_xid (win);
-
- if (d->frame_window && width != 0 && height != 0)
- {
- //fprintf (stderr, "adjusting size\n");
- //fprintf (stderr, "win, %i %i %i %i\n", x, y, w, h);
- //fprintf (stderr, "new size is %i %i %i %i\n", x, y - height * 2 , width, height);
- //gdk_window_show (d->frame_window);
- //gdk_window_move_resize (d->frame_window,
- //x, y - height * 2, width, height);
- }
- else if (d->frame_window)
- {
- gdk_window_hide (d->frame_window);
- }
-
- update_window_decoration_name (win);
-
- queue_decor_draw (d);
-
- return TRUE;
-}
-
-static void
-add_frame_window (WnckWindow *win,
- Window frame,
- Bool mode)
-{
- Display *xdisplay;
- XSetWindowAttributes attr;
- gulong xid = wnck_window_get_xid (win);
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
- gint i, j;
-
- xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
- d->active = wnck_window_is_active (win);
-
- attr.event_mask = ButtonPressMask | EnterWindowMask | LeaveWindowMask |
- ExposureMask;
- attr.override_redirect = TRUE;
-
gdk_error_trap_push ();
- for (i = 0; i < 3; i++)
- {
- for (j = 0; j < 3; j++)
- {
- d->event_windows[i][j] =
- XCreateWindow (xdisplay,
- frame,
- 0, 0, 1, 1, 0,
- CopyFromParent, CopyFromParent, CopyFromParent,
- CWOverrideRedirect | CWEventMask, &attr);
-
- if (cursor[i][j].cursor)
- XDefineCursor (xdisplay, d->event_windows[i][j],
- cursor[i][j].cursor);
- }
- }
-
- attr.event_mask |= ButtonReleaseMask;
-
- for (i = 0; i < BUTTON_NUM; i++)
- {
- d->button_windows[i] =
- XCreateWindow (xdisplay,
- frame,
- 0, 0, 1, 1, 0,
- CopyFromParent, CopyFromParent, CopyFromParent,
- CWOverrideRedirect | CWEventMask, &attr);
-
- d->button_states[i] = 0;
- }
-
- /* 2D Mode is on */
-
- fprintf (stderr, "2D Mode?\n");
-
- if (mode == TRUE)
- {
- //d->pixmap = create_pixmap (d->width, d->height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
- printf ("d->width is %i d->height is %i\n", d->client_width, d->client_height);
- fprintf (stderr, "window id is %i\n", frame);
- d->frame_window = create_gdk_window (frame);
- attr.event_mask |= ExposureMask;
- XChangeWindowAttributes (xdisplay, frame, CWEventMask, &attr);
- g_object_set_data (G_OBJECT (d->frame_window), "client_wnck_window", win);
- }
- else
- {
- //d->pixmap = create_pixmap (d->width, d->height, 32);
- d->frame_window = NULL;
- }
-
- gdk_display_sync (gdk_display_get_default ());
- if (!gdk_error_trap_pop ())
- {
- if (get_mwm_prop (xid) & (MWM_DECOR_ALL | MWM_DECOR_TITLE))
- d->decorated = TRUE;
-
- for (i = 0; i < 3; i++)
- for (j = 0; j < 3; j++)
- g_hash_table_insert (frame_table,
- GINT_TO_POINTER (d->event_windows[i][j]),
- GINT_TO_POINTER (xid));
-
- for (i = 0; i < BUTTON_NUM; i++)
- g_hash_table_insert (frame_table,
- GINT_TO_POINTER (d->button_windows[i]),
- GINT_TO_POINTER (xid));
-
- update_window_decoration_state (win);
- update_window_decoration_actions (win);
- update_window_decoration_icon (win);
- update_window_decoration_size (win);
-
- update_event_windows (win);
- }
+ if (d->frame_window)
+ buffer_pixmap = create_pixmap (width, height, gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)));
else
- {
- memset (d->event_windows, 0, sizeof (d->event_windows));
- }
-}
-
-static gboolean
-update_switcher_window (WnckWindow *win,
- Window selected)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
- GdkPixmap *pixmap, *buffer_pixmap = NULL;
- gint height, width = 0;
- WnckWindow *selected_win;
- Display *xdisplay;
-
- xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
- wnck_window_get_client_window_geometry (win, NULL, NULL, &width, NULL);
-
- decor_get_default_layout (&switcher_context, width, 1, &d->border_layout);
-
- width = d->border_layout.width;
- height = d->border_layout.height;
-
- d->decorated = FALSE;
- d->draw = draw_switcher_decoration;
-
- if (!d->pixmap && switcher_pixmap)
- {
- g_object_ref (G_OBJECT (switcher_pixmap));
- d->pixmap = switcher_pixmap;
- }
-
- if (!d->buffer_pixmap && switcher_buffer_pixmap)
- {
- g_object_ref (G_OBJECT (switcher_buffer_pixmap));
- d->buffer_pixmap = switcher_buffer_pixmap;
- }
-
- if (!d->width)
- d->width = switcher_width;
-
- if (!d->height)
- d->height = switcher_height;
-
- selected_win = wnck_window_get (selected);
- if (selected_win)
- {
- glong name_length;
- PangoLayoutLine *line;
- const gchar *name;
-
- if (d->name)
- {
- g_free (d->name);
- d->name = NULL;
- }
-
- name = wnck_window_get_name (selected_win);
- if (name && (name_length = strlen (name)))
- {
- if (!d->layout)
- {
- d->layout = pango_layout_new (pango_context);
- if (d->layout)
- pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR);
- }
-
- if (d->layout)
- {
- int tw;
-
- tw = width - switcher_context.left_space -
- switcher_context.right_space - 64;
- pango_layout_set_auto_dir (d->layout, FALSE);
- pango_layout_set_width (d->layout, tw * PANGO_SCALE);
- pango_layout_set_text (d->layout, name, name_length);
-
- line = pango_layout_get_line (d->layout, 0);
-
- name_length = line->length;
- if (pango_layout_get_line_count (d->layout) > 1)
- {
- if (name_length < 4)
- {
- g_object_unref (G_OBJECT (d->layout));
- d->layout = NULL;
- }
- else
- {
- d->name = g_strndup (name, name_length);
- strcpy (d->name + name_length - 3, "...");
- }
- }
- else
- d->name = g_strndup (name, name_length);
-
- if (d->layout)
- pango_layout_set_text (d->layout, d->name, name_length);
- }
- }
- else if (d->layout)
- {
- g_object_unref (G_OBJECT (d->layout));
- d->layout = NULL;
- }
- }
-
- if (selected != switcher_selected_window)
- {
- gtk_label_set_text (GTK_LABEL (switcher_label), "");
- if (selected_win && d->name)
- gtk_label_set_text (GTK_LABEL (switcher_label), d->name);
- switcher_selected_window = selected;
- }
-
- if (width == d->width && height == d->height)
- {
- if (!d->gc)
- d->gc = gdk_gc_new (d->pixmap);
-
- if (!d->picture)
- d->picture =
- XRenderCreatePicture (xdisplay,
- GDK_PIXMAP_XID (d->buffer_pixmap),
- xformat, 0, NULL);
-
- queue_decor_draw (d);
- return FALSE;
- }
+ buffer_pixmap = create_pixmap (width, height, 32);
- pixmap = create_pixmap (width, height, 32);
- if (!pixmap)
- return FALSE;
+ gdk_flush ();
- buffer_pixmap = create_pixmap (width, height, 32);
- if (!buffer_pixmap)
+ if (!buffer_pixmap || gdk_error_trap_pop ())
{
+ memset (buffer_pixmap, 0, sizeof (buffer_pixmap));
g_object_unref (G_OBJECT (pixmap));
return FALSE;
}
- if (switcher_pixmap)
- g_object_unref (G_OBJECT (switcher_pixmap));
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (buffer_pixmap)) == 32 ||
+ !d->frame_window)
+ picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat32, 0, NULL);
+ else
+ picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat24, 0, NULL);
- if (switcher_buffer_pixmap)
- g_object_unref (G_OBJECT (switcher_buffer_pixmap));
if (d->pixmap)
g_object_unref (G_OBJECT (d->pixmap));
@@ -4126,339 +3809,29 @@ update_switcher_window (WnckWindow *win,
if (d->picture)
XRenderFreePicture (xdisplay, d->picture);
- switcher_pixmap = pixmap;
- switcher_buffer_pixmap = buffer_pixmap;
-
- switcher_width = width;
- switcher_height = height;
-
- g_object_ref (G_OBJECT (pixmap));
- g_object_ref (G_OBJECT (buffer_pixmap));
d->pixmap = pixmap;
d->buffer_pixmap = buffer_pixmap;
d->gc = gdk_gc_new (pixmap);
- d->picture = XRenderCreatePicture (xdisplay, GDK_PIXMAP_XID (buffer_pixmap),
- xformat, 0, NULL);
+ d->picture = picture;
d->width = width;
d->height = height;
d->prop_xid = wnck_window_get_xid (win);
+ update_window_decoration_name (win);
+
queue_decor_draw (d);
return TRUE;
}
static void
-remove_frame_window (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
- Display *xdisplay;
-
- xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-
- if (d->pixmap)
- {
- g_object_unref (G_OBJECT (d->pixmap));
- d->pixmap = NULL;
- }
-
- if (d->buffer_pixmap)
- {
- g_object_unref (G_OBJECT (d->buffer_pixmap));
- d->buffer_pixmap = NULL;
- }
-
- if (d->gc)
- {
- g_object_unref (G_OBJECT (d->gc));
- d->gc = NULL;
- }
-
- if (d->picture && !d->frame_window)
- {
- XRenderFreePicture (xdisplay, d->picture);
- d->picture = 0;
- }
-
- if (d->name)
- {
- g_free (d->name);
- d->name = NULL;
- }
-
- if (d->layout)
- {
- g_object_unref (G_OBJECT (d->layout));
- d->layout = NULL;
- }
-
- if (d->icon)
- {
- cairo_pattern_destroy (d->icon);
- d->icon = NULL;
- }
-
- if (d->icon_pixmap)
- {
- g_object_unref (G_OBJECT (d->icon_pixmap));
- d->icon_pixmap = NULL;
- }
-
- if (d->icon_pixbuf)
- {
- g_object_unref (G_OBJECT (d->icon_pixbuf));
- d->icon_pixbuf = NULL;
- }
-
- if (d->force_quit_dialog)
- {
- GtkWidget *dialog = d->force_quit_dialog;
-
- d->force_quit_dialog = NULL;
- gtk_widget_destroy (dialog);
- }
-
- if (d->frame_window)
- {
- g_object_unref (G_OBJECT (d->frame_window));
- gdk_window_destroy (d->frame_window);
- d->frame_window = NULL;
- }
-
- d->width = 0;
- d->height = 0;
-
- d->decorated = FALSE;
-
- d->state = 0;
- d->actions = 0;
-
- d->context = NULL;
- d->shadow = NULL;
-
- draw_list = g_slist_remove (draw_list, d);
-}
-
-static void
-window_name_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- if (!update_window_decoration_size (win))
- queue_decor_draw (d);
- }
-}
-
-static void
-window_geometry_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- int width, height;
-
- wnck_window_get_client_window_geometry (win, NULL, NULL, &width,
- &height);
-
- if (width != d->client_width || height != d->client_height)
- {
- d->client_width = width;
- d->client_height = height;
-
- update_window_decoration_size (win);
- update_event_windows (win);
-
- //if (!d->frame_window)
- //queue_decor_draw (d);
- }
- }
-}
-
-static void
-window_icon_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- update_window_decoration_icon (win);
- queue_decor_draw (d);
- }
-}
-
-static void
-window_state_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- update_window_decoration_state (win);
- if (!update_window_decoration_size (win))
- queue_decor_draw (d);
-
- update_event_windows (win);
- }
-}
-
-static void
-window_actions_changed (WnckWindow *win)
-{
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- if (d->decorated)
- {
- update_window_decoration_actions (win);
- if (!update_window_decoration_size (win))
- queue_decor_draw (d);
-
- update_event_windows (win);
- }
-}
-
-static void
-connect_window (WnckWindow *win)
-{
- g_signal_connect_object (win, "name_changed",
- G_CALLBACK (window_name_changed),
- 0, 0);
- g_signal_connect_object (win, "geometry_changed",
- G_CALLBACK (window_geometry_changed),
- 0, 0);
- g_signal_connect_object (win, "icon_changed",
- G_CALLBACK (window_icon_changed),
- 0, 0);
- g_signal_connect_object (win, "state_changed",
- G_CALLBACK (window_state_changed),
- 0, 0);
- g_signal_connect_object (win, "actions_changed",
- G_CALLBACK (window_actions_changed),
- 0, 0);
-}
-
-static void
-active_window_changed (WnckScreen *screen)
-{
- WnckWindow *win;
- decor_t *d;
-
- win = wnck_screen_get_previously_active_window (screen);
- if (win)
- {
- d = g_object_get_data (G_OBJECT (win), "decor");
- if (d && d->pixmap)
- {
- d->active = wnck_window_is_active (win);
- queue_decor_draw (d);
- }
- }
-
- win = wnck_screen_get_active_window (screen);
- if (win)
- {
- d = g_object_get_data (G_OBJECT (win), "decor");
- if (d && d->pixmap)
- {
- d->active = wnck_window_is_active (win);
- queue_decor_draw (d);
- }
- }
-}
-
-static void
-window_opened (WnckScreen *screen,
- WnckWindow *win)
-{
- decor_t *d;
- Window window;
- gulong xid;
-
- d = calloc (1, sizeof (decor_t));
- if (!d)
- return;
-
- wnck_window_get_client_window_geometry (win, NULL, NULL,
- &d->client_width,
- &d->client_height);
-
- d->draw = theme_draw_window_decoration;
-
- g_object_set_data (G_OBJECT (win), "decor", d);
-
- connect_window (win);
-
- xid = wnck_window_get_xid (win);
-
- fprintf (stderr, "add_frame_window called\n");
-
- if (get_window_prop (xid, select_window_atom, &window))
- {
- d->prop_xid = wnck_window_get_xid (win);
- update_switcher_window (win, window);
- }
- else if (get_window_prop (xid, frame_input_window_atom, &window))
- {
- add_frame_window (win, window, FALSE);
- }
- else if (get_window_prop (xid, frame_output_window_atom, &window))
- {
- add_frame_window (win, window, TRUE);
- }
-}
-
-static void
-window_closed (WnckScreen *screen,
- WnckWindow *win)
-{
- Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
-
- remove_frame_window (win);
-
- g_object_set_data (G_OBJECT (win), "decor", NULL);
-
- gdk_error_trap_push ();
- XDeleteProperty (xdisplay, wnck_window_get_xid (win), win_decor_atom);
- gdk_display_sync (gdk_display_get_default ());
- gdk_error_trap_pop ();
-
- g_free (d);
-}
-
-static void
-connect_screen (WnckScreen *screen)
-{
- GList *windows;
-
- g_signal_connect_object (G_OBJECT (screen), "active_window_changed",
- G_CALLBACK (active_window_changed),
- 0, 0);
- g_signal_connect_object (G_OBJECT (screen), "window_opened",
- G_CALLBACK (window_opened),
- 0, 0);
- g_signal_connect_object (G_OBJECT (screen), "window_closed",
- G_CALLBACK (window_closed),
- 0, 0);
-
- windows = wnck_screen_get_windows (screen);
- while (windows != NULL)
- {
- window_opened (screen, windows->data);
- windows = windows->next;
- }
-}
-
-static void
move_resize_window (WnckWindow *win,
int direction,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent)
{
Display *xdisplay;
GdkDisplay *gdkdisplay;
@@ -4489,14 +3862,14 @@ move_resize_window (WnckWindow *win,
ev.xclient.message_type = wm_move_resize_atom;
ev.xclient.format = 32;
- ev.xclient.data.l[0] = xevent->xbutton.x_root;
- ev.xclient.data.l[1] = xevent->xbutton.y_root;
+ ev.xclient.data.l[0] = bevent->x_root;
+ ev.xclient.data.l[1] = bevent->y_root;
ev.xclient.data.l[2] = direction;
- ev.xclient.data.l[3] = xevent->xbutton.button;
+ ev.xclient.data.l[3] = bevent->button;
ev.xclient.data.l[4] = 1;
- XUngrabPointer (xdisplay, xevent->xbutton.time);
- XUngrabKeyboard (xdisplay, xevent->xbutton.time);
+ XUngrabPointer (xdisplay, bevent->time);
+ XUngrabKeyboard (xdisplay, bevent->time);
XSendEvent (xdisplay, xroot, FALSE,
SubstructureRedirectMask | SubstructureNotifyMask,
@@ -4708,32 +4081,36 @@ create_tooltip_window (void)
static void
handle_tooltip_event (WnckWindow *win,
- XEvent *xevent,
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType,
guint state,
const char *tip)
{
- switch (xevent->type) {
- case ButtonPress:
+ switch (gType) {
+ case GButtonPress:
hide_tooltip ();
break;
- case ButtonRelease:
+ case GButtonRelease:
break;
- case EnterNotify:
+ case GEnterNotify:
if (!(state & PRESSED_EVENT_WINDOW))
{
if (wnck_window_is_active (win))
tooltip_start_delay (tip);
}
break;
- case LeaveNotify:
+ case GLeaveNotify:
hide_tooltip ();
break;
+ default:
+ break;
}
}
static void
common_button_event (WnckWindow *win,
- XEvent *xevent,
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType,
int button,
int max,
char *tooltip)
@@ -4741,79 +4118,92 @@ common_button_event (WnckWindow *win,
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[button];
- handle_tooltip_event (win, xevent, state, tooltip);
+ handle_tooltip_event (win, bevent, gType, state, tooltip);
- switch (xevent->type) {
- case ButtonPress:
- if (xevent->xbutton.button <= max)
+ switch (gType) {
+ case GButtonPress:
+ if (bevent->button <= max)
d->button_states[button] |= PRESSED_EVENT_WINDOW;
break;
- case ButtonRelease:
- if (xevent->xbutton.button <= max)
+ case GButtonRelease:
+ if (bevent->button <= max)
d->button_states[button] &= ~PRESSED_EVENT_WINDOW;
break;
- case EnterNotify:
+ case GEnterNotify:
+ //fprintf (stderr, "I haz enter notify\n");
d->button_states[button] |= IN_EVENT_WINDOW;
break;
- case LeaveNotify:
+ case GLeaveNotify:
+ //fprintf (stderr, "I haz leave notify\n");
d->button_states[button] &= ~IN_EVENT_WINDOW;
break;
+ default:
+ break;
}
if (state != d->button_states[button])
+ {
queue_decor_draw (d);
+ }
}
#define BUTTON_EVENT_ACTION_STATE (PRESSED_EVENT_WINDOW | IN_EVENT_WINDOW)
static void
close_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_CLOSE];
- common_button_event (win, xevent, BUTTON_CLOSE, 1, _("Close Window"));
+ common_button_event (win, bevent, gType,
+ BUTTON_CLOSE, 1, _("Close Window"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
- wnck_window_close (win, xevent->xbutton.time);
+ {
+ wnck_window_close (win, bevent->time);
+ }
}
break;
+ default:
+ break;
}
}
static void
max_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_MAX];
if (wnck_window_is_maximized (win))
- common_button_event (win, xevent, BUTTON_MAX,
+ common_button_event (win, bevent, gType, BUTTON_MAX,
3, _("Unmaximize Window"));
else
- common_button_event (win, xevent, BUTTON_MAX,
+ common_button_event (win, bevent, gType, BUTTON_MAX,
3, _("Maximize Window"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button <= 3)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button <= 3)
{
if (state == BUTTON_EVENT_ACTION_STATE)
{
- if (xevent->xbutton.button == 2)
+ if (bevent->button == 2)
{
if (wnck_window_is_maximized_vertically (win))
wnck_window_unmaximize_vertically (win);
else
wnck_window_maximize_vertically (win);
}
- else if (xevent->xbutton.button == 3)
+ else if (bevent->button == 3)
{
if (wnck_window_is_maximized_horizontally (win))
wnck_window_unmaximize_horizontally (win);
@@ -4830,26 +4220,32 @@ max_button_event (WnckWindow *win,
}
}
break;
+ default:
+ break;
}
}
static void
min_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_MIN];
- common_button_event (win, xevent, BUTTON_MIN, 1, _("Minimize Window"));
+ common_button_event (win, bevent, gType,
+ BUTTON_MIN, 1, _("Minimize Window"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
wnck_window_minimize (win);
}
break;
+ default:
+ break;
}
}
@@ -4963,52 +4359,62 @@ action_menu_map (WnckWindow *win,
static void
menu_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- common_button_event (win, xevent, BUTTON_MENU, 1, _("Window Menu"));
+ common_button_event (win, bevent, gType,
+ BUTTON_MENU, 1, _("Window Menu"));
- switch (xevent->type) {
- case ButtonPress:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonPress:
+ if (bevent->button == 1)
action_menu_map (win,
- xevent->xbutton.button,
- xevent->xbutton.time);
+ bevent->button,
+ bevent->time);
+ break;
+ default:
break;
}
}
static void
shade_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_SHADE];
- common_button_event (win, xevent, BUTTON_SHADE, 1, _("Shade"));
+ common_button_event (win, bevent, gType,
+ BUTTON_SHADE, 1, _("Shade"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
wnck_window_shade (win);
}
break;
+ default:
+ break;
}
}
static void
above_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_ABOVE];
- common_button_event (win, xevent, BUTTON_ABOVE, 1, _("Make Above"));
+ common_button_event (win, bevent, gType,
+ BUTTON_ABOVE, 1, _("Make Above"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
{
@@ -5020,61 +4426,73 @@ above_button_event (WnckWindow *win,
}
}
break;
+ default:
+ break;
}
}
static void
stick_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_STICK];
- common_button_event (win, xevent, BUTTON_STICK, 1, _("Stick"));
+ common_button_event (win, bevent, gType,
+ BUTTON_STICK, 1, _("Stick"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
wnck_window_stick (win);
}
break;
+ default:
+ break;
}
}
static void
unshade_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_UNSHADE];
- common_button_event (win, xevent, BUTTON_UNSHADE, 1, _("Unshade"));
+ common_button_event (win, bevent, gType,
+ BUTTON_UNSHADE, 1, _("Unshade"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
wnck_window_unshade (win);
}
break;
+ default:
+ break;
}
}
static void
unabove_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_UNABOVE];
- common_button_event (win, xevent, BUTTON_UNABOVE, 1, _("Unmake Above"));
+ common_button_event (win, bevent, gType,
+ BUTTON_UNABOVE, 1, _("Unmake Above"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
{
@@ -5086,33 +4504,39 @@ unabove_button_event (WnckWindow *win,
}
}
break;
+ default:
+ break;
}
}
static void
unstick_button_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[BUTTON_UNSTICK];
- common_button_event (win, xevent, BUTTON_UNSTICK, 1, _("Unstick"));
+ common_button_event (win, bevent, gType,
+ BUTTON_UNSTICK, 1, _("Unstick"));
- switch (xevent->type) {
- case ButtonRelease:
- if (xevent->xbutton.button == 1)
+ switch (gType) {
+ case GButtonRelease:
+ if (bevent->button == 1)
{
if (state == BUTTON_EVENT_ACTION_STATE)
wnck_window_unstick (win);
}
break;
+ default:
+ break;
}
}
static void
handle_title_button_event (WnckWindow *win,
int action,
- XButtonEvent *event)
+ GTKWDButtonEvent *bevent)
{
switch (action) {
case CLICK_ACTION_SHADE:
@@ -5138,7 +4562,7 @@ handle_title_button_event (WnckWindow *win,
restack_window (win, Below);
break;
case CLICK_ACTION_MENU:
- action_menu_map (win, event->button, event->time);
+ action_menu_map (win, bevent->button, bevent->time);
break;
}
}
@@ -5180,7 +4604,8 @@ dist (double x1, double y1,
static void
title_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
static int last_button_num = 0;
static Window last_button_xwindow = None;
@@ -5188,19 +4613,19 @@ title_event (WnckWindow *win,
static int last_button_x = 0;
static int last_button_y = 0;
- if (xevent->type != ButtonPress)
+ if (gType != GButtonPress)
return;
- if (xevent->xbutton.button == 1)
+ if (bevent->button == 1)
{
- if (xevent->xbutton.button == last_button_num &&
- xevent->xbutton.window == last_button_xwindow &&
- xevent->xbutton.time < last_button_time + double_click_timeout &&
- dist (xevent->xbutton.x, xevent->xbutton.y,
+ if (bevent->button == last_button_num &&
+ bevent->window == last_button_xwindow &&
+ bevent->time < last_button_time + double_click_timeout &&
+ dist (bevent->x, bevent->y,
last_button_x, last_button_y) < DOUBLE_CLICK_DISTANCE)
{
handle_title_button_event (win, double_click_action,
- &xevent->xbutton);
+ bevent);
last_button_num = 0;
last_button_xwindow = None;
@@ -5210,115 +4635,1312 @@ title_event (WnckWindow *win,
}
else
{
- last_button_num = xevent->xbutton.button;
- last_button_xwindow = xevent->xbutton.window;
- last_button_time = xevent->xbutton.time;
- last_button_x = xevent->xbutton.x;
- last_button_y = xevent->xbutton.y;
+ last_button_num = bevent->button;
+ last_button_xwindow = bevent->window;
+ last_button_time = bevent->time;
+ last_button_x = bevent->x;
+ last_button_y = bevent->y;
restack_window (win, Above);
- move_resize_window (win, WM_MOVERESIZE_MOVE, xevent);
+ move_resize_window (win, WM_MOVERESIZE_MOVE, bevent);
}
}
- else if (xevent->xbutton.button == 2)
+ else if (bevent->button == 2)
{
handle_title_button_event (win, middle_click_action,
- &xevent->xbutton);
+ bevent);
}
- else if (xevent->xbutton.button == 3)
+ else if (bevent->button == 3)
{
handle_title_button_event (win, right_click_action,
- &xevent->xbutton);
+ bevent);
}
- else if (xevent->xbutton.button == 4 ||
- xevent->xbutton.button == 5)
+ else if (bevent->button == 4 ||
+ bevent->button == 5)
{
- handle_mouse_wheel_title_event (win, xevent->xbutton.button);
+ handle_mouse_wheel_title_event (win, bevent->button);
}
}
static void
frame_common_event (WnckWindow *win,
int direction,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- if (xevent->type != ButtonPress)
+ if (gType != GButtonPress)
return;
- switch (xevent->xbutton.button) {
+ switch (bevent->button) {
case 1:
- move_resize_window (win, direction, xevent);
+ move_resize_window (win, direction, bevent);
restack_window (win, Above);
break;
case 2:
handle_title_button_event (win, middle_click_action,
- &xevent->xbutton);
+ bevent);
break;
case 3:
handle_title_button_event (win, right_click_action,
- &xevent->xbutton);
+ bevent);
break;
}
}
static void
top_left_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_TOPLEFT, xevent);
+ frame_common_event (win, WM_MOVERESIZE_SIZE_TOPLEFT, bevent, gType);
}
static void
top_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_TOP, xevent);
+ frame_common_event (win, WM_MOVERESIZE_SIZE_TOP, bevent, gType);
}
static void
top_right_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_TOPRIGHT, xevent);
+ frame_common_event (win, WM_MOVERESIZE_SIZE_TOPRIGHT, bevent, gType);
}
static void
left_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_LEFT, xevent);
+ frame_common_event (win, WM_MOVERESIZE_SIZE_LEFT, bevent, gType);
}
static void
right_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_RIGHT, xevent);
+ frame_common_event (win, WM_MOVERESIZE_SIZE_RIGHT, bevent, gType);
}
static void
bottom_left_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMLEFT, xevent);
+ frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMLEFT, bevent, gType);
}
static void
bottom_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOM, xevent);
+ frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOM, bevent, gType);
}
static void
bottom_right_event (WnckWindow *win,
- XEvent *xevent)
+ GTKWDButtonEvent *bevent,
+ GTKWDEventType gType)
+{
+ frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMRIGHT, bevent, gType);
+}
+
+void
+frame_window_realized (GtkWidget *widget,
+ gpointer data)
+{
+ decor_t *d = (decor_t *) data;
+
+ if (d)
+ {
+ GdkWindow *gdk_frame_window = gtk_widget_get_window (d->decor_window);
+ gdk_window_reparent (gdk_frame_window, d->frame_window, 0, 0);
+ gdk_window_lower (gdk_frame_window);
+
+ }
+}
+
+static void
+frame_handle_button_press (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ decor_t *d = (decor_t *) user_data;
+
+ if (d)
+ {
+ /* Check to see where the event happened and fill out an appropriate
+ * struct
+ */
+
+ int i, j;
+ Bool found = FALSE;
+ Bool event_area = FALSE;
+ Bool exit = FALSE;
+
+ for (i = 0; i < BUTTON_NUM; i++)
+ {
+ /* Hit */
+ if (event->x >= d->button_window_pos[i].x1 &&
+ event->x <= d->button_window_pos[i].x2 &&
+ event->y >= d->button_window_pos[i].y1 &&
+ event->y <= d->button_window_pos[i].y2)
+ {
+ found = TRUE;
+
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ if (event->x >= d->event_window_pos[i][j].x1 &&
+ event->x <= d->event_window_pos[i][j].x2 &&
+ event->y >= d->event_window_pos[i][j].y1 &&
+ event->y <= d->event_window_pos[i][j].y2)
+ {
+ found = TRUE;
+ event_area = TRUE;
+
+ exit = TRUE;
+
+ break;
+ }
+ }
+
+ if (exit)
+ break;
+ }
+ }
+
+ if (found)
+ {
+ static event_callback callback[3][3] = {
+ { top_left_event, top_event, top_right_event },
+ { left_event, title_event, right_event },
+ { bottom_left_event, bottom_event, bottom_right_event }
+ };
+ static event_callback button_callback[BUTTON_NUM] = {
+ close_button_event,
+ max_button_event,
+ min_button_event,
+ menu_button_event,
+ shade_button_event,
+ above_button_event,
+ stick_button_event,
+ unshade_button_event,
+ unabove_button_event,
+ unstick_button_event
+ };
+
+ if (d->decorated)
+ {
+ GTKWDButtonEvent bevent;
+ GTKWDEventType gType;
+
+ gType = GButtonPress;
+
+ bevent.window = GDK_WINDOW_XID (d->frame_window);
+ bevent.button = event->button;
+ bevent.x = event->x;
+ bevent.y = event->y;
+ bevent.x_root = event->x_root;
+ bevent.y_root = event->y_root;
+ bevent.time = event->time;
+
+ if (event_area)
+ (*(callback[i][j])) (d->win, &bevent, gType);
+ else
+ (*button_callback[i]) (d->win, &bevent, gType);
+ }
+ }
+ }
+}
+
+static void
+frame_handle_button_release (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer user_data)
+{
+ decor_t *d = (decor_t *) user_data;
+
+ if (d)
+ {
+ /* Check to see where the event happened and fill out an appropriate
+ * struct
+ */
+
+ int i, j;
+ Bool found = FALSE;
+ Bool event_area = FALSE;
+ Bool exit = FALSE;
+
+ for (i = 0; i < BUTTON_NUM; i++)
+ {
+ /* Hit */
+ if (event->x >= d->button_window_pos[i].x1 &&
+ event->x <= d->button_window_pos[i].x2 &&
+ event->y >= d->button_window_pos[i].y1 &&
+ event->y <= d->button_window_pos[i].y2)
+ {
+ found = TRUE;
+
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ if (event->x >= d->event_window_pos[i][j].x1 &&
+ event->x <= d->event_window_pos[i][j].x2 &&
+ event->y >= d->event_window_pos[i][j].y1 &&
+ event->y <= d->event_window_pos[i][j].y2)
+ {
+ found = TRUE;
+ event_area = TRUE;
+
+ exit = TRUE;
+
+ break;
+ }
+ }
+
+ if (exit)
+ break;
+
+ }
+ }
+
+ if (found)
+ {
+ static event_callback callback[3][3] = {
+ { top_left_event, top_event, top_right_event },
+ { left_event, title_event, right_event },
+ { bottom_left_event, bottom_event, bottom_right_event }
+ };
+ static event_callback button_callback[BUTTON_NUM] = {
+ close_button_event,
+ max_button_event,
+ min_button_event,
+ menu_button_event,
+ shade_button_event,
+ above_button_event,
+ stick_button_event,
+ unshade_button_event,
+ unabove_button_event,
+ unstick_button_event
+ };
+
+ if (d->decorated)
+ {
+ GTKWDButtonEvent bevent;
+ GTKWDEventType gType;
+
+ gType = GButtonRelease;
+
+ bevent.window = GDK_WINDOW_XID (d->frame_window);
+ bevent.button = event->button;
+ bevent.x = event->x;
+ bevent.y = event->y;
+ bevent.x_root = event->x_root;
+ bevent.y_root = event->y_root;
+ bevent.time = event->time;
+
+ if (event_area)
+ (*callback[i][j]) (d->win, &bevent, gType);
+ else
+ (*button_callback[i]) (d->win, &bevent, gType);
+ }
+ }
+ }
+}
+
+static void
+frame_handle_motion (GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer user_data)
+{
+ decor_t *d = (decor_t *) user_data;
+
+ static event_callback callback[3][3] = {
+ { top_left_event, top_event, top_right_event },
+ { left_event, title_event, right_event },
+ { bottom_left_event, bottom_event, bottom_right_event }
+ };
+ static event_callback button_callback[BUTTON_NUM] = {
+ close_button_event,
+ max_button_event,
+ min_button_event,
+ menu_button_event,
+ shade_button_event,
+ above_button_event,
+ stick_button_event,
+ unshade_button_event,
+ unabove_button_event,
+ unstick_button_event
+ };
+
+ if (d)
+ {
+ /* Check to see where the event happened and fill out an appropriate
+ * struct
+ */
+
+ int i, j;
+ Bool found = FALSE;
+ Bool event_area = FALSE;
+ Bool send_enter = FALSE;
+ Bool send_leave = FALSE;
+ Bool exit = FALSE;
+
+ /* Check buttons */
+
+ for (i = 0; i < BUTTON_NUM; i++)
+ {
+ /* Hit */
+ if (event->x >= d->button_window_pos[i].x1 &&
+ event->x <= d->button_window_pos[i].x2 &&
+ event->y >= d->button_window_pos[i].y1 &&
+ event->y <= d->button_window_pos[i].y2)
+ {
+ found = TRUE;
+
+ //fprintf (stderr, "pointer is in %i\n", i);
+
+ if (d->last_pos_entered != &(d->button_window_pos[i]))
+ {
+ //printf (stderr, "newly entered area\n");
+ send_enter = TRUE;
+ if (d->last_pos_entered)
+ {
+ send_leave = TRUE;
+ }
+ }
+
+ break;
+ }
+ }
+
+ /* Check event windows */
+
+ exit = FALSE;
+
+ if (!found)
+ {
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+
+ //fprintf (stderr, "event is %f %f pos is %i %i %i %i\n", event->x_root, event->y_root, d->event_window_pos[i][j].x1, d->event_window_pos[i][j].x2, d->event_window_pos[i][j].y1, d->event_window_pos[i][j].y2);
+
+ if (event->x >= d->event_window_pos[i][j].x1 &&
+ event->x <= d->event_window_pos[i][j].x2 &&
+ event->y >= d->event_window_pos[i][j].y1 &&
+ event->y <= d->event_window_pos[i][j].y2)
+ {
+ found = TRUE;
+ event_area = TRUE;
+
+ //fprintf (stderr, "pointer is in %i\n", i);
+
+ if (d->last_pos_entered != &(d->event_window_pos[i][j]))
+ {
+ //fprintf (stderr, "newly entered area\n");
+ send_enter = TRUE;
+ if (d->last_pos_entered)
+ {
+ send_leave = TRUE;
+ }
+ }
+
+ exit = TRUE;
+
+ break;
+ }
+ }
+
+ if (exit)
+ break;
+ }
+ }
+
+ if (found)
+ {
+ if (d->decorated)
+ {
+ GTKWDButtonEvent bevent;
+ GTKWDEventType gType;
+
+ bevent.window = GDK_WINDOW_XID (d->frame_window);
+ bevent.x = event->x;
+ bevent.y = event->y;
+ bevent.x_root = event->x_root;
+ bevent.y_root = event->y_root;
+ bevent.time = event->time;
+
+ if (send_enter)
+ {
+ gType = GEnterNotify;
+
+ //fprintf (stderr, "sending enter notify\n");
+
+ //fprintf (stderr, "i and j are %i %i\n", i, j);
+
+ if (event_area)
+ (*callback[i][j]) (d->win, &bevent, gType);
+ else
+ (*button_callback[i]) (d->win, &bevent, gType);
+
+ }
+
+ if (send_leave)
+ {
+ guint k, l;
+ Bool l_event_area = FALSE;
+ Bool l_found = FALSE;
+
+ gType = GLeaveNotify;
+
+ //fprintf (stderr, "sending leave notify\n");
+
+ for (k = 0; k < 3; k++)
+ {
+ if (d->last_pos_entered == &(d->button_window_pos[k]))
+ {
+ l_found = TRUE;
+ break;
+ }
+ }
+
+ exit = FALSE;
+
+ if (!l_found)
+ {
+ for (k = 0; k < 3; k++)
+ {
+ for (l = 0; l < 3; l++)
+ {
+ if (d->last_pos_entered == &(d->event_window_pos[k][l]))
+ {
+ l_found = TRUE;
+ l_event_area = TRUE;
+
+ exit = TRUE;
+
+ break;
+ }
+
+ if (exit)
+ break;
+ }
+ }
+ }
+
+ if (l_found)
+ {
+ if (l_event_area)
+ (*callback[k][l]) (d->win, &bevent, gType);
+ else
+ (*button_callback[k]) (d->win, &bevent, gType);
+ }
+ }
+
+ if (send_enter)
+ {
+ if (event_area)
+ d->last_pos_entered = &d->button_window_pos[i];
+ else
+ d->last_pos_entered = &d->event_window_pos[i][j];
+ }
+ }
+ }
+ else if (d->last_pos_entered && d->decorated)
+ {
+ /* We are not in an event / button window but last_pos_entered
+ * is still set, so send a GLeaveNotify to last_pos_entered
+ * and set it to NULL
+ */
+
+ GTKWDButtonEvent bevent;
+ GTKWDEventType gType;
+
+ bevent.window = GDK_WINDOW_XID (d->frame_window);
+ bevent.x = event->x;
+ bevent.y = event->y;
+ bevent.x_root = event->x_root;
+ bevent.y_root = event->y_root;
+ bevent.time = event->time;
+
+ guint k, l;
+ Bool l_event_area = FALSE;
+ Bool l_found = FALSE;
+
+ gType = GLeaveNotify;
+
+ for (k = 0; k < 3; k++)
+ {
+ if (d->last_pos_entered == &(d->button_window_pos[k]))
+ {
+ l_found = TRUE;
+ break;
+ }
+ }
+
+ exit = FALSE;
+
+ if (!l_found)
+ {
+ for (k = 0; k < 3; k++)
+ {
+ for (l = 0; l < 3; l++)
+ {
+ if (d->last_pos_entered == &(d->event_window_pos[k][l]))
+ {
+ l_found = TRUE;
+ l_event_area = TRUE;
+
+ exit = TRUE;
+
+ break;
+ }
+
+ if (exit)
+ break;
+ }
+ }
+ }
+
+ if (l_found)
+ {
+ if (l_event_area)
+ (*callback[k][l]) (d->win, &bevent, gType);
+ else
+ (*button_callback[k]) (d->win, &bevent, gType);
+ }
+
+ d->last_pos_entered = NULL;
+ }
+
+ }
+}
+
+static void
+window_name_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ if (!update_window_decoration_size (win))
+ queue_decor_draw (d);
+ }
+}
+
+static void
+window_geometry_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ int width, height;
+
+ wnck_window_get_client_window_geometry (win, NULL, NULL, &width,
+ &height);
+
+ if (width != d->client_width || height != d->client_height)
+ {
+ d->client_width = width;
+ d->client_height = height;
+
+ update_window_decoration_size (win);
+ update_event_windows (win);
+ }
+ }
+}
+
+static void
+window_icon_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ update_window_decoration_icon (win);
+ queue_decor_draw (d);
+ }
+}
+
+static void
+window_state_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ update_window_decoration_state (win);
+ if (!update_window_decoration_size (win))
+ queue_decor_draw (d);
+
+ update_event_windows (win);
+ }
+}
+
+static void
+window_actions_changed (WnckWindow *win)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ if (d->decorated)
+ {
+ update_window_decoration_actions (win);
+ if (!update_window_decoration_size (win))
+ queue_decor_draw (d);
+
+ update_event_windows (win);
+ }
+}
+
+static void
+connect_window (WnckWindow *win)
+{
+ g_signal_connect_object (win, "name_changed",
+ G_CALLBACK (window_name_changed),
+ 0, 0);
+ g_signal_connect_object (win, "geometry_changed",
+ G_CALLBACK (window_geometry_changed),
+ 0, 0);
+ g_signal_connect_object (win, "icon_changed",
+ G_CALLBACK (window_icon_changed),
+ 0, 0);
+ g_signal_connect_object (win, "state_changed",
+ G_CALLBACK (window_state_changed),
+ 0, 0);
+ g_signal_connect_object (win, "actions_changed",
+ G_CALLBACK (window_actions_changed),
+ 0, 0);
+}
+
+static void
+add_frame_window (WnckWindow *win,
+ Window frame,
+ Bool mode)
+{
+ Display *xdisplay;
+ XSetWindowAttributes attr;
+ gulong xid = wnck_window_get_xid (win);
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+ gint i, j;
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+
+ /* If we have already done this, there is no need to do it again, except
+ * if the property changed.
+ *
+ * The reason this check is here is because sometimes the PropertyNotify X
+ * event can come a bit after the property on the window is actually set
+ * which might result in this function being called twice - once by
+ * wnck through window_opened and once through our X event handler
+ * event_filter_func
+ */
+
+ if (d->created)
+ {
+ fprintf (stderr, "we are already created\n");
+ if ((mode && d->frame_window) || (!mode && !d->frame_window))
+ {
+ fprintf (stderr, "returning\n");
+ return;
+ }
+ }
+
+ d->active = wnck_window_is_active (win);
+ d->win = win;
+ d->last_pos_entered = NULL;
+
+ attr.event_mask = ButtonPressMask | EnterWindowMask | LeaveWindowMask |
+ ExposureMask;
+ attr.override_redirect = TRUE;
+
+ gdk_error_trap_push ();
+
+ fprintf (stderr, "mode is %i\n", mode);
+
+ if (mode)
+ {
+ GdkScreen *screen = gdk_display_get_default_screen (gdk_display_get_default ());
+ GdkColormap *colormap;
+
+ d->frame_window = create_gdk_window (frame);
+ d->decor_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)) == 24)
+ colormap = gdk_screen_get_rgb_colormap (screen);
+ else if (gdk_drawable_get_depth (GDK_DRAWABLE (d->frame_window)) == 32)
+ colormap = gdk_screen_get_rgba_colormap (screen);
+
+ gtk_widget_set_colormap (d->decor_window, colormap);
+
+ d->decor_image = gtk_image_new ();
+
+ gtk_widget_set_colormap (d->decor_image, colormap);
+
+ d->decor_event_box = gtk_event_box_new ();
+ gtk_event_box_set_visible_window (GTK_EVENT_BOX (d->decor_event_box), FALSE);
+ gtk_widget_set_events (d->decor_event_box, GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK);
+
+ g_signal_connect (G_OBJECT (d->decor_event_box), "button-press-event",
+ G_CALLBACK (frame_handle_button_press),
+ (gpointer) (d));
+
+ g_signal_connect (G_OBJECT (d->decor_event_box), "button-release-event",
+ G_CALLBACK (frame_handle_button_release),
+ (gpointer) (d));
+
+ g_signal_connect (G_OBJECT (d->decor_event_box), "motion-notify-event",
+ G_CALLBACK (frame_handle_motion),
+ (gpointer) (d));
+
+ gtk_container_add (GTK_CONTAINER (d->decor_event_box), d->decor_image);
+ gtk_event_box_set_above_child (GTK_EVENT_BOX (d->decor_event_box), TRUE);
+ gtk_widget_show_all (d->decor_event_box);
+ gtk_window_set_decorated (GTK_WINDOW (d->decor_window), FALSE);
+ gtk_window_set_default_size (GTK_WINDOW (d->decor_window), 1000, 1000);
+ gtk_container_add (GTK_CONTAINER (d->decor_window), d->decor_event_box);
+
+ /* Assumed realization happens here */
+
+ g_signal_connect (G_OBJECT (d->decor_window), "realize",
+ G_CALLBACK (frame_window_realized), (gpointer) d);
+
+ gtk_widget_show_all (d->decor_window);
+ gtk_widget_show (d->decor_window);
+
+ g_object_set_data (G_OBJECT (d->frame_window), "client_wnck_window", win);
+ }
+ else
+ {
+ d->frame_window = NULL;
+
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ d->event_windows[i][j] =
+ XCreateWindow (xdisplay,
+ frame,
+ 0, 0, 1, 1, 0,
+ CopyFromParent, CopyFromParent, CopyFromParent,
+ CWOverrideRedirect | CWEventMask, &attr);
+
+ if (cursor[i][j].cursor)
+ XDefineCursor (xdisplay, d->event_windows[i][j],
+ cursor[i][j].cursor);
+ }
+ }
+
+ attr.event_mask |= ButtonReleaseMask;
+
+ for (i = 0; i < BUTTON_NUM; i++)
+ {
+ d->button_windows[i] =
+ XCreateWindow (xdisplay,
+ frame,
+ 0, 0, 1, 1, 0,
+ CopyFromParent, CopyFromParent, CopyFromParent,
+ CWOverrideRedirect | CWEventMask, &attr);
+
+ d->button_states[i] = 0;
+ }
+ }
+
+ gdk_display_sync (gdk_display_get_default ());
+ if (!gdk_error_trap_pop ())
+ {
+ if (get_mwm_prop (xid) & (MWM_DECOR_ALL | MWM_DECOR_TITLE))
+ d->decorated = TRUE;
+
+ for (i = 0; i < 3; i++)
+ for (j = 0; j < 3; j++)
+ g_hash_table_insert (frame_table,
+ GINT_TO_POINTER (d->event_windows[i][j]),
+ GINT_TO_POINTER (xid));
+
+ for (i = 0; i < BUTTON_NUM; i++)
+ g_hash_table_insert (frame_table,
+ GINT_TO_POINTER (d->button_windows[i]),
+ GINT_TO_POINTER (xid));
+
+ if (d->frame_window)
+ {
+ g_hash_table_insert (frame_table,
+ GINT_TO_POINTER (frame),
+ GINT_TO_POINTER (xid));
+ }
+ update_window_decoration_state (win);
+ update_window_decoration_actions (win);
+ update_window_decoration_icon (win);
+ update_window_decoration_size (win);
+
+ update_event_windows (win);
+ }
+ else
+ {
+ memset (d->event_windows, 0, sizeof (d->event_windows));
+ }
+
+ d->created = TRUE;
+}
+
+static gboolean
+update_switcher_window (WnckWindow *win,
+ Window selected)
+{
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+ GdkPixmap *pixmap, *buffer_pixmap = NULL;
+ gint height, width = 0;
+ WnckWindow *selected_win;
+ Display *xdisplay;
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+
+ wnck_window_get_client_window_geometry (win, NULL, NULL, &width, NULL);
+
+ decor_get_default_layout (&switcher_context, width, 1, &d->border_layout);
+
+ width = d->border_layout.width;
+ height = d->border_layout.height;
+
+ d->decorated = FALSE;
+ d->draw = draw_switcher_decoration;
+
+ if (!d->pixmap && switcher_pixmap)
+ {
+ g_object_ref (G_OBJECT (switcher_pixmap));
+
+ d->pixmap = switcher_pixmap;
+ }
+
+ if (!d->buffer_pixmap && switcher_buffer_pixmap)
+ {
+ g_object_ref (G_OBJECT (switcher_buffer_pixmap));
+ d->buffer_pixmap = switcher_buffer_pixmap;
+ }
+
+ if (!d->width)
+ d->width = switcher_width;
+
+ if (!d->height)
+ d->height = switcher_height;
+
+ selected_win = wnck_window_get (selected);
+ if (selected_win)
+ {
+ glong name_length;
+ PangoLayoutLine *line;
+ const gchar *name;
+
+ if (d->name)
+ {
+ g_free (d->name);
+ d->name = NULL;
+ }
+
+ name = wnck_window_get_name (selected_win);
+ if (name && (name_length = strlen (name)))
+ {
+ if (!d->layout)
+ {
+ d->layout = pango_layout_new (pango_context);
+ if (d->layout)
+ pango_layout_set_wrap (d->layout, PANGO_WRAP_CHAR);
+ }
+
+ if (d->layout)
+ {
+ int tw;
+
+ tw = width - switcher_context.left_space -
+ switcher_context.right_space - 64;
+ pango_layout_set_auto_dir (d->layout, FALSE);
+ pango_layout_set_width (d->layout, tw * PANGO_SCALE);
+ pango_layout_set_text (d->layout, name, name_length);
+
+ line = pango_layout_get_line (d->layout, 0);
+
+ name_length = line->length;
+ if (pango_layout_get_line_count (d->layout) > 1)
+ {
+ if (name_length < 4)
+ {
+ g_object_unref (G_OBJECT (d->layout));
+ d->layout = NULL;
+ }
+ else
+ {
+ d->name = g_strndup (name, name_length);
+ strcpy (d->name + name_length - 3, "...");
+ }
+ }
+ else
+ d->name = g_strndup (name, name_length);
+
+ if (d->layout)
+ pango_layout_set_text (d->layout, d->name, name_length);
+ }
+ }
+ else if (d->layout)
+ {
+ g_object_unref (G_OBJECT (d->layout));
+ d->layout = NULL;
+ }
+ }
+
+ if (selected != switcher_selected_window)
+ {
+ gtk_label_set_text (GTK_LABEL (switcher_label), "");
+ if (selected_win && d->name)
+ gtk_label_set_text (GTK_LABEL (switcher_label), d->name);
+ switcher_selected_window = selected;
+ }
+
+ if (width == d->width && height == d->height)
+ {
+ if (!d->gc)
+ d->gc = gdk_gc_new (d->pixmap);
+
+ if (!d->picture)
+ {
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->buffer_pixmap)) == 32 ||
+ !d->frame_window)
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat32, 0, NULL);
+ else
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat24, 0, NULL);
+ }
+ queue_decor_draw (d);
+ return FALSE;
+ }
+
+ pixmap = create_pixmap (width, height, 32);
+ if (!pixmap)
+ return FALSE;
+
+ buffer_pixmap = create_pixmap (width, height, 32);
+ if (!buffer_pixmap)
+ {
+ g_object_unref (G_OBJECT (pixmap));
+ return FALSE;
+ }
+
+ if (switcher_pixmap)
+ g_object_unref (G_OBJECT (switcher_pixmap));
+
+ if (switcher_buffer_pixmap)
+ g_object_unref (G_OBJECT (switcher_buffer_pixmap));
+
+ if (d->pixmap)
+ g_object_unref (G_OBJECT (d->pixmap));
+
+ if (d->buffer_pixmap)
+ g_object_unref (G_OBJECT (d->buffer_pixmap));
+
+ if (d->gc)
+ g_object_unref (G_OBJECT (d->gc));
+
+ if (d->picture)
+ XRenderFreePicture (xdisplay, d->picture);
+
+ switcher_pixmap = pixmap;
+ switcher_buffer_pixmap = buffer_pixmap;
+
+ switcher_width = width;
+ switcher_height = height;
+
+ g_object_ref (G_OBJECT (pixmap));
+ g_object_ref (G_OBJECT (buffer_pixmap));
+
+ d->pixmap = pixmap;
+ d->buffer_pixmap = buffer_pixmap;
+ d->gc = gdk_gc_new (pixmap);
+
+ if (gdk_drawable_get_depth (GDK_DRAWABLE (d->buffer_pixmap)) == 32 ||
+ !d->frame_window)
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat32, 0, NULL);
+ else
+ d->picture = XRenderCreatePicture (xdisplay,
+ GDK_PIXMAP_XID (buffer_pixmap),
+ xformat24, 0, NULL);
+
+ d->width = width;
+ d->height = height;
+
+ d->prop_xid = wnck_window_get_xid (win);
+
+ queue_decor_draw (d);
+
+ return TRUE;
+}
+
+static void
+remove_frame_window (WnckWindow *win)
{
- frame_common_event (win, WM_MOVERESIZE_SIZE_BOTTOMRIGHT, xevent);
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+ Display *xdisplay;
+
+ xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+
+ if (d->pixmap)
+ {
+ g_object_unref (G_OBJECT (d->pixmap));
+ d->pixmap = NULL;
+ }
+
+ if (d->buffer_pixmap)
+ {
+ g_object_unref (G_OBJECT (d->buffer_pixmap));
+ d->buffer_pixmap = NULL;
+ }
+
+ if (d->gc)
+ {
+ g_object_unref (G_OBJECT (d->gc));
+ d->gc = NULL;
+ }
+
+ if (d->picture && !d->frame_window)
+ {
+ XRenderFreePicture (xdisplay, d->picture);
+ d->picture = 0;
+ }
+
+ if (d->name)
+ {
+ g_free (d->name);
+ d->name = NULL;
+ }
+
+ if (d->layout)
+ {
+ g_object_unref (G_OBJECT (d->layout));
+ d->layout = NULL;
+ }
+
+ if (d->icon)
+ {
+ cairo_pattern_destroy (d->icon);
+ d->icon = NULL;
+ }
+
+ if (d->icon_pixmap)
+ {
+ g_object_unref (G_OBJECT (d->icon_pixmap));
+ d->icon_pixmap = NULL;
+ }
+
+ if (d->icon_pixbuf)
+ {
+ g_object_unref (G_OBJECT (d->icon_pixbuf));
+ d->icon_pixbuf = NULL;
+ }
+
+ if (d->force_quit_dialog)
+ {
+ GtkWidget *dialog = d->force_quit_dialog;
+
+ d->force_quit_dialog = NULL;
+ gtk_widget_destroy (dialog);
+ }
+
+ if (d->frame_window)
+ {
+ gdk_window_destroy (d->frame_window);
+ d->frame_window = NULL;
+ }
+
+ if (d->decor_image)
+ {
+ g_object_unref (d->decor_window);
+ d->decor_image = NULL;
+ }
+
+ if (d->decor_event_box)
+ {
+ g_object_unref (d->decor_event_box);
+ d->decor_event_box = NULL;
+ }
+
+ if (d->decor_window)
+ {
+ g_object_unref (d->decor_window);
+ d->decor_window = NULL;
+ }
+
+
+
+ d->width = 0;
+ d->height = 0;
+
+ d->decorated = FALSE;
+
+ d->state = 0;
+ d->actions = 0;
+
+ d->context = NULL;
+ d->shadow = NULL;
+
+ draw_list = g_slist_remove (draw_list, d);
}
static void
+active_window_changed (WnckScreen *screen)
+{
+ WnckWindow *win;
+ decor_t *d;
+
+ win = wnck_screen_get_previously_active_window (screen);
+ if (win)
+ {
+ d = g_object_get_data (G_OBJECT (win), "decor");
+ if (d && d->pixmap)
+ {
+ d->active = wnck_window_is_active (win);
+ queue_decor_draw (d);
+ }
+ }
+
+ win = wnck_screen_get_active_window (screen);
+ if (win)
+ {
+ d = g_object_get_data (G_OBJECT (win), "decor");
+ if (d && d->pixmap)
+ {
+ d->active = wnck_window_is_active (win);
+ queue_decor_draw (d);
+ }
+ }
+}
+
+static void
+window_opened (WnckScreen *screen,
+ WnckWindow *win)
+{
+ decor_t *d;
+ Window window;
+ gulong xid;
+
+ d = calloc (1, sizeof (decor_t));
+ if (!d)
+ return;
+
+ wnck_window_get_client_window_geometry (win, NULL, NULL,
+ &d->client_width,
+ &d->client_height);
+
+ d->draw = theme_draw_window_decoration;
+
+ /* Prevent double pixmap freeing */
+
+ d->created = FALSE;
+ d->pixmap = NULL;
+ d->gc = NULL;
+ d->buffer_pixmap = NULL;
+ d->picture = None;
+
+ connect_window (win);
+
+ fprintf (stderr, "made a windopw\n");
+
+ if (d->pixmap)
+ fprintf (stderr, "after connnection, d->pixmap exists\n");
+
+ g_object_set_data (G_OBJECT (win), "decor", d);
+
+ xid = wnck_window_get_xid (win);
+
+ if (get_window_prop (xid, select_window_atom, &window))
+ {
+ d->prop_xid = wnck_window_get_xid (win);
+ update_switcher_window (win, window);
+ }
+ else if (get_window_prop (xid, frame_input_window_atom, &window))
+ {
+ add_frame_window (win, window, FALSE);
+ }
+ else if (get_window_prop (xid, frame_output_window_atom, &window))
+ {
+ add_frame_window (win, window, TRUE);
+ }
+}
+
+static void
+window_closed (WnckScreen *screen,
+ WnckWindow *win)
+{
+ Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
+ decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
+
+ remove_frame_window (win);
+
+ g_object_set_data (G_OBJECT (win), "decor", NULL);
+
+ gdk_error_trap_push ();
+ XDeleteProperty (xdisplay, wnck_window_get_xid (win), win_decor_atom);
+ gdk_display_sync (gdk_display_get_default ());
+ gdk_error_trap_pop ();
+
+ g_free (d);
+}
+
+static void
+connect_screen (WnckScreen *screen)
+{
+ GList *windows;
+
+ g_signal_connect_object (G_OBJECT (screen), "active_window_changed",
+ G_CALLBACK (active_window_changed),
+ 0, 0);
+ g_signal_connect_object (G_OBJECT (screen), "window_opened",
+ G_CALLBACK (window_opened),
+ 0, 0);
+ g_signal_connect_object (G_OBJECT (screen), "window_closed",
+ G_CALLBACK (window_closed),
+ 0, 0);
+
+ windows = wnck_screen_get_windows (screen);
+ while (windows != NULL)
+ {
+ window_opened (screen, windows->data);
+ windows = windows->next;
+ }
+}
+
+
+
+static void
force_quit_dialog_realize (GtkWidget *dialog,
void *data)
{
@@ -5513,26 +6135,6 @@ event_filter_func (GdkXEvent *gdkxevent,
g_hash_table_lookup (frame_table,
GINT_TO_POINTER (xevent->xbutton.window));
break;
- case Expose:
- {
- fprintf (stderr, "got expose %i\n", xevent->xexpose.window);
- GdkWindow *win = gdk_window_lookup (xevent->xexpose.window);
- if (win)
- {
- fprintf (stderr, "found win\n");
- gdk_window_clear (win);
- #if 0
- WnckWindow *wnck_window = g_object_get_data (G_OBJECT (win),
- "client_wnck_window");
-
- if (wnck_window)
- {
- fprintf (stderr, "found wnck_win\n");
- //update_window_decoration_size (wnck_window);
- }
- #endif
- }
- }
case EnterNotify:
case LeaveNotify:
xid = (gulong)
@@ -5640,6 +6242,7 @@ event_filter_func (GdkXEvent *gdkxevent,
case DestroyNotify:
g_hash_table_remove (frame_table,
GINT_TO_POINTER (xevent->xproperty.window));
+ // XXX
break;
case ClientMessage:
if (xevent->xclient.message_type == toolkit_action_atom)
@@ -5707,15 +6310,59 @@ event_filter_func (GdkXEvent *gdkxevent,
if (d->decorated)
{
gint i, j;
+ GTKWDButtonEvent bevent;
+ GTKWDEventType gType;
+
+ bevent.window = xevent->xany.window;
+
+ switch (xevent->type)
+ {
+ case ButtonPress:
+ gType = GButtonPress;
+ bevent.button = xevent->xbutton.button;
+ bevent.x = xevent->xbutton.x;
+ bevent.y = xevent->xbutton.y;
+ bevent.x_root = xevent->xbutton.x_root;
+ bevent.y_root = xevent->xbutton.y_root;
+ bevent.time = xevent->xbutton.time;
+ break;
+ case ButtonRelease:
+ gType = GButtonRelease;
+ bevent.button = xevent->xbutton.button;
+ bevent.x = xevent->xbutton.x;
+ bevent.y = xevent->xbutton.y;
+ bevent.x_root = xevent->xbutton.x_root;
+ bevent.y_root = xevent->xbutton.y_root;
+ bevent.time = xevent->xbutton.time;
+ break;
+ case EnterNotify:
+ gType = GEnterNotify;
+ bevent.x = xevent->xcrossing.x;
+ bevent.y = xevent->xcrossing.y;
+ bevent.x_root = xevent->xcrossing.x_root;
+ bevent.y_root = xevent->xcrossing.y_root;
+ bevent.time = xevent->xcrossing.time;
+ break;
+ case LeaveNotify:
+ gType = GLeaveNotify;
+ bevent.x = xevent->xcrossing.x;
+ bevent.y = xevent->xcrossing.y;
+ bevent.x_root = xevent->xcrossing.x_root;
+ bevent.y_root = xevent->xcrossing.y_root;
+ bevent.time = xevent->xcrossing.time;
+ break;
+ default:
+ break;
+ }
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
if (d->event_windows[i][j] == xevent->xany.window)
- (*callback[i][j]) (win, xevent);
+ (*callback[i][j]) (win, &bevent, gType);
for (i = 0; i < BUTTON_NUM; i++)
if (d->button_windows[i] == xevent->xany.window)
- (*button_callback[i]) (win, xevent);
+ (*button_callback[i]) (win, &bevent, gType);
}
}
}
@@ -7232,34 +7879,63 @@ init_settings (WnckScreen *screen)
}
#endif
- style_window = gtk_window_new (GTK_WINDOW_POPUP);
+ style_window32 = gtk_window_new (GTK_WINDOW_POPUP);
gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ());
colormap = gdk_screen_get_rgba_colormap (gdkscreen);
if (colormap)
- gtk_widget_set_colormap (style_window, colormap);
+ gtk_widget_set_colormap (style_window32, colormap);
- gtk_widget_realize (style_window);
+ gtk_widget_realize (style_window32);
switcher_label = gtk_label_new ("");
switcher_label_obj = gtk_widget_get_accessible (switcher_label);
atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR);
- gtk_container_add (GTK_CONTAINER (style_window), switcher_label);
+ gtk_container_add (GTK_CONTAINER (style_window32), switcher_label);
- gtk_widget_set_size_request (style_window, 0, 0);
- gtk_window_move (GTK_WINDOW (style_window), -100, -100);
- gtk_widget_show_all (style_window);
+ gtk_widget_set_size_request (style_window32, 0, 0);
+ gtk_window_move (GTK_WINDOW (style_window32), -100, -100);
+ gtk_widget_show_all (style_window32);
- g_signal_connect_object (style_window, "style-set",
+ g_signal_connect_object (style_window32, "style-set",
G_CALLBACK (style_changed),
0, 0);
- settings = gtk_widget_get_settings (style_window);
+ settings = gtk_widget_get_settings (style_window32);
g_object_get (G_OBJECT (settings), "gtk-double-click-time",
&double_click_timeout, NULL);
- pango_context = gtk_widget_create_pango_context (style_window);
+ pango_context = gtk_widget_create_pango_context (style_window32);
+
+ style_window24 = gtk_window_new (GTK_WINDOW_POPUP);
+
+ gdkscreen = gdk_display_get_default_screen (gdk_display_get_default ());
+ colormap = gdk_screen_get_rgb_colormap (gdkscreen);
+ if (colormap)
+ gtk_widget_set_colormap (style_window24, colormap);
+
+ gtk_widget_realize (style_window24);
+
+ switcher_label = gtk_label_new ("");
+ switcher_label_obj = gtk_widget_get_accessible (switcher_label);
+ atk_object_set_role (switcher_label_obj, ATK_ROLE_STATUSBAR);
+ gtk_container_add (GTK_CONTAINER (style_window24), switcher_label);
+
+ gtk_widget_set_size_request (style_window24, 0, 0);
+ gtk_window_move (GTK_WINDOW (style_window24), -100, -100);
+ gtk_widget_show_all (style_window24);
+
+ g_signal_connect_object (style_window24, "style-set",
+ G_CALLBACK (style_changed),
+ 0, 0);
+
+ settings = gtk_widget_get_settings (style_window24);
+
+ g_object_get (G_OBJECT (settings), "gtk-double-click-time",
+ &double_click_timeout, NULL);
+
+ pango_context = gtk_widget_create_pango_context (style_window24);
#ifdef USE_GCONF
use_system_font = gconf_client_get_bool (gconf,
@@ -7270,8 +7946,8 @@ init_settings (WnckScreen *screen)
button_layout_changed (gconf);
#endif
- update_style (style_window);
-
+ update_style (style_window32);
+ update_style (style_window24);
#ifdef USE_GCONF
titlebar_font_changed (gconf);
#endif
@@ -7421,8 +8097,6 @@ main (int argc, char *argv[])
}
#endif
- fprintf (stderr, "starting decor\n");
-
gdkdisplay = gdk_display_get_default ();
xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay);
gdkscreen = gdk_display_get_default_screen (gdkdisplay);
@@ -7485,9 +8159,11 @@ main (int argc, char *argv[])
}
}
- xformat = XRenderFindStandardFormat (xdisplay, PictStandardARGB32);
+ xformat32 = XRenderFindStandardFormat (xdisplay, PictStandardARGB32);
+ xformat24 = XRenderFindStandardFormat (xdisplay, PictStandardRGB24);
frame_table = g_hash_table_new (NULL, NULL);
+ //rame_window_table = g_hash_table_new (NULL, NULL);
if (!create_tooltip_window ())
{