add scratch window support

This commit is contained in:
Julien Danjou 2008-02-06 08:49:31 +01:00
parent 8567009d22
commit b2e004b453
9 changed files with 79 additions and 6 deletions

View File

@ -87,6 +87,10 @@ Client
Move client window with mouse. Move client window with mouse.
*client_resizemouse*:: *client_resizemouse*::
Resize client window with mouse. Resize client window with mouse.
*client_setscratch*::
Set or unset client as being the scratch window.
*client_togglescratch*::
Toggle scratch window.
Tag Tag
~~~ ~~~

View File

@ -316,6 +316,18 @@ keys
command = "client_togglefloating" command = "client_togglefloating"
} }
key key
{
modkey = {"Mod4"}
key = "s"
command = "client_togglescratch"
}
key
{
modkey = {"Mod4", "Control"}
key = "s"
command = "client_setscratch"
}
key
{ {
modkey = {"Mod4", "Shift"} modkey = {"Mod4", "Shift"}
key = "c" key = "c"

View File

@ -704,6 +704,9 @@ client_isvisible(Client *c, int screen)
if(!c || c->screen != screen) if(!c || c->screen != screen)
return False; return False;
if(globalconf.scratch.client == c)
return globalconf.scratch.isvisible;
for(tag = globalconf.screens[screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[screen].tags; tag; tag = tag->next)
if(tag->selected && is_client_tagged(c, tag)) if(tag->selected && is_client_tagged(c, tag))
return True; return True;
@ -1079,4 +1082,41 @@ uicb_client_togglefloating(int screen __attribute__ ((unused)),
client_setfloating(globalconf.focus->client, !globalconf.focus->client->isfloating); client_setfloating(globalconf.focus->client, !globalconf.focus->client->isfloating);
} }
/** Toggle scratch client attribute
* \param screen screen number
* \param arg unused argument
* \ingroup ui_callback
*/
void
uicb_client_setscratch(int screen,
char *arg __attribute__ ((unused)))
{
if(!globalconf.focus->client)
return;
if(globalconf.scratch.client == globalconf.focus->client)
globalconf.scratch.client = NULL;
else
globalconf.scratch.client = globalconf.focus->client;
widget_invalidate_cache(screen, WIDGET_CACHE_CLIENTS | WIDGET_CACHE_TAGS);
globalconf.screens[screen].need_arrange = True;
}
/** Toggle scratch client visibility
* \param screen screen number
* \param arg unused argument
* \ingroup ui_callback
*/
void
uicb_client_togglescratch(int screen __attribute__ ((unused)),
char *arg __attribute__ ((unused)))
{
if(globalconf.scratch.client)
{
globalconf.scratch.isvisible = !globalconf.scratch.isvisible;
globalconf.screens[globalconf.scratch.client->screen].need_arrange = True;
widget_invalidate_cache(globalconf.scratch.client->screen, WIDGET_CACHE_CLIENTS);
}
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -52,6 +52,8 @@ Uicb uicb_client_zoom;
Uicb uicb_client_focusnext; Uicb uicb_client_focusnext;
Uicb uicb_client_focusprev; Uicb uicb_client_focusprev;
Uicb uicb_client_togglefloating; Uicb uicb_client_togglefloating;
Uicb uicb_client_togglescratch;
Uicb uicb_client_setscratch;
DO_SLIST(Client, client, p_delete); DO_SLIST(Client, client, p_delete);

View File

@ -19,10 +19,6 @@
* *
*/ */
/**
* @defgroup ui_callback User Interface Callbacks
*/
#include <X11/keysym.h> #include <X11/keysym.h>
#include "config.h" #include "config.h"

View File

@ -314,6 +314,12 @@ struct AwesomeConf
Cursor cursor[CurLast]; Cursor cursor[CurLast];
/** Clients list */ /** Clients list */
Client *clients; Client *clients;
/** Scratch client */
struct
{
Client *client;
Bool isvisible;
} scratch;
/** Path to config file */ /** Path to config file */
char *configpath; char *configpath;
/** Selected clients history */ /** Selected clients history */

4
uicb.c
View File

@ -19,6 +19,10 @@
* *
*/ */
/**
* @defgroup ui_callback User Interface Callbacks
*/
#include "awesome.h" #include "awesome.h"
#include "xutil.h" #include "xutil.h"
#include "tag.h" #include "tag.h"

View File

@ -40,8 +40,9 @@ isoccupied(Tag *t)
Client *c; Client *c;
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(is_client_tagged(c, t) && !c->skip) if(is_client_tagged(c, t) && !c->skip && c != globalconf.scratch.client)
return True; return True;
return False; return False;
} }

View File

@ -142,7 +142,15 @@ tasklist_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
widget->font->height / 2, widget->font, c->name, widget->font->height / 2, widget->font, c->name,
d->fg, d->bg); d->fg, d->bg);
if(c->isfloating || c->ismax) if(c == globalconf.scratch.client)
{
area.x = widget->area.x + icon_width + box_width * i;
area.y = widget->area.y;
area.width = (widget->font->height + 2) / 3;
area.height = (widget->font->height + 2) / 3;
draw_rectangle(ctx, area, c->isfloating, d->fg);
}
else if(c->isfloating || c->ismax)
draw_circle(ctx, widget->area.x + icon_width + box_width * i, draw_circle(ctx, widget->area.x + icon_width + box_width * i,
widget->area.y, widget->area.y,
(widget->font->height + 2) / 4, (widget->font->height + 2) / 4,