1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

show workspace name when changing workspace

This commit is contained in:
kojima
1999-04-17 18:24:23 +00:00
parent 57f0f4b245
commit b147e8f85c
13 changed files with 276 additions and 105 deletions

View File

@@ -676,10 +676,8 @@ iconDblClick(WObjDescriptor *desc, XEvent *event)
return;
}
#endif /* REDUCE_APPICONS */
#if 0
/* aproveita que ta aqui pra atualizar */
wapp->main_window = aicon->icon->owner->main_window;
#endif
printf("%i\n",wapp->refcount);
unhideHere = (event->xbutton.state & ShiftMask);

View File

@@ -184,10 +184,13 @@ Restart(char *manager)
}
}
}
if (dpy) {
#ifdef XSMP_ENABLED
wSessionDisconnectManager();
wSessionDisconnectManager();
#endif
XCloseDisplay(dpy);
XCloseDisplay(dpy);
dpy = NULL;
}
if (!prog)
execvp(Arguments[0], Arguments);
else {

View File

@@ -155,7 +155,6 @@ alreadyRunningError(Display *dpy, XErrorEvent *error)
* not be freed by anybody.
*----------------------------------------------------------------------
*/
#ifndef NEWSTUFF
static void
allocButtonPixmaps(WScreen *scr)
{
@@ -182,8 +181,6 @@ allocButtonPixmaps(WScreen *scr)
pix->shared = 1;
scr->b_pixmaps[WBUT_KILL] = pix;
}
#endif
static void
@@ -366,7 +363,13 @@ allocGCs(WScreen *scr)
/* misc drawing GC */
gcv.graphics_exposures = False;
gcm = GCGraphicsExposures;
scr->draw_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv);
scr->draw_gc = XCreateGC(dpy, scr->w_win, gcm, &gcv);
assert (scr->stipple_bitmap!=None);
/* mono GC */
scr->mono_gc = XCreateGC(dpy, scr->stipple_bitmap, gcm, &gcv);
}
@@ -538,6 +541,19 @@ createInternalWindows(WScreen *scr)
CopyFromParent, scr->w_visual, vmask, &attribs);
/* workspace name */
vmask = CWBackPixel|CWSaveUnder|CWOverrideRedirect|CWColormap
|CWBorderPixel;
attribs.save_under = True;
attribs.override_redirect = True;
attribs.colormap = scr->w_colormap;
attribs.background_pixel = scr->icon_back_texture->normal.pixel;
attribs.border_pixel = 0; /* do not care */
scr->workspace_name =
XCreateWindow(dpy, scr->root_win, 0, 0, 10, 10, 0, scr->w_depth,
CopyFromParent, scr->w_visual, vmask, &attribs);
/* for our window manager info notice board */
scr->info_window =
XCreateWindow(dpy, scr->root_win, 0, 0, 10, 10, 0, CopyFromParent,
@@ -758,6 +774,8 @@ wScreenInit(int screen_number)
scr->frame_border_pixel = xcol.pixel;
}
scr->workspace_name_font = wLoadFont(DEF_WORKSPACE_NAME_FONT);
/* create GCs with default values */
allocGCs(scr);

View File

