barwin: Rename bar.c -> barwin.c and all the bar.c function bar_* -> barwin_*
This commit is contained in:
parent
71bec3d1bb
commit
ec29e1d67e
@ -28,7 +28,7 @@ project(${PROJECT_NAME} C)
|
||||
|
||||
# Definition of the wmfs source
|
||||
set(wmfs_src
|
||||
src/bar.c
|
||||
src/barwin.c
|
||||
src/client.c
|
||||
src/config.c
|
||||
src/draw.c
|
||||
|
||||
255
src/bar.c
255
src/bar.c
@ -1,255 +0,0 @@
|
||||
/*
|
||||
* bar.c
|
||||
* Copyright © 2008 Martin Duquesnoy <xorg62@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* * Neither the name of the nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "wmfs.h"
|
||||
|
||||
/** Create a BarWindow
|
||||
* \param parent Parent window of the BarWindow
|
||||
* \param x X position
|
||||
* \param y Y position
|
||||
* \param w BarWindow Width
|
||||
* \param h BarWindow Height
|
||||
* \param color BarWindow color
|
||||
* \param entermask Bool for know if the EnterMask mask is needed
|
||||
* \return The BarWindow pointer
|
||||
*/
|
||||
BarWindow*
|
||||
bar_create(Window parent,
|
||||
int x, int y, uint w, uint h,
|
||||
uint color, Bool entermask)
|
||||
{
|
||||
XSetWindowAttributes at;
|
||||
BarWindow *bw;
|
||||
|
||||
bw = emalloc(1, sizeof(BarWindow));
|
||||
|
||||
at.override_redirect = True;
|
||||
at.background_pixmap = ParentRelative;
|
||||
if(entermask)
|
||||
at.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
|
||||
ButtonPressMask | ExposureMask | EnterWindowMask |
|
||||
LeaveWindowMask | StructureNotifyMask;
|
||||
else
|
||||
at.event_mask = SubstructureRedirectMask | SubstructureNotifyMask |
|
||||
ButtonPressMask | ExposureMask | StructureNotifyMask;
|
||||
|
||||
/* Create window */
|
||||
bw->win = XCreateWindow(dpy, parent, x, y, w, h, 0, DefaultDepth(dpy, screen),
|
||||
CopyFromParent, DefaultVisual(dpy, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &at);
|
||||
bw->dr = XCreatePixmap(dpy, parent, w, h, DefaultDepth(dpy, screen));
|
||||
|
||||
/* His border */
|
||||
CWIN(bw->border.left, bw->win, 0, 0, SHADH, h, 0, CWBackPixel, color_enlight(color), &at);
|
||||
CWIN(bw->border.top, bw->win, 0, 0, w, SHADH, 0, CWBackPixel, color_enlight(color), &at);
|
||||
CWIN(bw->border.bottom, bw->win, 0, h - SHADH, w, SHADH, 0, CWBackPixel, SHADC, &at);
|
||||
CWIN(bw->border.right, bw->win, w - SHADH, 0, SHADH, h, 0, CWBackPixel, SHADC, &at);
|
||||
|
||||
bw->geo.x = x;
|
||||
bw->geo.y = y;
|
||||
bw->geo.width = w;
|
||||
bw->geo.height = h;
|
||||
bw->color = color;
|
||||
bw->border.light = color_enlight(color);
|
||||
bw->border.dark = SHADC;
|
||||
|
||||
return bw;
|
||||
}
|
||||
|
||||
/** Delete a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_delete(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XSelectInput(dpy, bw->win, NoEventMask);
|
||||
XDestroyWindow(dpy, bw->win);
|
||||
XFreePixmap(dpy, bw->dr);
|
||||
free(bw);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Delete the BarWindow sub windows
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_delete_subwin(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XDestroySubwindows(dpy, bw->win);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Map a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_map(BarWindow *bw)
|
||||
{
|
||||
CHECK(!bw->mapped);
|
||||
|
||||
XMapWindow(dpy, bw->win);
|
||||
|
||||
bw->mapped = True;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** Map the subwindows of a BarWindow
|
||||
* Use for the BarWindow special border...
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_map_subwin(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XMapSubwindows(dpy, bw->win);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Unmap a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_unmap(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw->mapped);
|
||||
|
||||
XUnmapWindow(dpy, bw->win);
|
||||
|
||||
bw->mapped = False;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Unmap the BarWindow sub windows
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_unmap_subwin(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XUnmapSubwindows(dpy, bw->win);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Move a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
* \param x X position
|
||||
* \param y Y poistion
|
||||
*/
|
||||
void
|
||||
bar_move(BarWindow *bw, int x, int y)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
bw->geo.x = x;
|
||||
bw->geo.y = y;
|
||||
|
||||
XMoveWindow(dpy, bw->win, x, y);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Resize a BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
* \param w Width
|
||||
* \param h Height
|
||||
*/
|
||||
void
|
||||
bar_resize(BarWindow *bw, uint w, uint h)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
bw->geo.width = w;
|
||||
bw->geo.height = h;
|
||||
XFreePixmap(dpy, bw->dr);
|
||||
|
||||
/* Frame */
|
||||
bw->dr = XCreatePixmap(dpy, root, w - SHADH, h - SHADH, DefaultDepth(dpy, screen));
|
||||
XResizeWindow(dpy, bw->win, w, h);
|
||||
|
||||
/* Border */
|
||||
XResizeWindow(dpy, bw->border.left, SHADH, h);
|
||||
XResizeWindow(dpy, bw->border.top, w, SHADH);
|
||||
XResizeWindow(dpy, bw->border.bottom, w, SHADH);
|
||||
XMoveResizeWindow(dpy, bw->border.right, w - SHADH, 0, SHADH, h);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Refresh the BarWindow Color
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_refresh_color(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
draw_rectangle(bw->dr, 0, 0, bw->geo.width, bw->geo.height, bw->color);
|
||||
|
||||
XSetWindowBackground(dpy, bw->border.left , bw->border.light);
|
||||
XSetWindowBackground(dpy, bw->border.top , bw->border.light);
|
||||
XSetWindowBackground(dpy, bw->border.bottom , bw->border.dark);
|
||||
XSetWindowBackground(dpy, bw->border.right , bw->border.dark);
|
||||
|
||||
XClearWindow(dpy, bw->border.left);
|
||||
XClearWindow(dpy, bw->border.top);
|
||||
XClearWindow(dpy, bw->border.bottom);
|
||||
XClearWindow(dpy, bw->border.right);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/** Refresh the BarWindow
|
||||
* \param bw BarWindow pointer
|
||||
*/
|
||||
void
|
||||
bar_refresh(BarWindow *bw)
|
||||
{
|
||||
CHECK(bw);
|
||||
|
||||
XCopyArea(dpy, bw->dr, bw->win, gc, 0, 0, bw->geo.width, bw->geo.height, 0, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -337,8 +337,8 @@ client_map(Client *c)
|
||||
XMapSubwindows(dpy, c->frame);
|
||||
if(TBARH)
|
||||
{
|
||||
bar_map(c->titlebar);
|
||||
bar_map_subwin(c->titlebar);
|
||||
barwin_map(c->titlebar);
|
||||
barwin_map_subwin(c->titlebar);
|
||||
}
|
||||
c->unmapped = False;
|
||||
|
||||
@ -609,8 +609,8 @@ client_unmap(Client *c)
|
||||
|
||||
if(TBARH)
|
||||
{
|
||||
bar_unmap_subwin(c->titlebar);
|
||||
bar_unmap(c->titlebar);
|
||||
barwin_unmap_subwin(c->titlebar);
|
||||
barwin_unmap(c->titlebar);
|
||||
}
|
||||
XUnmapWindow(dpy, c->frame);
|
||||
XUnmapSubwindows(dpy, c->frame);
|
||||
|
||||
@ -206,14 +206,14 @@ expose(XExposeEvent *ev)
|
||||
|
||||
if(ev->count == 0
|
||||
&& (ev->window == infobar->bar->win))
|
||||
bar_refresh(infobar->bar);
|
||||
barwin_refresh(infobar->bar);
|
||||
|
||||
for(i = 1; i < conf.ntag + 1; ++i)
|
||||
if(ev->window == infobar->tags[i]->win)
|
||||
bar_refresh(infobar->tags[i]);
|
||||
barwin_refresh(infobar->tags[i]);
|
||||
|
||||
if(ev->window == infobar->layout_button->win)
|
||||
bar_refresh(infobar->layout_button);
|
||||
barwin_refresh(infobar->layout_button);
|
||||
|
||||
if((c = client_gb_titlebar(ev->window)))
|
||||
frame_update(c);
|
||||
|
||||
12
src/frame.c
12
src/frame.c
@ -69,7 +69,7 @@ frame_create(Client *c)
|
||||
|
||||
/* Create titlebar window */
|
||||
if(TBARH)
|
||||
c->titlebar = bar_create(c->frame, 0, 0, c->frame_geo.width, TBARH + BORDH, c->colors.frame, True);
|
||||
c->titlebar = barwin_create(c->frame, 0, 0, c->frame_geo.width, TBARH + BORDH, c->colors.frame, True);
|
||||
|
||||
at.event_mask &= ~(EnterWindowMask | LeaveWindowMask); /* <- Delete useless mask */
|
||||
|
||||
@ -108,8 +108,8 @@ frame_delete(Client *c)
|
||||
/* If there is, delete the titlebar */
|
||||
if(TBARH)
|
||||
{
|
||||
bar_delete_subwin(c->titlebar);
|
||||
bar_delete(c->titlebar);
|
||||
barwin_delete_subwin(c->titlebar);
|
||||
barwin_delete(c->titlebar);
|
||||
}
|
||||
|
||||
/* Delete the frame's sub win and the frame */
|
||||
@ -140,7 +140,7 @@ frame_moveresize(Client *c, XRectangle geo)
|
||||
|
||||
/* Titlebar */
|
||||
if(TBARH)
|
||||
bar_resize(c->titlebar, c->frame_geo.width, TBARH + BORDH);
|
||||
barwin_resize(c->titlebar, c->frame_geo.width, TBARH + BORDH);
|
||||
|
||||
/* Resize area */
|
||||
XMoveWindow(dpy, c->resize, c->frame_geo.width - RESHW, c->frame_geo.height - RESHW);
|
||||
@ -164,7 +164,7 @@ frame_update(Client *c)
|
||||
if(TBARH)
|
||||
{
|
||||
c->titlebar->color = c->colors.frame;
|
||||
bar_refresh_color(c->titlebar);
|
||||
barwin_refresh_color(c->titlebar);
|
||||
}
|
||||
|
||||
XSetWindowBackground(dpy, c->frame, c->colors.frame);
|
||||
@ -187,7 +187,7 @@ frame_update(Client *c)
|
||||
(c->frame_geo.width / 2) - (textw(c->title) / 2),
|
||||
(font->height - (font->descent)) + (((TBARH + BORDH) - font->height) / 2),
|
||||
conf.titlebar.fg, 0, c->title);
|
||||
bar_refresh(c->titlebar);
|
||||
barwin_refresh(c->titlebar);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@ -45,29 +45,29 @@ infobar_init(void)
|
||||
infobar->geo.y = (conf.bartop) ? 0 : MAXH - infobar->geo.height;
|
||||
|
||||
/* Create infobar barwindow */
|
||||
infobar->bar = bar_create(root, 0, infobar->geo.y, MAXW, infobar->geo.height, conf.colors.bar, False);
|
||||
infobar->bar = barwin_create(root, 0, infobar->geo.y, MAXW, infobar->geo.height, conf.colors.bar, False);
|
||||
|
||||
|
||||
/* Create tags window */
|
||||
for(i = 1; i < conf.ntag + 1; ++i)
|
||||
{
|
||||
infobar->tags[i] = bar_create(infobar->bar->win, j, 0, textw(tags[i].name) + PAD,
|
||||
infobar->geo.height, conf.colors.bar, False);
|
||||
infobar->tags[i] = barwin_create(infobar->bar->win, j, 0, textw(tags[i].name) + PAD,
|
||||
infobar->geo.height, conf.colors.bar, False);
|
||||
j += textw(tags[i].name) + PAD;
|
||||
bar_map_subwin(infobar->tags[i]);
|
||||
barwin_map_subwin(infobar->tags[i]);
|
||||
}
|
||||
|
||||
/* Create layout switch & layout type switch barwindow */
|
||||
infobar->layout_button = bar_create(infobar->bar->win, j + PAD / 2, 0,
|
||||
infobar->layout_button = barwin_create(infobar->bar->win, j + PAD / 2, 0,
|
||||
textw(tags[seltag].layout.symbol) + PAD,
|
||||
infobar->geo.height, conf.colors.layout_bg, False);
|
||||
|
||||
/* Map/Refresh all */
|
||||
bar_map(infobar->bar);
|
||||
bar_map_subwin(infobar->bar);
|
||||
bar_map_subwin(infobar->layout_button);
|
||||
bar_refresh_color(infobar->bar);
|
||||
bar_refresh(infobar->bar);
|
||||
barwin_map(infobar->bar);
|
||||
barwin_map_subwin(infobar->bar);
|
||||
barwin_map_subwin(infobar->layout_button);
|
||||
barwin_refresh_color(infobar->bar);
|
||||
barwin_refresh(infobar->bar);
|
||||
|
||||
strcpy(infobar->statustext, "WMFS-" WMFS_VERSION);
|
||||
infobar_draw();
|
||||
@ -82,7 +82,7 @@ infobar_draw(void)
|
||||
{
|
||||
infobar_draw_taglist();
|
||||
infobar_draw_layout();
|
||||
bar_refresh_color(infobar->bar);
|
||||
barwin_refresh_color(infobar->bar);
|
||||
|
||||
/* Draw status text */
|
||||
draw_text(infobar->bar->dr,
|
||||
@ -91,7 +91,7 @@ infobar_draw(void)
|
||||
conf.colors.text, 0,
|
||||
infobar->statustext);
|
||||
|
||||
bar_refresh(infobar->bar);
|
||||
barwin_refresh(infobar->bar);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -101,11 +101,11 @@ infobar_draw(void)
|
||||
void
|
||||
infobar_draw_layout(void)
|
||||
{
|
||||
bar_resize(infobar->layout_button, textw(tags[seltag].layout.symbol) + PAD, infobar->geo.height);
|
||||
bar_refresh_color(infobar->layout_button);
|
||||
barwin_resize(infobar->layout_button, textw(tags[seltag].layout.symbol) + PAD, infobar->geo.height);
|
||||
barwin_refresh_color(infobar->layout_button);
|
||||
draw_text(infobar->layout_button->dr, PAD / 2, font->height,
|
||||
conf.colors.layout_fg, 0, tags[seltag].layout.symbol);
|
||||
bar_refresh(infobar->layout_button);
|
||||
barwin_refresh(infobar->layout_button);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -120,11 +120,11 @@ infobar_draw_taglist(void)
|
||||
for(i = 1; i < conf.ntag + 1; ++i)
|
||||
{
|
||||
infobar->tags[i]->color = ((i == seltag) ? conf.colors.tagselbg : conf.colors.bar);
|
||||
bar_refresh_color(infobar->tags[i]);
|
||||
barwin_refresh_color(infobar->tags[i]);
|
||||
draw_text(infobar->tags[i]->dr, PAD / 2, font->height,
|
||||
((i == seltag) ? conf.colors.tagselfg : conf.colors.text),
|
||||
0, tags[i].name);
|
||||
bar_refresh(infobar->tags[i]);
|
||||
barwin_refresh(infobar->tags[i]);
|
||||
}
|
||||
|
||||
return;
|
||||
@ -137,15 +137,15 @@ infobar_destroy(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
bar_delete(infobar->bar);
|
||||
bar_delete(infobar->layout_button);
|
||||
bar_delete_subwin(infobar->layout_button);
|
||||
barwin_delete(infobar->bar);
|
||||
barwin_delete(infobar->layout_button);
|
||||
barwin_delete_subwin(infobar->layout_button);
|
||||
for(i = 1; i < conf.ntag + 1; ++i)
|
||||
{
|
||||
bar_delete_subwin(infobar->tags[i]);
|
||||
bar_delete(infobar->tags[i]);
|
||||
barwin_delete_subwin(infobar->tags[i]);
|
||||
barwin_delete(infobar->tags[i]);
|
||||
}
|
||||
bar_delete_subwin(infobar->bar);
|
||||
barwin_delete_subwin(infobar->bar);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -165,7 +165,7 @@ uicb_infobar_togglepos(uicb_t cmd)
|
||||
sgeo.y = TBARH;
|
||||
|
||||
infobar->geo.y = (conf.bartop) ? 0 : MAXH - infobar->geo.height;
|
||||
bar_move(infobar->bar, 0, infobar->geo.y);
|
||||
barwin_move(infobar->bar, 0, infobar->geo.y);
|
||||
infobar_draw();
|
||||
arrange();
|
||||
|
||||
|
||||
24
src/wmfs.h
24
src/wmfs.h
@ -80,18 +80,18 @@
|
||||
#define deb(p) fprintf(stderr, "debug: %d\n", p)
|
||||
#define PAD 14
|
||||
|
||||
/* bar.c */
|
||||
BarWindow *bar_create(Window parent, int x, int y, uint w, uint h, uint color, Bool entermask);
|
||||
void bar_delete(BarWindow *bw);
|
||||
void bar_delete_subwin(BarWindow *bw);
|
||||
void bar_map(BarWindow *bw);
|
||||
void bar_map_subwin(BarWindow *bw);
|
||||
void bar_unmap(BarWindow *bw);
|
||||
void bar_unmap_subwin(BarWindow *bw);
|
||||
void bar_move(BarWindow *bw, int x, int y);
|
||||
void bar_resize(BarWindow *bw, uint w, uint h);
|
||||
void bar_refresh_color(BarWindow *bw);
|
||||
void bar_refresh(BarWindow *bw);
|
||||
/* barwin.c */
|
||||
BarWindow *barwin_create(Window parent, int x, int y, uint w, uint h, uint color, Bool entermask);
|
||||
void barwin_delete(BarWindow *bw);
|
||||
void barwin_delete_subwin(BarWindow *bw);
|
||||
void barwin_map(BarWindow *bw);
|
||||
void barwin_map_subwin(BarWindow *bw);
|
||||
void barwin_unmap(BarWindow *bw);
|
||||
void barwin_unmap_subwin(BarWindow *bw);
|
||||
void barwin_move(BarWindow *bw, int x, int y);
|
||||
void barwin_resize(BarWindow *bw, uint w, uint h);
|
||||
void barwin_refresh_color(BarWindow *bw);
|
||||
void barwin_refresh(BarWindow *bw);
|
||||
|
||||
/* draw.c */
|
||||
void draw_text(Drawable d, int x, int y, char* fg, int pad, char *str);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user