# Set this to the location of the global configuration files
SYSCONFDIR = $(CONFPREFIX)$(CONFDIR)
-# Information about the location of the menurc file
-ifndef MENURC
-MENURC = $(SYSCONFDIR)/windowlab.menurc
-endif
-
-DEFINES += -DDEF_MENURC="\"$(MENURC)\""
-
# Uncomment for debugging info (abandon all hope, ye who enter here)
#DEFINES += -DDEBUG
// clear text part of bar
if (c == focused_client)
{
- XFillRectangle(dsply, c->frame, active_gc, 0, 0, c->width - ((BARHEIGHT() - DEF_BORDERWIDTH) * 3), BARHEIGHT() - DEF_BORDERWIDTH);
+ XFillRectangle(dsply, c->frame, active_gc, 0, 0, c->width - (BARHEIGHT() - DEF_BORDERWIDTH), BARHEIGHT() - DEF_BORDERWIDTH);
}
else
{
- XFillRectangle(dsply, c->frame, inactive_gc, 0, 0, c->width - ((BARHEIGHT() - DEF_BORDERWIDTH) * 3), BARHEIGHT() - DEF_BORDERWIDTH);
+ XFillRectangle(dsply, c->frame, inactive_gc, 0, 0, c->width - (BARHEIGHT() - DEF_BORDERWIDTH), BARHEIGHT() - DEF_BORDERWIDTH);
}
if (!c->trans && c->name != NULL)
{
}
if (c == focused_client)
{
- draw_hide_button(c, &text_gc, &active_gc);
- draw_toggledepth_button(c, &text_gc, &active_gc);
draw_close_button(c, &text_gc, &active_gc);
}
else
{
- draw_hide_button(c, &text_gc, &inactive_gc);
- draw_toggledepth_button(c, &text_gc, &inactive_gc);
draw_close_button(c, &text_gc, &inactive_gc);
}
}
return prev_focused;
}
-void draw_hide_button(Client *c, GC *detail_gc, GC *background_gc)
-{
- int x, topleft_offset;
- x = c->width - ((BARHEIGHT() - DEF_BORDERWIDTH) * 3);
- topleft_offset = (BARHEIGHT() / 2) - 5; // 5 being ~half of 9
- XFillRectangle(dsply, c->frame, *background_gc, x, 0, BARHEIGHT() - DEF_BORDERWIDTH, BARHEIGHT() - DEF_BORDERWIDTH);
-
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 4, topleft_offset + 2, x + topleft_offset + 4, topleft_offset + 0);
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 6, topleft_offset + 2, x + topleft_offset + 7, topleft_offset + 1);
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 6, topleft_offset + 4, x + topleft_offset + 8, topleft_offset + 4);
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 6, topleft_offset + 6, x + topleft_offset + 7, topleft_offset + 7);
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 4, topleft_offset + 6, x + topleft_offset + 4, topleft_offset + 8);
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 2, topleft_offset + 6, x + topleft_offset + 1, topleft_offset + 7);
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 2, topleft_offset + 4, x + topleft_offset + 0, topleft_offset + 4);
- XDrawLine(dsply, c->frame, *detail_gc, x + topleft_offset + 2, topleft_offset + 2, x + topleft_offset + 1, topleft_offset + 1);
-}
-
-void draw_toggledepth_button(Client *c, GC *detail_gc, GC *background_gc)
-{
- int x, topleft_offset;
- x = c->width - ((BARHEIGHT() - DEF_BORDERWIDTH) * 2);
- topleft_offset = (BARHEIGHT() / 2) - 6; // 6 being ~half of 11
- XFillRectangle(dsply, c->frame, *background_gc, x, 0, BARHEIGHT() - DEF_BORDERWIDTH, BARHEIGHT() - DEF_BORDERWIDTH);
-
- XDrawRectangle(dsply, c->frame, *detail_gc, x + topleft_offset, topleft_offset, 7, 7);
- XDrawRectangle(dsply, c->frame, *detail_gc, x + topleft_offset + 3, topleft_offset + 3, 7, 7);
-}
-
void draw_close_button(Client *c, GC *detail_gc, GC *background_gc)
{
int x, topleft_offset;
#include <X11/Xatom.h>
#include "windowlab.h"
-static void handle_key_press(XKeyEvent *);
static void handle_button_press(XButtonEvent *);
static void handle_windowbar_click(XButtonEvent *, Client *);
static unsigned int box_clicked(Client *, int);
static void handle_client_message(XClientMessageEvent *);
static void handle_property_change(XPropertyEvent *);
static void handle_enter_event(XCrossingEvent *);
-static void handle_colormap_change(XColormapEvent *);
static void handle_expose_event(XExposeEvent *);
static int interruptible_XNextEvent(XEvent *event);
#endif
switch (ev.type)
{
- case KeyPress:
- handle_key_press(&ev.xkey);
- break;
case ButtonPress:
handle_button_press(&ev.xbutton);
break;
case ClientMessage:
handle_client_message(&ev.xclient);
break;
- case ColormapNotify:
- handle_colormap_change(&ev.xcolormap);
- break;
case PropertyNotify:
handle_property_change(&ev.xproperty);
break;
}
}
-static void handle_key_press(XKeyEvent *e)
-{
- KeySym key = XKeycodeToKeysym(dsply, e->keycode, 0);
- switch (key)
- {
- case KEY_FULLSCREEN:
- toggle_fullscreen(focused_client);
- break;
- case KEY_TOGGLEZ:
- raise_lower(focused_client);
- break;
- }
-}
-
/* Someone clicked a button. If it was on the root, we get the click
* by default. If it's on a window frame, we get it as well. If it's
* on a client window, it may still fall through to us if the client
XAllowEvents(dsply, ReplayPointer, CurrentTime);
}
}
- else if (e->window == root)
- {
-#ifdef DEBUG
- dump_clients();
-#endif
- }
else
{
// pass event on
case 1:
raise_lower(c);
break;
- case 2:
- hide(c);
- break;
}
}
}
static void draw_button(Client *c, GC *detail_gc, GC *background_gc, unsigned int which_box)
{
- switch (which_box)
- {
- case 0:
- draw_close_button(c, detail_gc, background_gc);
- break;
- case 1:
- draw_toggledepth_button(c, detail_gc, background_gc);
- break;
- case 2:
- draw_hide_button(c, detail_gc, background_gc);
- break;
+ if (which_box == 0) {
+ draw_close_button(c, detail_gc, background_gc);
}
}
Client *c = find_client(e->window, WINDOW);
if (c != NULL)
{
- unhide(c);
}
else
{
static void handle_destroy_event(XDestroyWindowEvent *e)
{
Client *c = find_client(e->window, WINDOW);
- if (c != NULL)
- {
- remove_client(c, WITHDRAW);
- }
+ if (c) remove_client(c, WITHDRAW);
}
/* If a client wants to iconify itself (boo! hiss!) it must send a
static void handle_client_message(XClientMessageEvent *e)
{
- Client *c = find_client(e->window, WINDOW);
- if (c != NULL && e->message_type == wm_change_state && e->format == 32 && e->data.l[0] == IconicState)
- {
- hide(c);
- }
}
/* All that we have cached is the name and the size hints, so we only
}
}
-/* Here's part 2 of our colormap policy: when a client installs a new
- * colormap on itself, set the display's colormap to that. Arguably,
- * this is bad, because we should only set the colormap if that client
- * has the focus. However, clients don't usually set colormaps at
- * random when you're not interacting with them, so I think we're
- * safe. If you have an 8-bit display and this doesn't work for you,
- * by all means yell at me, but very few people have 8-bit displays
- * these days. */
-
-static void handle_colormap_change(XColormapEvent *e)
-{
- Client *c = find_client(e->window, WINDOW);
- //if (c != NULL && e->c_new) // use c_new for c++
- if (c != NULL && e->new)
- {
- c->cmap = e->colormap;
- XInstallColormap(dsply, c->cmap);
- }
-}
-
/* If we were covered by multiple windows, we will usually get
* multiple expose events, so ignore them unless e->count (the number
* of outstanding exposes) is zero. */
Cursor resize_curs;
Atom wm_state, wm_change_state, wm_protos, wm_delete, wm_cmapwins;
Client *head_client = NULL, *focused_client = NULL, *topmost_client = NULL, *fullscreen_client = NULL;
-unsigned int in_taskbar = 0; // actually, we don't know yet
-unsigned int showing_taskbar = 1;
unsigned int focus_count = 0;
Rect fs_prevdims;
char *opt_font = DEF_FONT;
#include "windowlab.h"
-static void limit_size(Client *, Rect *);
-static int get_incsize(Client *, unsigned int *, unsigned int *, Rect *, int);
-
void raise_lower(Client *c)
{
if (c != NULL)
}
}
-/* increment ignore_unmap here and decrement it in handle_unmap_event in events.c */
-
-void hide(Client *c)
-{
- if (c != NULL)
- {
- if (!c->hidden)
- {
- c->ignore_unmap++;
- c->hidden = 1;
- if (c == topmost_client)
- {
- topmost_client = NULL;
- }
- XUnmapWindow(dsply, c->frame);
- XUnmapWindow(dsply, c->window);
- set_wm_state(c, IconicState);
- check_focus(get_prev_focused());
- }
- }
-}
-
-void unhide(Client *c)
-{
- if (c != NULL)
- {
- if (c->hidden)
- {
- c->hidden = 0;
- topmost_client = c;
- XMapWindow(dsply, c->window);
- XMapRaised(dsply, c->frame);
- set_wm_state(c, NormalState);
- }
- }
-}
-
-void toggle_fullscreen(Client *c)
-{
- int xoffset, yoffset, maxwinwidth, maxwinheight;
- if (c != NULL && !c->trans)
- {
- if (c == fullscreen_client) // reset to original size
- {
- c->x = fs_prevdims.x;
- c->y = fs_prevdims.y;
- c->width = fs_prevdims.width;
- c->height = fs_prevdims.height;
- XMoveResizeWindow(dsply, c->frame, c->x, c->y - BARHEIGHT(), c->width, c->height + BARHEIGHT());
- XMoveResizeWindow(dsply, c->window, 0, BARHEIGHT(), c->width, c->height);
- send_config(c);
- fullscreen_client = NULL;
- showing_taskbar = 1;
- }
- else // make fullscreen
- {
- xoffset = yoffset = 0;
- maxwinwidth = DisplayWidth(dsply, screen);
- maxwinheight = DisplayHeight(dsply, screen) - BARHEIGHT();
- if (fullscreen_client != NULL) // reset existing fullscreen window to original size
- {
- fullscreen_client->x = fs_prevdims.x;
- fullscreen_client->y = fs_prevdims.y;
- fullscreen_client->width = fs_prevdims.width;
- fullscreen_client->height = fs_prevdims.height;
- XMoveResizeWindow(dsply, fullscreen_client->frame, fullscreen_client->x, fullscreen_client->y - BARHEIGHT(), fullscreen_client->width, fullscreen_client->height + BARHEIGHT());
- XMoveResizeWindow(dsply, fullscreen_client->window, 0, BARHEIGHT(), fullscreen_client->width, fullscreen_client->height);
- send_config(fullscreen_client);
- }
- fs_prevdims.x = c->x;
- fs_prevdims.y = c->y;
- fs_prevdims.width = c->width;
- fs_prevdims.height = c->height;
- c->x = 0 - BORDERWIDTH(c);
- c->y = BARHEIGHT() - BORDERWIDTH(c);
- c->width = maxwinwidth;
- c->height = maxwinheight;
- if (c->size->flags & PMaxSize || c->size->flags & PResizeInc)
- {
- if (c->size->flags & PResizeInc)
- {
- Rect maxwinsize;
- maxwinsize.x = xoffset;
- maxwinsize.width = maxwinwidth;
- maxwinsize.y = yoffset;
- maxwinsize.height = maxwinheight;
- get_incsize(c, (unsigned int *)&c->size->max_width, (unsigned int *)&c->size->max_height, &maxwinsize, PIXELS);
- }
- if (c->size->max_width < maxwinwidth)
- {
- c->width = c->size->max_width;
- xoffset = (maxwinwidth - c->width) / 2;
- }
- if (c->size->max_height < maxwinheight)
- {
- c->height = c->size->max_height;
- yoffset = (maxwinheight - c->height) / 2;
- }
- }
- XMoveResizeWindow(dsply, c->frame, c->x, c->y, maxwinwidth, maxwinheight);
- XMoveResizeWindow(dsply, c->window, xoffset, yoffset, c->width, c->height);
- send_config(c);
- fullscreen_client = c;
- showing_taskbar = in_taskbar;
- }
- }
-}
-
/* The name of this function is a bit misleading: if the client
* doesn't listen to WM_DELETE then we just terminate it with extreme
* prejudice. */
XDestroyWindow(dsply, resize_win);
}
-static void limit_size(Client *c, Rect *newdims)
-{
- int dw, dh;
- dw = DisplayWidth(dsply, screen);
- dh = DisplayHeight(dsply, screen);
-
- if (c->size->flags & PMinSize)
- {
- if (newdims->width < c->size->min_width)
- {
- newdims->width = c->size->min_width;
- }
- if (newdims->height < c->size->min_height)
- {
- newdims->height = c->size->min_height;
- }
- }
-
- if (c->size->flags & PMaxSize)
- {
- if (newdims->width > c->size->max_width)
- {
- newdims->width = c->size->max_width;
- }
- if (newdims->height > c->size->max_height)
- {
- newdims->height = c->size->max_height;
- }
- }
-
- if (newdims->width < MINWINWIDTH)
- {
- newdims->width = MINWINWIDTH;
- }
- if (newdims->height < MINWINHEIGHT)
- {
- newdims->height = MINWINHEIGHT;
- }
-
- if (newdims->width > dw)
- {
- newdims->width = dw;
- }
- if (newdims->height > (dh - BARHEIGHT()))
- {
- newdims->height = (dh - BARHEIGHT());
- }
-}
-
-/* If the window in question has a ResizeInc int, then it wants to be
- * resized in multiples of some (x,y). Here we set x_ret and y_ret to
- * the number of multiples (if mode == INCREMENTS) or the correct size
- * in pixels for said multiples (if mode == PIXELS). */
-
-static int get_incsize(Client *c, unsigned int *x_ret, unsigned int *y_ret, Rect *newdims, int mode)
-{
- int basex, basey;
- if (c->size->flags & PResizeInc)
- {
- basex = (c->size->flags & PBaseSize) ? c->size->base_width : (c->size->flags & PMinSize) ? c->size->min_width : 0;
- basey = (c->size->flags & PBaseSize) ? c->size->base_height : (c->size->flags & PMinSize) ? c->size->min_height : 0;
- // work around broken apps that set their resize increments to 0
- if (mode == PIXELS)
- {
- if (c->size->width_inc != 0)
- {
- *x_ret = newdims->width - ((newdims->width - basex) % c->size->width_inc);
- }
- if (c->size->height_inc != 0)
- {
- *y_ret = newdims->height - ((newdims->height - basey) % c->size->height_inc);
- }
- }
- else // INCREMENTS
- {
- if (c->size->width_inc != 0)
- {
- *x_ret = (newdims->width - basex) / c->size->width_inc;
- }
- if (c->size->height_inc != 0)
- {
- *y_ret = (newdims->height - basey) / c->size->height_inc;
- }
- }
- return 1;
- }
- return 0;
-}
-
void write_titletext(Client *c, Window bar_win)
{
if (!c->trans && c->name != NULL)
extern void dump_clients(void);
#endif
-// taskbar.c
-extern Window taskbar;
-extern XftDraw *tbxftdraw;
-extern void make_taskbar(void);
-extern void cycle_previous(void);
-extern void cycle_next(void);
-extern void lclick_taskbar(int);
-extern void rclick_taskbar(int);
-extern void rclick_root(void);
-extern void redraw_taskbar(void);
-extern float get_button_width(void);
-
-// menufile.c
-extern int do_menuitems;
-extern MenuItem* menuitems;
-extern unsigned int num_menuitems;
-extern void get_menuitems(void);
-extern void free_menuitems(void);
#endif /* WINDOWLAB_H */