Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
解决圆角窗口resize以及最大化的问题。
Browse files Browse the repository at this point in the history
只需要处理configure event即可。此事件在窗口大小,位置,stacking
改变时触发。
  • Loading branch information
kernelhcy committed Jan 24, 2011
1 parent 92dc455 commit 5b0d639
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions src/gui/qqwindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ static gboolean motion_event_cb (GtkWidget *widget, GdkEventMotion *event
, gpointer data);
static gboolean expose_event_cb (GtkWidget *widget, GdkEventExpose *event
, gpointer data);
static gboolean configure_event_cb (GtkWidget *widget, GdkEventConfigure *event
, gpointer data);

static void qq_window_set_shape_mask (QQWindow *qwin);
static void qq_window_remove_shape_mask (QQWindow *qw);
Expand Down Expand Up @@ -101,6 +103,8 @@ void qq_window_init(QQWindow *qwin, gpointer data)
, G_CALLBACK(button_release_event_cb), NULL);
g_signal_connect(widget, "motion-notify-event"
, G_CALLBACK(motion_event_cb), NULL);
g_signal_connect(widget, "configure-event"
, G_CALLBACK(configure_event_cb), NULL);

g_signal_connect(widget, "expose-event"
, G_CALLBACK(expose_event_cb), NULL);
Expand Down Expand Up @@ -159,15 +163,13 @@ gboolean button_press_event_cb(GtkWidget *widget, GdkEventButton *event
return TRUE;
}

//qq_window_remove_shape_mask(QQ_WINDOW(widget));

if(event -> type == GDK_2BUTTON_PRESS){
qq_window_remove_shape_mask(QQ_WINDOW(widget));
if(QQ_WINDOW(widget) -> is_maxsize){
qq_window_unmaximize(QQ_WINDOW(widget));
}else{
qq_window_maximize(QQ_WINDOW(widget));
}
qq_window_set_shape_mask(QQ_WINDOW(widget));
return FALSE;
}

Expand Down Expand Up @@ -230,7 +232,6 @@ gboolean button_press_event_cb(GtkWidget *widget, GdkEventButton *event
gboolean button_release_event_cb(GtkWidget *widget, GdkEventButton *event
, gpointer data)
{
qq_window_set_shape_mask(QQ_WINDOW(widget));
return FALSE;
}
gboolean motion_event_cb(GtkWidget *widget, GdkEventMotion *event
Expand Down Expand Up @@ -273,7 +274,7 @@ gboolean motion_event_cb(GtkWidget *widget, GdkEventMotion *event
if(cur != nc && ! QQ_WINDOW(widget) -> is_maxsize){
gdk_window_set_cursor(widget -> window, cur);
}
qq_window_set_shape_mask(QQ_WINDOW(widget));

return FALSE;
}

Expand Down Expand Up @@ -303,6 +304,15 @@ void qq_window_set_shape_mask(QQWindow *qwin)
gint width, height;
gtk_window_get_size(GTK_WINDOW(qwin), &width, &height);

if(qwin -> pre_w == width
&& qwin -> pre_h == height){
/*
* The shape of the window does change.
* We just do nothing.
*/
return;
}

GdkBitmap *bm = NULL;
gdouble radius = 10;

Expand Down Expand Up @@ -344,10 +354,24 @@ void qq_window_set_shape_mask(QQWindow *qwin)

gtk_widget_shape_combine_mask(GTK_WIDGET(qwin), bm, 0, 0);
gtk_widget_input_shape_combine_mask(GTK_WIDGET(qwin), bm, 0, 0);

qwin -> pre_w = width;
qwin -> pre_h = height;
}

gboolean expose_event_cb(GtkWidget *widget, GdkEventExpose *event
, gpointer data)
{
return FALSE;
}

/*
* The window's size is changed.
* Reset the shape mask.
*/
gboolean configure_event_cb(GtkWidget *widget, GdkEventConfigure *event
, gpointer data)
{
qq_window_set_shape_mask(QQ_WINDOW(widget));
return FALSE;
}

0 comments on commit 5b0d639

Please sign in to comment.