1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-02-04 15:25:52 +01:00

changed indentation to use spaces only

This commit is contained in:
dan
2004-10-12 21:28:27 +00:00
parent 5912898b06
commit 6830b05716
240 changed files with 35951 additions and 35773 deletions

View File

@@ -1,9 +1,9 @@
/* appmenu.c- application defined menu
*
* Window Maker window manager
*
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
@@ -57,10 +57,10 @@ typedef struct {
enum {
wmBeginMenu = 1,
wmEndMenu = 2,
wmNormalItem = 10,
wmDoubleItem = 11,
wmSubmenuItem = 12
wmEndMenu = 2,
wmNormalItem = 10,
wmDoubleItem = 11,
wmSubmenuItem = 12
};
enum {
@@ -87,11 +87,11 @@ sendMessage(Window window, int what, int tag)
}
static void
static void
notifyClient(WMenu *menu, WMenuEntry *entry)
{
WAppMenuData *data = entry->clientdata;
sendMessage(data->window, wmSelectItem, data->tag);
}
@@ -107,123 +107,123 @@ parseMenuCommand(WScreen *scr, Window win, char **slist, int count, int *index)
char rtext[300];
if (strlen(slist[*index])>300) {
wwarning("appmenu: menu command size exceeded in window %x", win);
return NULL;
wwarning("appmenu: menu command size exceeded in window %x", win);
return NULL;
}
if (sscanf(slist[*index], "%i %i %n", &command, &code, &pos)<2
|| command!=wmBeginMenu) {
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
|| command!=wmBeginMenu) {
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
menu = wMenuCreateForApp(scr, title, *index==1);
if (!menu)
return NULL;
return NULL;
*index += 1;
while (*index<count) {
int ecode, etag, enab;
int ecode, etag, enab;
if (sscanf(slist[*index], "%i", &command)!=1) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
if (command==wmEndMenu) {
*index += 1;
break;
} else if (command==wmNormalItem
|| command==wmDoubleItem) {
WAppMenuData *data;
WMenuEntry *entry;
if (sscanf(slist[*index], "%i", &command)!=1) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
if (command == wmNormalItem) {
if (sscanf(slist[*index], "%i %i %i %i %n",
&command, &ecode, &etag, &enab, &pos)!=4
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
rtext[0] = 0;
} else {
if (sscanf(slist[*index], "%i %i %i %i %s %n",
&command, &ecode, &etag, &enab, rtext, &pos)!=5
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
}
if (!(data = malloc(sizeof(WAppMenuData)))) {
wwarning("appmenu: out of memory making menu for window %x",
win);
wMenuDestroy(menu, True);
return NULL;
}
data->code = code;
data->tag = etag;
data->window = win;
entry = wMenuAddCallback(menu, title, notifyClient, data);
if (!entry) {
wMenuDestroy(menu, True);
wwarning("appmenu: out of memory creating menu for window %x",
slist[*index], win);
wfree(data);
return NULL;
}
if (rtext[0]!=0)
entry->rtext = wstrdup(rtext);
else
entry->rtext = NULL;
entry->free_cdata = free;
*index += 1;
if (command==wmEndMenu) {
*index += 1;
break;
} else if (command==wmSubmenuItem) {
int ncode;
WMenuEntry *entry;
WMenu *submenu;
} else if (command==wmNormalItem
|| command==wmDoubleItem) {
WAppMenuData *data;
WMenuEntry *entry;
if (sscanf(slist[*index], "%i %i %i %i %i %n",
&command, &ecode, &etag, &enab, &ncode, &pos)!=5
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
if (command == wmNormalItem) {
if (sscanf(slist[*index], "%i %i %i %i %n",
&command, &ecode, &etag, &enab, &pos)!=4
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
rtext[0] = 0;
} else {
if (sscanf(slist[*index], "%i %i %i %i %s %n",
&command, &ecode, &etag, &enab, rtext, &pos)!=5
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
strcpy(title, &slist[*index][pos]);
}
if (!(data = malloc(sizeof(WAppMenuData)))) {
wwarning("appmenu: out of memory making menu for window %x",
win);
wMenuDestroy(menu, True);
return NULL;
}
data->code = code;
data->tag = etag;
data->window = win;
entry = wMenuAddCallback(menu, title, notifyClient, data);
if (!entry) {
wMenuDestroy(menu, True);
wwarning("appmenu: out of memory creating menu for window %x",
slist[*index], win);
wfree(data);
return NULL;
}
if (rtext[0]!=0)
entry->rtext = wstrdup(rtext);
else
entry->rtext = NULL;
entry->free_cdata = free;
*index += 1;
return NULL;
}
strcpy(title, &slist[*index][pos]);
*index += 1;
} else if (command==wmSubmenuItem) {
int ncode;
WMenuEntry *entry;
WMenu *submenu;
submenu = parseMenuCommand(scr, win, slist, count, index);
if (sscanf(slist[*index], "%i %i %i %i %i %n",
&command, &ecode, &etag, &enab, &ncode, &pos)!=5
|| ecode!=code) {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
entry = wMenuAddCallback(menu, title, NULL, NULL);
if (!entry) {
wMenuDestroy(menu, True);
wMenuDestroy(submenu, True);
wwarning("appmenu: out of memory creating menu for window %x",
slist[*index], win);
return NULL;
}
return NULL;
}
strcpy(title, &slist[*index][pos]);
*index += 1;
wMenuEntrySetCascade(menu, entry, submenu);
} else {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
}
submenu = parseMenuCommand(scr, win, slist, count, index);
entry = wMenuAddCallback(menu, title, NULL, NULL);
if (!entry) {
wMenuDestroy(menu, True);
wMenuDestroy(submenu, True);
wwarning("appmenu: out of memory creating menu for window %x",
slist[*index], win);
return NULL;
}
wMenuEntrySetCascade(menu, entry, submenu);
} else {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
}
return menu;
}
@@ -236,37 +236,37 @@ wAppMenuGet(WScreen *scr, Window window)
int count, i;
char **slist;
WMenu *menu;
if (!XGetTextProperty(dpy, window, &text_prop, _XA_WINDOWMAKER_MENU)) {
return NULL;
return NULL;
}
if (!XTextPropertyToStringList(&text_prop, &slist, &count) || count<1) {
XFree(text_prop.value);
return NULL;
XFree(text_prop.value);
return NULL;
}
XFree(text_prop.value);
if (strcmp(slist[0], "WMMenu 0")!=0) {
wwarning("appmenu: unknown version of WMMenu in window %x: %s",
window, slist[0]);
XFreeStringList(slist);
return NULL;
wwarning("appmenu: unknown version of WMMenu in window %x: %s",
window, slist[0]);
XFreeStringList(slist);
return NULL;
}
i = 1;
menu = parseMenuCommand(scr, window, slist, count, &i);
if (menu)
menu->parent = NULL;
menu->parent = NULL;
XFreeStringList(slist);
return menu;
}
void
wAppMenuDestroy(WMenu *menu)
wAppMenuDestroy(WMenu *menu)
{
if (menu)
wMenuDestroy(menu, True);
wMenuDestroy(menu, True);
}
@@ -276,12 +276,12 @@ mapmenus(WMenu *menu)
int i;
if (menu->flags.mapped)
XMapWindow(dpy, menu->frame->core->window);
XMapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XMapWindow(dpy, menu->brother->frame->core->window);
XMapWindow(dpy, menu->brother->frame->core->window);
for (i=0; i<menu->cascade_no; i++) {
if (menu->cascades[i])
mapmenus(menu->cascades[i]);
if (menu->cascades[i])
mapmenus(menu->cascades[i]);
}
}
@@ -291,25 +291,25 @@ wAppMenuMap(WMenu *menu, WWindow *wwin)
{
if (!menu)
return;
return;
if (!menu->flags.mapped) {
wMenuMap(menu);
wMenuMap(menu);
}
if(wwin && (wPreferences.focus_mode!=WKF_CLICK)) {
int x, min;
int x, min;
min = 20; /* Keep at least 20 pixels visible */
if (wwin->frame_x > min) {
x = wwin->frame_x - menu->frame->core->width;
}
else {
x = min - menu->frame->core->width;
}
wMenuMove(menu, x, wwin->frame_y, True);
if (wwin->frame_x > min) {
x = wwin->frame_x - menu->frame->core->width;
}
else {
x = min - menu->frame->core->width;
}
wMenuMove(menu, x, wwin->frame_y, True);
}
mapmenus(menu);
}
@@ -317,14 +317,14 @@ static void
unmapmenus(WMenu *menu)
{
int i;
if (menu->flags.mapped)
XUnmapWindow(dpy, menu->frame->core->window);
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XUnmapWindow(dpy, menu->brother->frame->core->window);
XUnmapWindow(dpy, menu->brother->frame->core->window);
for (i=0; i<menu->cascade_no; i++) {
if (menu->cascades[i])
unmapmenus(menu->cascades[i]);
if (menu->cascades[i])
unmapmenus(menu->cascades[i]);
}
}
@@ -332,6 +332,6 @@ void
wAppMenuUnmap(WMenu *menu)
{
if (menu)
unmapmenus(menu);
unmapmenus(menu);
}