1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Change to the linux kernel coding style

for arq in `git ls-files *.c`; do
    echo $arq;
    indent -linux -l115 $arq;
    done

The different line break at 115 columns is because
I use a widescreen monitor :-)
This commit is contained in:
Carlos R. Mafra
2009-08-20 00:59:40 +02:00
parent 59fc927dc9
commit 688a56e8ab
209 changed files with 87034 additions and 98138 deletions

View File

@@ -39,7 +39,6 @@
#include "framewin.h"
/******** Global Variables **********/
extern Atom _XA_WINDOWMAKER_MENU;
extern Atom _XA_WINDOWMAKER_WM_PROTOCOLS;
@@ -48,290 +47,256 @@ extern Time LastTimestamp;
extern WPreferences wPreferences;
typedef struct {
short code;
short tag;
Window window;
short code;
short tag;
Window window;
} WAppMenuData;
enum {
wmBeginMenu = 1,
wmEndMenu = 2,
wmNormalItem = 10,
wmDoubleItem = 11,
wmSubmenuItem = 12
wmBeginMenu = 1,
wmEndMenu = 2,
wmNormalItem = 10,
wmDoubleItem = 11,
wmSubmenuItem = 12
};
enum {
wmSelectItem = 1
wmSelectItem = 1
};
static void
sendMessage(Window window, int what, int tag)
static void sendMessage(Window window, int what, int tag)
{
XEvent event;
XEvent event;
event.xclient.type = ClientMessage;
event.xclient.message_type = _XA_WINDOWMAKER_MENU;
event.xclient.format = 32;
event.xclient.display = dpy;
event.xclient.window = window;
event.xclient.data.l[0] = LastTimestamp;
event.xclient.data.l[1] = what;
event.xclient.data.l[2] = tag;
event.xclient.data.l[3] = 0;
XSendEvent(dpy, window, False, NoEventMask, &event);
XFlush(dpy);
event.xclient.type = ClientMessage;
event.xclient.message_type = _XA_WINDOWMAKER_MENU;
event.xclient.format = 32;
event.xclient.display = dpy;
event.xclient.window = window;
event.xclient.data.l[0] = LastTimestamp;
event.xclient.data.l[1] = what;
event.xclient.data.l[2] = tag;
event.xclient.data.l[3] = 0;
XSendEvent(dpy, window, False, NoEventMask, &event);
XFlush(dpy);
}
static void
notifyClient(WMenu *menu, WMenuEntry *entry)
static void notifyClient(WMenu * menu, WMenuEntry * entry)
{
WAppMenuData *data = entry->clientdata;
WAppMenuData *data = entry->clientdata;
sendMessage(data->window, wmSelectItem, data->tag);
sendMessage(data->window, wmSelectItem, data->tag);
}
static WMenu*
parseMenuCommand(WScreen *scr, Window win, char **slist, int count, int *index)
static WMenu *parseMenuCommand(WScreen * scr, Window win, char **slist, int count, int *index)
{
WMenu *menu;
int command;
int code, pos;
char title[300];
char rtext[300];
WMenu *menu;
int command;
int code, pos;
char title[300];
char rtext[300];
if (strlen(slist[*index])>300) {
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;
}
strcpy(title, &slist[*index][pos]);
menu = wMenuCreateForApp(scr, title, *index==1);
if (!menu)
return NULL;
*index += 1;
while (*index<count) {
int ecode, etag, enab;
if (strlen(slist[*index]) > 300) {
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;
}
strcpy(title, &slist[*index][pos]);
menu = wMenuCreateForApp(scr, title, *index == 1);
if (!menu)
return NULL;
*index += 1;
while (*index < count) {
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 (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;
if (command == wmEndMenu) {
*index += 1;
break;
} else if (command==wmNormalItem
|| command==wmDoubleItem) {
WAppMenuData *data;
WMenuEntry *entry;
} else if (command == wmNormalItem || command == wmDoubleItem) {
WAppMenuData *data;
WMenuEntry *entry;
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 == 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;
} else if (command==wmSubmenuItem) {
int ncode;
WMenuEntry *entry;
WMenu *submenu;
} else if (command == wmSubmenuItem) {
int ncode;
WMenuEntry *entry;
WMenu *submenu;
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 (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);
return NULL;
}
strcpy(title, &slist[*index][pos]);
*index += 1;
return NULL;
}
strcpy(title, &slist[*index][pos]);
*index += 1;
submenu = parseMenuCommand(scr, win, slist, count, index);
submenu = parseMenuCommand(scr, win, slist, count, index);
entry = wMenuAddCallback(menu, title, NULL, NULL);
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;
}
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);
wMenuEntrySetCascade(menu, entry, submenu);
} else {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x",
slist[*index], win);
return NULL;
}
}
} else {
wMenuDestroy(menu, True);
wwarning("appmenu: bad menu entry \"%s\" in window %x", slist[*index], win);
return NULL;
}
}
return menu;
return menu;
}
WMenu*
wAppMenuGet(WScreen *scr, Window window)
WMenu *wAppMenuGet(WScreen * scr, Window window)
{
XTextProperty text_prop;
int count, i;
char **slist;
WMenu *menu;
XTextProperty text_prop;
int count, i;
char **slist;
WMenu *menu;
if (!XGetTextProperty(dpy, window, &text_prop, _XA_WINDOWMAKER_MENU)) {
return NULL;
}
if (!XTextPropertyToStringList(&text_prop, &slist, &count) || count<1) {
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;
}
if (!XGetTextProperty(dpy, window, &text_prop, _XA_WINDOWMAKER_MENU)) {
return NULL;
}
if (!XTextPropertyToStringList(&text_prop, &slist, &count) || count < 1) {
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;
}
i = 1;
menu = parseMenuCommand(scr, window, slist, count, &i);
if (menu)
menu->parent = NULL;
i = 1;
menu = parseMenuCommand(scr, window, slist, count, &i);
if (menu)
menu->parent = NULL;
XFreeStringList(slist);
XFreeStringList(slist);
return menu;
return menu;
}
void
wAppMenuDestroy(WMenu *menu)
void wAppMenuDestroy(WMenu * menu)
{
if (menu)
wMenuDestroy(menu, True);
if (menu)
wMenuDestroy(menu, True);
}
static void
mapmenus(WMenu *menu)
static void mapmenus(WMenu * menu)
{
int i;
int i;
if (menu->flags.mapped)
XMapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
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->flags.mapped)
XMapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XMapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
mapmenus(menu->cascades[i]);
}
}
void
wAppMenuMap(WMenu *menu, WWindow *wwin)
void wAppMenuMap(WMenu * menu, WWindow * wwin)
{
if (!menu)
return;
if (!menu)
return;
if (!menu->flags.mapped) {
wMenuMap(menu);
}
if(wwin && (wPreferences.focus_mode!=WKF_CLICK)) {
int x, min;
if (!menu->flags.mapped) {
wMenuMap(menu);
}
if (wwin && (wPreferences.focus_mode != WKF_CLICK)) {
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);
}
mapmenus(menu);
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);
}
mapmenus(menu);
}
static void
unmapmenus(WMenu *menu)
static void unmapmenus(WMenu * menu)
{
int i;
int i;
if (menu->flags.mapped)
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
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->flags.mapped)
XUnmapWindow(dpy, menu->frame->core->window);
if (menu->brother->flags.mapped)
XUnmapWindow(dpy, menu->brother->frame->core->window);
for (i = 0; i < menu->cascade_no; i++) {
if (menu->cascades[i])
unmapmenus(menu->cascades[i]);
}
}
void
wAppMenuUnmap(WMenu *menu)
void wAppMenuUnmap(WMenu * menu)
{
if (menu)
unmapmenus(menu);
if (menu)
unmapmenus(menu);
}