From 9e1994d8794e622f7dfaa75cbabe8bb932a60e29 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 23 Jan 2008 17:44:07 +0100 Subject: [PATCH] rework statusbar stuff --- statusbar.c | 40 +++++++++++++++++++++------------------- window.c | 16 +++++++++++----- window.h | 2 +- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/statusbar.c b/statusbar.c index a08d1dd6..8c723ff7 100644 --- a/statusbar.c +++ b/statusbar.c @@ -116,21 +116,23 @@ statusbar_draw(Statusbar *statusbar) left += widget->draw(widget, ctx, left, (left + right)); } - if(statusbar->position == Right - || statusbar->position == Left) + switch(statusbar->position) { - if(statusbar->position == Right) - statusbar->sw->drawable = draw_rotate(ctx, phys_screen, M_PI_2, statusbar->height, 0); - else - statusbar->sw->drawable = draw_rotate(ctx, phys_screen, - M_PI_2, 0, statusbar->width); - - draw_free_context(ctx); - } - else - { - statusbar->sw->drawable = ctx->drawable; - /* just delete the struct, don't delete the drawable */ - p_delete(&ctx); + case Right: + statusbar->sw->drawable = draw_rotate(ctx, phys_screen, M_PI_2, + statusbar->height, 0); + draw_free_context(ctx); + break; + case Left: + statusbar->sw->drawable = draw_rotate(ctx, phys_screen, - M_PI_2, + 0, statusbar->width); + draw_free_context(ctx); + break; + default: + statusbar->sw->drawable = ctx->drawable; + /* just delete the struct, don't delete the drawable */ + p_delete(&ctx); + break; } statusbar_display(statusbar); @@ -150,13 +152,13 @@ statusbar_display(Statusbar *statusbar) XCopyArea(globalconf.display, statusbar->sw->drawable, statusbar->sw->window, DefaultGC(globalconf.display, phys_screen), 0, 0, - statusbar->height, - statusbar->width, 0, 0); + statusbar->sw->geometry.height, + statusbar->sw->geometry.width, 0, 0); else XCopyArea(globalconf.display, statusbar->sw->drawable, statusbar->sw->window, DefaultGC(globalconf.display, phys_screen), 0, 0, - statusbar->width, statusbar->height, 0, 0); + statusbar->sw->geometry.width, statusbar->sw->geometry.height, 0, 0); } void @@ -207,10 +209,10 @@ statusbar_init(Statusbar *statusbar) if(statusbar->dposition == Right || statusbar->dposition == Left) statusbar->sw = - simplewindow_new(phys_screen, 0, 0, statusbar->height, statusbar->width, 0); + simplewindow_new(phys_screen, 0, 0, statusbar->height, statusbar->width, 0, True); else statusbar->sw = - simplewindow_new(phys_screen, 0, 0, statusbar->width, statusbar->height, 0); + simplewindow_new(phys_screen, 0, 0, statusbar->width, statusbar->height, 0, False); widget_calculate_alignments(statusbar->widgets); diff --git a/window.c b/window.c index 574cf860..b7b3618b 100644 --- a/window.c +++ b/window.c @@ -178,7 +178,7 @@ window_settrans(Window win, double opacity) SimpleWindow * simplewindow_new(int phys_screen, int x, int y, unsigned int w, unsigned int h, - unsigned int border_width) + unsigned int border_width, Bool rotate_drawable) { XSetWindowAttributes wa; SimpleWindow *sw; @@ -206,10 +206,16 @@ simplewindow_new(int phys_screen, int x, int y, unsigned int w, unsigned int h, CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); - sw->drawable = XCreatePixmap(globalconf.display, - RootWindow(globalconf.display, phys_screen), - w, h, - DefaultDepth(globalconf.display, phys_screen)); + if(rotate_drawable) + sw->drawable = XCreatePixmap(globalconf.display, + RootWindow(globalconf.display, phys_screen), + h, w, + DefaultDepth(globalconf.display, phys_screen)); + else + sw->drawable = XCreatePixmap(globalconf.display, + RootWindow(globalconf.display, phys_screen), + w, h, + DefaultDepth(globalconf.display, phys_screen)); XDefineCursor(globalconf.display, sw->window, diff --git a/window.h b/window.h index 1ddec427..373cd712 100644 --- a/window.h +++ b/window.h @@ -30,7 +30,7 @@ Status window_configure(Window, Area, int); void window_grabbuttons(int, Window, Bool, Bool); void window_setshape(int, Window); int window_settrans(Window, double); -SimpleWindow * simplewindow_new(int, int, int, unsigned int, unsigned int, unsigned int); +SimpleWindow * simplewindow_new(int, int, int, unsigned int, unsigned int, unsigned int, Bool); void simplewindow_delete(SimpleWindow *); int simplewindow_move(SimpleWindow *, int, int);