Chubby buttons patch
Scott Moynes
smoynes at nexus.carleton.ca
Fri Aug 23 00:22:04 EDT 2002
Here is a different version of the large button patch. It is
prelimnary and only meant to get an idea if people like it.
I'll make the code prettier if people care.
--
Scott Moynes
"Computer science is as much about computers
as astronomy is about telescopes." -- Dijkstra
-------------- next part --------------
diff -purN openbox-HEAD/src/GCCache.cc openbox-bigbuttons/src/GCCache.cc
--- openbox-HEAD/src/GCCache.cc Sun Jul 7 06:27:02 2002
+++ openbox-bigbuttons/src/GCCache.cc Fri Aug 23 00:07:05 2002
@@ -43,12 +43,17 @@ BGCCacheContext::~BGCCacheContext(void)
void BGCCacheContext::set(const BColor &_color,
const XFontStruct * const _font,
- const int _function, const int _subwindow) {
+ const int _function, const int _subwindow,
+ int _lineWidth) {
XGCValues gcv;
pixel = gcv.foreground = _color.pixel();
function = gcv.function = _function;
subwindow = gcv.subwindow_mode = _subwindow;
- unsigned long mask = GCForeground | GCFunction | GCSubwindowMode;
+ lineWidth = gcv.line_width = _lineWidth;
+ gcv.cap_style = CapProjecting;
+
+ unsigned long mask = GCForeground | GCFunction | GCSubwindowMode |
+ GCLineWidth | GCCapStyle;
if (_font) {
fontid = gcv.font = _font->fid;
@@ -131,7 +136,7 @@ void BGCCache::release(BGCCacheContext *
BGCCacheItem *BGCCache::find(const BColor &_color,
const XFontStruct * const _font,
- int _function, int _subwindow) {
+ int _function, int _subwindow, int _lineWidth) {
const unsigned long pixel = _color.pixel();
const unsigned int screen = _color.screen();
const int key = _color.red() ^ _color.green() ^ _color.blue();
@@ -142,7 +147,8 @@ BGCCacheItem *BGCCache::find(const BColo
// this will either loop 8 times then return/abort or it will stop matching
while (c->ctx &&
(c->ctx->pixel != pixel || c->ctx->function != _function ||
- c->ctx->subwindow != _subwindow || c->ctx->screen != screen)) {
+ c->ctx->subwindow != _subwindow || c->ctx->screen != screen ||
+ c->ctx->lineWidth != _lineWidth)) {
if (i < 7) {
prev = c;
c = cache[ ++k ];
@@ -151,7 +157,7 @@ BGCCacheItem *BGCCache::find(const BColo
}
if (c->count == 0 && c->ctx->screen == screen) {
// use this cache item
- c->ctx->set(_color, _font, _function, _subwindow);
+ c->ctx->set(_color, _font, _function, _subwindow, _lineWidth);
c->ctx->used = true;
c->count = 1;
c->hits = 1;
@@ -175,7 +181,7 @@ BGCCacheItem *BGCCache::find(const BColo
}
} else {
c->ctx = nextContext(screen);
- c->ctx->set(_color, _font, _function, _subwindow);
+ c->ctx->set(_color, _font, _function, _subwindow, _lineWidth);
c->ctx->used = true;
c->count = 1;
c->hits = 1;
diff -purN openbox-HEAD/src/GCCache.hh openbox-bigbuttons/src/GCCache.hh
--- openbox-HEAD/src/GCCache.hh Sun Jul 7 06:27:02 2002
+++ openbox-bigbuttons/src/GCCache.hh Thu Aug 22 23:34:34 2002
@@ -36,7 +36,7 @@ class BGCCacheItem;
class BGCCacheContext {
public:
void set(const BColor &_color, const XFontStruct * const _font,
- const int _function, const int _subwindow);
+ const int _function, const int _subwindow, const int lineWidth);
void set(const XFontStruct * const _font);
~BGCCacheContext(void);
@@ -44,7 +44,7 @@ public:
private:
BGCCacheContext(const BaseDisplay * const _display)
: display(_display), gc(0), pixel(0ul), fontid(0ul),
- function(0), subwindow(0), used(false), screen(~(0u)) {}
+ function(0), subwindow(0), used(false), screen(~(0u)), lineWidth(0) {}
const BaseDisplay *display;
GC gc;
@@ -54,6 +54,7 @@ private:
int subwindow;
bool used;
unsigned int screen;
+ int lineWidth;
BGCCacheContext(const BGCCacheContext &_nocopy);
BGCCacheContext &operator=(const BGCCacheContext &_nocopy);
@@ -89,7 +90,8 @@ public:
void purge(void);
BGCCacheItem *find(const BColor &_color, const XFontStruct * const _font = 0,
- int _function = GXcopy, int _subwindow = ClipByChildren);
+ int _function = GXcopy, int _subwindow = ClipByChildren,
+ int _lineWidth = 0);
void release(BGCCacheItem *_item);
private:
@@ -111,13 +113,16 @@ private:
class BPen {
public:
inline BPen(const BColor &_color, const XFontStruct * const _font = 0,
- int _function = GXcopy, int _subwindow = ClipByChildren)
+ int _function = GXcopy, int _subwindow = ClipByChildren,
+ int _lineWidth = 0)
: color(_color), font(_font), function(_function), subwindow(_subwindow),
- cache(_color.display()->gcCache()), item(0) { }
+ cache(_color.display()->gcCache()), item(0), lineWidth(_lineWidth) { }
+
inline ~BPen(void) { if (item) cache->release(item); }
inline const GC &gc(void) const {
- if (! item) item = cache->find(color, font, function, subwindow);
+ if (! item) item = cache->find(color, font, function, subwindow,
+ lineWidth);
return item->gc();
}
@@ -126,6 +131,7 @@ private:
const XFontStruct *font;
int function;
int subwindow;
+ int lineWidth;
mutable BGCCache *cache;
mutable BGCCacheItem *item;
diff -purN openbox-HEAD/src/Window.cc openbox-bigbuttons/src/Window.cc
--- openbox-HEAD/src/Window.cc Wed Aug 21 23:46:45 2002
+++ openbox-bigbuttons/src/Window.cc Fri Aug 23 00:12:16 2002
@@ -2605,11 +2605,18 @@ void BlackboxWindow::redrawCloseButton(b
XClearWindow(blackbox->getXDisplay(), frame.close_button);
BPen pen((flags.focused) ? screen->getWindowStyle()->b_pic_focus :
- screen->getWindowStyle()->b_pic_unfocus);
+ screen->getWindowStyle()->b_pic_unfocus,
+ 0, GXcopy, ClipByChildren, 2);
+
+ XGCValues gcv;
+ XGetGCValues(blackbox->getXDisplay(), pen.gc(), GCLineWidth,
+ &gcv);
+
XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(),
2, 2, (frame.button_w - 3), (frame.button_w - 3));
XDrawLine(blackbox->getXDisplay(), frame.close_button, pen.gc(),
2, (frame.button_w - 3), (frame.button_w - 3), 2);
+
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
URL: <http://icculus.org/pipermail/openbox/attachments/20020823/e0f96d38/attachment.pgp>
More information about the openbox
mailing list