summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Fourdan <fourdan.olivier@wanadoo.fr>2003-03-16 22:46:11 +0000
committerOlivier Fourdan <fourdan.olivier@wanadoo.fr>2003-03-16 22:46:11 +0000
commit5081cbc49205ddb0e6a37fa1295cbb3b7c64036d (patch)
tree768fe1233491583c0ad0c4e39bebec0a0e231a3e
parentdd7cd002b81750e384047e89f921289a8168bb43 (diff)
downloadxfwm4-5081cbc49205ddb0e6a37fa1295cbb3b7c64036d.tar.gz
Apply a modified version of the patch submitted by Jens Guballa <J.Guballa@t-online.de> for toggled buttons.
(Old svn revision: 10990)
-rw-r--r--src/client.c2
-rw-r--r--src/client.h4
-rw-r--r--src/frame.c70
-rw-r--r--src/settings.c15
-rw-r--r--src/settings.h9
-rw-r--r--themes/gtk/Makefile.am9
-rw-r--r--themes/gtk/Makefile.in9
-rw-r--r--themes/microdeck/top-left-active.xpm6
-rw-r--r--themes/microdeck/top-left-inactive.xpm6
-rw-r--r--themes/microdeck/top-right-active.xpm6
-rw-r--r--themes/microdeck/top-right-inactive.xpm6
11 files changed, 100 insertions, 42 deletions
diff --git a/src/client.c b/src/client.c
index 30ce19596..941279658 100644
--- a/src/client.c
+++ b/src/client.c
@@ -4138,7 +4138,6 @@ void clientButtonPress(Client * c, Window w, XButtonEvent * bev)
if(c->button_pressed[b])
{
c->button_pressed[b] = False;
- frameDraw(c, FALSE, FALSE);
switch (b)
{
case HIDE_BUTTON:
@@ -4181,6 +4180,7 @@ void clientButtonPress(Client * c, Window w, XButtonEvent * bev)
clientToggleSticky(c, TRUE);
break;
}
+ frameDraw(c, FALSE, FALSE);
}
}
diff --git a/src/client.h b/src/client.h
index 56a3ceeff..5b68a784d 100644
--- a/src/client.h
+++ b/src/client.h
@@ -68,10 +68,6 @@
#define UPDATE_CACHE (1<<3)
#define UPDATE_ALL (UPDATE_KEYGRABS | UPDATE_FRAME | UPDATE_GRAVITY | UPDATE_CACHE)
-#define ACTIVE 0
-#define INACTIVE 1
-#define PRESSED 2
-
#define MARGIN_LEFT 0
#define MARGIN_RIGHT 1
#define MARGIN_TOP 2
diff --git a/src/frame.c b/src/frame.c
index e6a3e845d..223149d18 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -152,7 +152,7 @@ static inline void fillRectangle(Display * dpy, Drawable d, Pixmap pm, int x, in
XFreeGC(dpy, gc);
}
-static void frameCreateTitlePixmap(Client * c, int state, int left, int right, MyPixmap * pm)
+static inline void frameCreateTitlePixmap(Client * c, int state, int left, int right, MyPixmap * pm)
{
int width, x = 0, tp = 0, w1 = 0, w2, w3, w4, w5, temp;
GdkPixmap *gpixmap = NULL;
@@ -308,7 +308,7 @@ static void frameCreateTitlePixmap(Client * c, int state, int left, int right, M
g_object_unref(G_OBJECT(layout));
}
-static int getButtonFromLetter(char chr, Client * c)
+static inline int getButtonFromLetter(char chr, Client * c)
{
int b = -1;
@@ -358,7 +358,7 @@ static int getButtonFromLetter(char chr, Client * c)
return b;
}
-static char getLetterFromButton(int i, Client * c)
+static inline char getLetterFromButton(int i, Client * c)
{
char chr = 0;
@@ -405,11 +405,44 @@ static char getLetterFromButton(int i, Client * c)
return chr;
}
-static void frameSetShape(Client * c, int state, ClientPixmapCache * pm_cache, int button_x[BUTTON_COUNT])
+static inline MyPixmap *frameGetPixmap(Client * c, int button, int state)
+{
+ switch (button)
+ {
+ case SHADE_BUTTON:
+ if (CLIENT_FLAG_TEST(c, CLIENT_FLAG_SHADED) && params.buttons[SHADE_BUTTON][state + 3].pixmap)
+ {
+ return &params.buttons[SHADE_BUTTON][state + 3];
+ }
+ return &params.buttons[SHADE_BUTTON][state];
+ break;
+ case STICK_BUTTON:
+ if (CLIENT_FLAG_TEST(c, CLIENT_FLAG_STICKY) && params.buttons[STICK_BUTTON][state + 3].pixmap)
+ {
+ return &params.buttons[STICK_BUTTON][state + 3];
+ }
+ return &params.buttons[STICK_BUTTON][state];
+ break;
+ case MAXIMIZE_BUTTON:
+ if (CLIENT_FLAG_TEST(c, CLIENT_FLAG_MAXIMIZED) && params.buttons[MAXIMIZE_BUTTON][state + 3].pixmap)
+ {
+ return &params.buttons[MAXIMIZE_BUTTON][state + 3];
+ }
+ return &params.buttons[MAXIMIZE_BUTTON][state];
+ break;
+ default:
+ break;
+ }
+ return &params.buttons[button][state];
+}
+
+
+static inline void frameSetShape(Client * c, int state, ClientPixmapCache * pm_cache, int button_x[BUTTON_COUNT])
{
Window temp;
int i;
XRectangle rect;
+ MyPixmap * my_pixmap;
DBG("entering frameSetShape\n");
DBG("setting shape for client (0x%lx)\n", c->window);
@@ -449,14 +482,8 @@ static void frameSetShape(Client * c, int state, ClientPixmapCache * pm_cache, i
for(i = 0; i < BUTTON_COUNT; i++)
{
- if(c->button_pressed[i])
- {
- XShapeCombineMask(dpy, MYWINDOW_XWINDOW(c->buttons[i]), ShapeBounding, 0, 0, params.buttons[i][PRESSED].mask, ShapeSet);
- }
- else
- {
- XShapeCombineMask(dpy, MYWINDOW_XWINDOW(c->buttons[i]), ShapeBounding, 0, 0, params.buttons[i][state].mask, ShapeSet);
- }
+ my_pixmap = frameGetPixmap(c, i, c->button_pressed[i] ? PRESSED : state);
+ XShapeCombineMask(dpy, MYWINDOW_XWINDOW(c->buttons[i]), ShapeBounding, 0, 0, my_pixmap->mask, ShapeSet);
}
if(params.corners[CORNER_TOP_LEFT][ACTIVE].height > frameHeight(c) - frameBottom(c) + 1)
@@ -532,6 +559,7 @@ void frameDraw(Client * c, gboolean invalidate_cache, gboolean force_shape_updat
int right_height;
int button_x[BUTTON_COUNT];
gboolean requires_clearing = FALSE;
+ MyPixmap * my_pixmap;
DBG("entering frameDraw\n");
DBG("drawing frame for \"%s\" (0x%lx)\n", c->name, c->window);
@@ -603,13 +631,10 @@ void frameDraw(Client * c, gboolean invalidate_cache, gboolean force_shape_updat
}
else if(button >= 0)
{
- if((c->button_pressed[button]) && (params.buttons[button][PRESSED].pixmap))
- {
- XSetWindowBackgroundPixmap(dpy, MYWINDOW_XWINDOW(c->buttons[button]), params.buttons[button][PRESSED].pixmap);
- }
- else if(params.buttons[button][state].pixmap)
+ my_pixmap = frameGetPixmap(c, button, c->button_pressed[button] ? PRESSED : state);
+ if(my_pixmap->pixmap)
{
- XSetWindowBackgroundPixmap(dpy, MYWINDOW_XWINDOW(c->buttons[button]), params.buttons[button][state].pixmap);
+ XSetWindowBackgroundPixmap(dpy, MYWINDOW_XWINDOW(c->buttons[button]), my_pixmap->pixmap);
}
myWindowShow(&c->buttons[button], x, (frameTop(c) - params.buttons[button][ACTIVE].height) / 2, params.buttons[button][ACTIVE].width, params.buttons[button][ACTIVE].height, TRUE);
button_x[button] = x;
@@ -629,13 +654,10 @@ void frameDraw(Client * c, gboolean invalidate_cache, gboolean force_shape_updat
}
else if(button >= 0)
{
- if((c->button_pressed[button]) && (params.buttons[button][PRESSED].pixmap))
- {
- XSetWindowBackgroundPixmap(dpy, MYWINDOW_XWINDOW(c->buttons[button]), params.buttons[button][PRESSED].pixmap);
- }
- else if(params.buttons[button][state].pixmap)
+ my_pixmap = frameGetPixmap(c, button, c->button_pressed[button] ? PRESSED : state);
+ if(my_pixmap->pixmap)
{
- XSetWindowBackgroundPixmap(dpy, MYWINDOW_XWINDOW(c->buttons[button]), params.buttons[button][state].pixmap);
+ XSetWindowBackgroundPixmap(dpy, MYWINDOW_XWINDOW(c->buttons[button]), my_pixmap->pixmap);
}
x = x - params.buttons[button][ACTIVE].width - params.button_spacing;
myWindowShow(&c->buttons[button], x, (frameTop(c) - params.buttons[button][ACTIVE].height) / 2, params.buttons[button][ACTIVE].width, params.buttons[button][ACTIVE].height, TRUE);
diff --git a/src/settings.c b/src/settings.c
index 84b349590..1c31a0db5 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -532,6 +532,15 @@ static void loadTheme(Settings rc[])
loadPixmap(dpy, &params.buttons[MENU_BUTTON][ACTIVE], theme, "menu-active.xpm", colsym, 20);
loadPixmap(dpy, &params.buttons[MENU_BUTTON][INACTIVE], theme, "menu-inactive.xpm", colsym, 20);
loadPixmap(dpy, &params.buttons[MENU_BUTTON][PRESSED], theme, "menu-pressed.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[SHADE_BUTTON][T_ACTIVE], theme, "shade-toggled-active.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[SHADE_BUTTON][T_INACTIVE], theme, "shade-toggled-inactive.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[SHADE_BUTTON][T_PRESSED], theme, "shade-toggled-pressed.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[STICK_BUTTON][T_ACTIVE], theme, "stick-toggled-active.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[STICK_BUTTON][T_INACTIVE], theme, "stick-toggled-inactive.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[STICK_BUTTON][T_PRESSED], theme, "stick-toggled-pressed.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[MAXIMIZE_BUTTON][T_ACTIVE], theme, "maximize-toggled-active.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[MAXIMIZE_BUTTON][T_INACTIVE], theme, "maximize-toggled-inactive.xpm", colsym, 20);
+ loadPixmap(dpy, &params.buttons[MAXIMIZE_BUTTON][T_PRESSED], theme, "maximize-toggled-pressed.xpm", colsym, 20);
loadPixmap(dpy, &params.title[TITLE_1][ACTIVE], theme, "title-1-active.xpm", colsym, 20);
loadPixmap(dpy, &params.title[TITLE_1][INACTIVE], theme, "title-1-inactive.xpm", colsym, 20);
loadPixmap(dpy, &params.title[TITLE_2][ACTIVE], theme, "title-2-active.xpm", colsym, 20);
@@ -908,6 +917,9 @@ static void unloadTheme(void)
freePixmap(dpy, &params.buttons[i][ACTIVE]);
freePixmap(dpy, &params.buttons[i][INACTIVE]);
freePixmap(dpy, &params.buttons[i][PRESSED]);
+ freePixmap(dpy, &params.buttons[i][T_ACTIVE]);
+ freePixmap(dpy, &params.buttons[i][T_INACTIVE]);
+ freePixmap(dpy, &params.buttons[i][T_PRESSED]);
}
for(i = 0; i < 5; i++)
{
@@ -974,6 +986,9 @@ gboolean initSettings(void)
initPixmap(&params.buttons[i][ACTIVE]);
initPixmap(&params.buttons[i][INACTIVE]);
initPixmap(&params.buttons[i][PRESSED]);
+ initPixmap(&params.buttons[i][T_ACTIVE]);
+ initPixmap(&params.buttons[i][T_INACTIVE]);
+ initPixmap(&params.buttons[i][T_PRESSED]);
}
for(i = 0; i < 5; i++)
{
diff --git a/src/settings.h b/src/settings.h
index 5dd53b1b5..aa9a14c35 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -54,6 +54,13 @@
#define TITLE_SEPARATOR 6
#define BUTTON_COUNT 6
+#define ACTIVE 0
+#define INACTIVE 1
+#define PRESSED 2
+#define T_ACTIVE 3
+#define T_INACTIVE 4
+#define T_PRESSED 5
+
#define KEY_MOVE_UP 0
#define KEY_MOVE_DOWN 1
#define KEY_MOVE_LEFT 2
@@ -137,7 +144,7 @@ struct _Params
{
MyColor title_colors[2];
MyKey keys[KEY_COUNT];
- MyPixmap buttons[BUTTON_COUNT][3];
+ MyPixmap buttons[BUTTON_COUNT][6];
MyPixmap corners[4][2];
MyPixmap sides[3][2];
MyPixmap title[5][2];
diff --git a/themes/gtk/Makefile.am b/themes/gtk/Makefile.am
index 4e6cb02b9..cb029e9a3 100644
--- a/themes/gtk/Makefile.am
+++ b/themes/gtk/Makefile.am
@@ -17,6 +17,9 @@ theme_DATA = README \
maximize-active.xpm \
maximize-inactive.xpm \
maximize-pressed.xpm \
+ maximize-toggled-active.xpm \
+ maximize-toggled-inactive.xpm \
+ maximize-toggled-pressed.xpm \
menu-active.xpm \
menu-inactive.xpm \
menu-pressed.xpm \
@@ -25,9 +28,15 @@ theme_DATA = README \
shade-active.xpm \
shade-inactive.xpm \
shade-pressed.xpm \
+ shade-toggled-active.xpm \
+ shade-toggled-inactive.xpm \
+ shade-toggled-pressed.xpm \
stick-active.xpm \
stick-inactive.xpm \
stick-pressed.xpm \
+ stick-toggled-active.xpm \
+ stick-toggled-inactive.xpm \
+ stick-toggled-pressed.xpm \
themerc \
title-1-active.xpm \
title-1-inactive.xpm \
diff --git a/themes/gtk/Makefile.in b/themes/gtk/Makefile.in
index 1ac713b3d..4f3c7d1d7 100644
--- a/themes/gtk/Makefile.in
+++ b/themes/gtk/Makefile.in
@@ -174,6 +174,9 @@ theme_DATA = README \
maximize-active.xpm \
maximize-inactive.xpm \
maximize-pressed.xpm \
+ maximize-toggled-active.xpm \
+ maximize-toggled-inactive.xpm \
+ maximize-toggled-pressed.xpm \
menu-active.xpm \
menu-inactive.xpm \
menu-pressed.xpm \
@@ -182,9 +185,15 @@ theme_DATA = README \
shade-active.xpm \
shade-inactive.xpm \
shade-pressed.xpm \
+ shade-toggled-active.xpm \
+ shade-toggled-inactive.xpm \
+ shade-toggled-pressed.xpm \
stick-active.xpm \
stick-inactive.xpm \
stick-pressed.xpm \
+ stick-toggled-active.xpm \
+ stick-toggled-inactive.xpm \
+ stick-toggled-pressed.xpm \
themerc \
title-1-active.xpm \
title-1-inactive.xpm \
diff --git a/themes/microdeck/top-left-active.xpm b/themes/microdeck/top-left-active.xpm
index 8a9ee44de..863042bdd 100644
--- a/themes/microdeck/top-left-active.xpm
+++ b/themes/microdeck/top-left-active.xpm
@@ -23,6 +23,6 @@ static char * top_left_active_xpm[] = {
"$@###.",
"$@###.",
"$@###.",
-"$++++.",
-"$.....",
-"$$$$$$"};
+"$@###.",
+"$@##+.",
+"$@##.$"};
diff --git a/themes/microdeck/top-left-inactive.xpm b/themes/microdeck/top-left-inactive.xpm
index 47e5bad93..021cd89ad 100644
--- a/themes/microdeck/top-left-inactive.xpm
+++ b/themes/microdeck/top-left-inactive.xpm
@@ -23,6 +23,6 @@ static char * top_left_inactive_xpm[] = {
"$@###.",
"$@###.",
"$@###.",
-"$++++.",
-"$.....",
-"$$$$$$"};
+"$@###.",
+"$@##+.",
+"$@##.$"};
diff --git a/themes/microdeck/top-right-active.xpm b/themes/microdeck/top-right-active.xpm
index e8cb90d90..1a7cc7cf5 100644
--- a/themes/microdeck/top-right-active.xpm
+++ b/themes/microdeck/top-right-active.xpm
@@ -23,6 +23,6 @@ static char * top_right_active_xpm[] = {
"+##@.$",
"+##@.$",
"+##@.$",
-"+@@@.$",
-".....$",
-"$$$$$$"};
+"+##@.$",
+".+#@.$",
+"$.#@.$"};
diff --git a/themes/microdeck/top-right-inactive.xpm b/themes/microdeck/top-right-inactive.xpm
index d6c31c887..b93a99c91 100644
--- a/themes/microdeck/top-right-inactive.xpm
+++ b/themes/microdeck/top-right-inactive.xpm
@@ -23,6 +23,6 @@ static char * top_right_inactive_xpm[] = {
"+##@.$",
"+##@.$",
"+##@.$",
-"+@@@.$",
-".....$",
-"$$$$$$"};
+"+##@.$",
+".+#@.$",
+"$.#@.$"};