@@ -152,6 +152,7 @@ typedef struct _WScreen {
WFont *clip_title_font; /* for clip titles */
WFont *info_text_font; /* text on things like geometry
* hint boxes */
WFont *workspace_name_font;
WMPixel select_pixel;
WMPixel select_text_pixel;
@@ -192,13 +193,16 @@ typedef struct _WScreen {
GC select_menu_gc; /* selected menu entries */
GC disabled_menu_entry_gc; /* disabled menu entries */
GC info_text_gc; /* for size/position display */
GC icon_select_gc;
GC workspace_name_gc; /* for the name shown when workspace
* is changed */
GC frame_gc; /* gc for resize/move frame (root) */
GC line_gc; /* gc for drawing XORed lines (root) */
GC copy_gc; /* gc for XCopyArea() */
GC stipple_gc; /* gc for stippled filling */
GC icon_select_gc;
GC draw_gc; /* gc for drawing misc things */
GC mono_gc; /* gc for 1 bit drawables */
#ifndef NEWSTUFF
struct WPixmap *b_pixmaps[PRED_BPIXMAPS]; /* internal pixmaps for buttons*/
@@ -270,7 +274,12 @@ typedef struct _WScreen {
/* balloon help data */
struct _WBalloon *balloon;
/* workspace name data */
Window workspace_name;
WMHandlerID *workspace_name_timer;
struct WorkspaceNameData *workspace_name_data;
/* for raise-delay */
WMHandlerID *autoRaiseTimer;
Window autoRaiseWindow; /* window that is scheduled to be

View File

@@ -565,3 +565,4 @@ InitGhostWindowMove(WScreen *scr)
}
#endif /* GHOST_WINDOW_MOVE */

View File

@@ -69,7 +69,8 @@ typedef struct {
static void
notifyClient(WMenu *menu, WMenuEntry *entry){
notifyClient(WMenu *menu, WMenuEntry *entry)
{
XEvent event;
WUserMenuData *data = entry->clientdata;
WScreen *scr = data->screen;
@@ -78,7 +79,7 @@ notifyClient(WMenu *menu, WMenuEntry *entry){
window=scr->focused_window->client_win;
for(i=0;i<data->key_no;i++){
for(i=0;i<data->key_no;i++) {
event.xkey.type = KeyPress;
event.xkey.display = dpy;
event.xkey.window = window;
@@ -99,7 +100,8 @@ notifyClient(WMenu *menu, WMenuEntry *entry){
}
static void
removeUserMenudata(void *menudata){
removeUserMenudata(void *menudata)
{
WUserMenuData *data = menudata;
if(data->key) free(data->key);
free(data);
@@ -107,7 +109,8 @@ removeUserMenudata(void *menudata){
static WUserMenuData*
convertShortcuts(WScreen *scr, proplist_t shortcut){
convertShortcuts(WScreen *scr, proplist_t shortcut)
{
WUserMenuData *data;
KeySym ksym;
char *k;
@@ -115,10 +118,10 @@ convertShortcuts(WScreen *scr, proplist_t shortcut){
char buf[128], *b;
int keycount,i,j,mod;
if (PLIsString(shortcut)){
if (PLIsString(shortcut)) {
keycount = 1;
}
else if (PLIsArray(shortcut)){
else if (PLIsArray(shortcut)) {
keycount = PLGetNumberOfElements(shortcut);
}
else return NULL;
@@ -137,8 +140,7 @@ convertShortcuts(WScreen *scr, proplist_t shortcut){
data->key[j].modifier = 0;
if (PLIsArray(shortcut)) {
strcpy(buf, PLGetString(PLGetArrayElement(shortcut, i)));
}
else {
} else {
strcpy(buf, PLGetString(shortcut));
}
b = (char*)buf;
@@ -180,7 +182,8 @@ keyover:
}
static WMenu*
configureUserMenu(WScreen *scr, proplist_t plum){
configureUserMenu(WScreen *scr, proplist_t plum)
{
char *mtitle;
WMenu *menu=NULL;
proplist_t elem, title, command, params;
@@ -188,7 +191,7 @@ configureUserMenu(WScreen *scr, proplist_t plum){
WUserMenuData *data;
if (!plum) return NULL;
if (!PLIsArray(plum)){
if (!PLIsArray(plum)) {
return NULL;
}
@@ -196,7 +199,7 @@ configureUserMenu(WScreen *scr, proplist_t plum){
if (!count) return NULL;
elem = PLGetArrayElement(plum, 0);
if (!PLIsString(elem)){
if (!PLIsString(elem)) {
return NULL;
}
@@ -204,9 +207,9 @@ configureUserMenu(WScreen *scr, proplist_t plum){
menu=wMenuCreateForApp(scr, mtitle, True);
for(i=1; i<count; i++){
for(i=1; i<count; i++) {
elem = PLGetArrayElement(plum,i);
if(PLIsArray(PLGetArrayElement(elem,1))){
if(PLIsArray(PLGetArrayElement(elem,1))) {
WMenu *submenu;
WMenuEntry *mentry;
@@ -228,7 +231,7 @@ configureUserMenu(WScreen *scr, proplist_t plum){
if (!title || !command)
return menu;
if (!strcmp("SHORTCUT",PLGetString(command))){
if (!strcmp("SHORTCUT",PLGetString(command))) {
WMenuEntry *entry;
data = convertShortcuts(scr, params);
@@ -242,12 +245,12 @@ configureUserMenu(WScreen *scr, proplist_t plum){
}
entry->free_cdata = removeUserMenudata;
if (PLGetNumberOfElements(elem) >= 4){
if (PLGetNumberOfElements(elem) >= 4) {
instances = PLGetArrayElement(elem,idx++);
if(PLIsArray(instances))
if (instances && PLGetNumberOfElements(instances)
&& PLIsArray(instances)){
entry->instances = PLRetain(instances);
if (instances && PLGetNumberOfElements(instances)
&& PLIsArray(instances)){
entry->instances = PLRetain(instances);
}
}
}
@@ -278,9 +281,9 @@ wUserMenuRefreshInstances(WMenu *menu, WWindow *wwin)
oldflag = menu->entries[i]->flags.enabled;
menu->entries[i]->flags.enabled = 0;
for (j=0; j<count;j++){
for (j=0; j<count;j++) {
ins = PLGetArrayElement(menu->entries[i]->instances,j);
if (!strcmp(wwin->wm_instance,PLGetString(ins))){
if (!strcmp(wwin->wm_instance,PLGetString(ins))) {
menu->entries[i]->flags.enabled = 1;
break;
}
@@ -291,12 +294,12 @@ wUserMenuRefreshInstances(WMenu *menu, WWindow *wwin)
}
for (i=0; i < menu->cascade_no; i++) {
if (!menu->cascades[i]->flags.brother)
wUserMenuRefreshInstances(menu->cascades[i], wwin);
wUserMenuRefreshInstances(menu->cascades[i], wwin);
else
wUserMenuRefreshInstances(menu->cascades[i]->brother, wwin);
wUserMenuRefreshInstances(menu->cascades[i]->brother, wwin);
}
if(paintflag)
if (paintflag)
wMenuPaint(menu);
}
@@ -322,7 +325,8 @@ readUserMenuFile(WScreen *scr, char *file_name)
WMenu*
wUserMenuGet(WScreen *scr, WWindow *wwin){
wUserMenuGet(WScreen *scr, WWindow *wwin)
{
WMenu *menu = NULL;
char buffer[100];
char *path = NULL;

View File

@@ -299,13 +299,17 @@
#define DEF_ICON_TITLE_FONT "\"-*-*-medium-r-normal--10-*\""
#define DEF_CLIP_TITLE_FONT "\"-*-*-medium-r-normal--10-*\""
#define DEF_INFO_TEXT_FONT "\"-*-*-medium-r-normal--14-*\""
#else /* I18N_MB */
#define DEF_WORKSPACE_NAME_FONT "-*-*-medium-r-normal--24-*"
#else /* !I18N_MB */
#define DEF_TITLE_FONT "\"-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*\""
#define DEF_MENU_TITLE_FONT "\"-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*-*\""
#define DEF_MENU_ENTRY_FONT "\"-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*\""
#define DEF_ICON_TITLE_FONT "\"-*-helvetica-medium-r-normal-*-8-*-*-*-*-*-*-*\""
#define DEF_CLIP_TITLE_FONT "\"-*-helvetica-bold-r-normal-*-10-*-*-*-*-*-*-*\""
#define DEF_INFO_TEXT_FONT "\"-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*\""
#define DEF_WORKSPACE_NAME_FONT "-*-times-bold-i-normal--24-*"
#endif /* !I18N_MB */
#define HELVETICA10_FONT "-*-helvetica-medium-r-normal-*-10-*-*-*-*-*-*-*"

View File

@@ -23,6 +23,10 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef SHAPE
#include <X11/extensions/shape.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
@@ -220,15 +224,185 @@ wWorkspaceDelete(WScreen *scr, int workspace)
}
typedef struct WorkspaceNameData {
int count;
RImage *back;
RImage *text;
} WorkspaceNameData;
static void
hideWorkpaceName(void *data)
{
WScreen *scr = (WScreen*)data;
if (!scr->workspace_name_data || scr->workspace_name_data->count == 0) {
XUnmapWindow(dpy, scr->workspace_name);
if (scr->workspace_name_data) {
RDestroyImage(scr->workspace_name_data->back);
RDestroyImage(scr->workspace_name_data->text);
free(scr->workspace_name_data);
scr->workspace_name_data = NULL;
}
scr->workspace_name_timer = NULL;
} else {
RImage *img = RCloneImage(scr->workspace_name_data->back);
Pixmap pix;
RCombineImagesWithOpaqueness(img, scr->workspace_name_data->text,
scr->workspace_name_data->count*255/10);
RConvertImage(scr->rcontext, img, &pix);
RDestroyImage(img);
XSetWindowBackgroundPixmap(dpy, scr->workspace_name, pix);
XClearWindow(dpy, scr->workspace_name);
XFreePixmap(dpy, pix);
XFlush(dpy);
scr->workspace_name_data->count--;
scr->workspace_name_timer = WMAddTimerHandler(40, hideWorkpaceName,
scr);
}
}
static void
showWorkspaceName(WScreen *scr, int workspace)
{
WorkspaceNameData *data;
RXImage *ximg;
Pixmap text, mask;
int w, h;
char *name = scr->workspaces[workspace]->name;
int len = strlen(name);
int x, y;
if (scr->workspace_name_timer) {
WMDeleteTimerHandler(scr->workspace_name_timer);
XUnmapWindow(dpy, scr->workspace_name);
XFlush(dpy);
}
if (scr->workspace_name_data) {
RDestroyImage(scr->workspace_name_data->back);
RDestroyImage(scr->workspace_name_data->text);
free(scr->workspace_name_data);
}
#ifndef I18N_MB
XSetFont(dpy, scr->mono_gc, scr->workspace_name_font->font->fid);
XSetFont(dpy, scr->draw_gc, scr->workspace_name_font->font->fid);
#endif
data = wmalloc(sizeof(WorkspaceNameData));
w = wTextWidth(scr->workspace_name_font->font, name, len);
h = scr->workspace_name_font->height;
XResizeWindow(dpy, scr->workspace_name, w+4, h+4);
XMoveWindow(dpy, scr->workspace_name, (scr->scr_width - (w+4))/2,
(scr->scr_height - (h+4))/2);
text = XCreatePixmap(dpy, scr->w_win, w+4, h+4, scr->w_depth);
mask = XCreatePixmap(dpy, scr->w_win, w+4, h+4, 1);
XSetForeground(dpy, scr->draw_gc, scr->black_pixel);
XFillRectangle(dpy, text, scr->draw_gc, 0, 0, w+4, h+4);
XSetForeground(dpy, scr->mono_gc, 0);
XFillRectangle(dpy, mask, scr->mono_gc, 0, 0, w+4, h+4);
XSetForeground(dpy, scr->mono_gc, 1);
for (x = 0; x <= 4; x++) {
for (y = 0; y <= 4; y++) {
wDrawString(mask, scr->workspace_name_font, scr->mono_gc,
x, scr->workspace_name_font->y + y, name, len);
}
}
XSetForeground(dpy, scr->draw_gc, scr->white_pixel);
wDrawString(text, scr->workspace_name_font, scr->draw_gc,
2, scr->workspace_name_font->y + 2,
scr->workspaces[workspace]->name,
strlen(scr->workspaces[workspace]->name));
#ifdef SHAPE
XShapeCombineMask(dpy, scr->workspace_name, ShapeBounding, 0, 0, mask,
ShapeSet);
#endif
XSetWindowBackgroundPixmap(dpy, scr->workspace_name, text);
XClearWindow(dpy, scr->workspace_name);
data->text = RCreateImageFromDrawable(scr->rcontext, text, None);
XFreePixmap(dpy, text);
XFreePixmap(dpy, mask);
if (!data->text) {
XMapRaised(dpy, scr->workspace_name);
XFlush(dpy);
goto erro;
}
ximg = RGetXImage(scr->rcontext, scr->root_win,
(scr->scr_width - data->text->width)/2,
(scr->scr_height - data->text->height)/2,
data->text->width, data->text->height);
if (!ximg) {
goto erro;
}
XMapRaised(dpy, scr->workspace_name);
XFlush(dpy);
data->back = RCreateImageFromXImage(scr->rcontext, ximg->image, NULL);
RDestroyXImage(scr->rcontext, ximg);
if (!data->back) {
goto erro;
}
data->count = 10;
scr->workspace_name_data = data;
scr->workspace_name_timer = WMAddTimerHandler(200, hideWorkpaceName, scr);
return;
erro:
if (data->text)
RDestroyImage(data->text);
if (data->back)
RDestroyImage(data->back);
free(data);
scr->workspace_name_data = NULL;
scr->workspace_name_timer = WMAddTimerHandler(600, hideWorkpaceName, scr);
}
void
wWorkspaceChange(WScreen *scr, int workspace)
{
if (scr->flags.startup || scr->flags.startup2) {
return;
}
if (workspace != scr->current_workspace) {
wWorkspaceForceChange(scr, workspace);
} else {
showWorkspaceName(scr, workspace);
}
}
@@ -395,6 +569,8 @@ wWorkspaceForceChange(WScreen *scr, int workspace)
}
}
showWorkspaceName(scr, workspace);
#ifdef GNOME_STUFF
wGNOMEUpdateCurrentWorkspaceHint(scr);
#endif