1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-01-01 19:42:32 +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

@@ -1,241 +1,211 @@
#include <X11/Xlib.h>
#include "WINGsP.h"
typedef struct W_IMContext {
XIM xim;
XIMStyle ximstyle;
XIM xim;
XIMStyle ximstyle;
} WMIMContext;
static void
instantiateIM_cb(Display *display, XPointer client_data, XPointer call_data)
static void instantiateIM_cb(Display * display, XPointer client_data, XPointer call_data)
{
W_InitIM((W_Screen *)client_data);
W_InitIM((W_Screen *) client_data);
}
static void
destroyIM_cb(XIM xim, XPointer client_data, XPointer call_data)
static void destroyIM_cb(XIM xim, XPointer client_data, XPointer call_data)
{
W_Screen *scr = (W_Screen *)client_data;
W_View *target;
W_Screen *scr = (W_Screen *) client_data;
W_View *target;
if (scr->imctx->xim != xim)
return;
if (scr->imctx->xim != xim)
return;
target = scr->rootView->childrenList;
while (target!=NULL) {
W_DestroyIC(target);
target = target->nextSister;
}
target = scr->rootView->childrenList;
while (target != NULL) {
W_DestroyIC(target);
target = target->nextSister;
}
wfree(scr->imctx);
scr->imctx = NULL;
wfree(scr->imctx);
scr->imctx = NULL;
XRegisterIMInstantiateCallback(scr->display, NULL, NULL, NULL,
instantiateIM_cb, (XPointer)scr);
XRegisterIMInstantiateCallback(scr->display, NULL, NULL, NULL, instantiateIM_cb, (XPointer) scr);
}
void
W_InitIM(W_Screen *scr)
void W_InitIM(W_Screen * scr)
{
XIM xim;
XIM xim;
if (scr->imctx)
return;
if (scr->imctx)
return;
xim = XOpenIM(scr->display, NULL, NULL, NULL);
xim = XOpenIM(scr->display, NULL, NULL, NULL);
if (xim) {
XIMStyles *im_styles;
XIMCallback cb;
int i;
if (xim) {
XIMStyles *im_styles;
XIMCallback cb;
int i;
scr->imctx = wmalloc(sizeof(WMIMContext));
scr->imctx->xim = xim;
scr->imctx = wmalloc(sizeof(WMIMContext));
scr->imctx->xim = xim;
cb.callback = destroyIM_cb;
cb.client_data = (XPointer)scr;
if (XSetIMValues(scr->imctx->xim, XNDestroyCallback, &cb, NULL))
wwarning("could not add destroy callback for input method");
XUnregisterIMInstantiateCallback(scr->display, NULL, NULL, NULL,
instantiateIM_cb, (XPointer)scr);
/* Get available input style */
XGetIMValues(scr->imctx->xim, XNQueryInputStyle, &im_styles, NULL);
cb.callback = destroyIM_cb;
cb.client_data = (XPointer) scr;
if (XSetIMValues(scr->imctx->xim, XNDestroyCallback, &cb, NULL))
wwarning("could not add destroy callback for input method");
XUnregisterIMInstantiateCallback(scr->display, NULL, NULL, NULL, instantiateIM_cb, (XPointer) scr);
/* Get available input style */
XGetIMValues(scr->imctx->xim, XNQueryInputStyle, &im_styles, NULL);
scr->imctx->ximstyle = 0;
scr->imctx->ximstyle = 0;
for (i=0; i<im_styles->count_styles && scr->imctx->ximstyle==0; i++) {
if ((im_styles->supported_styles[i] & XIMPreeditPosition) &&
(im_styles->supported_styles[i] & XIMStatusNothing)) {
scr->imctx->ximstyle = XIMPreeditPosition | XIMStatusNothing;
} else if ((im_styles->supported_styles[i] & XIMPreeditNothing) &&
(im_styles->supported_styles[i] & XIMStatusNothing)) {
scr->imctx->ximstyle = XIMPreeditNothing | XIMStatusNothing;
}
}
XFree(im_styles);
} else {
XRegisterIMInstantiateCallback(scr->display, NULL, NULL, NULL,
instantiateIM_cb, (XPointer)scr);
}
for (i = 0; i < im_styles->count_styles && scr->imctx->ximstyle == 0; i++) {
if ((im_styles->supported_styles[i] & XIMPreeditPosition) &&
(im_styles->supported_styles[i] & XIMStatusNothing)) {
scr->imctx->ximstyle = XIMPreeditPosition | XIMStatusNothing;
} else if ((im_styles->supported_styles[i] & XIMPreeditNothing) &&
(im_styles->supported_styles[i] & XIMStatusNothing)) {
scr->imctx->ximstyle = XIMPreeditNothing | XIMStatusNothing;
}
}
XFree(im_styles);
} else {
XRegisterIMInstantiateCallback(scr->display, NULL, NULL, NULL, instantiateIM_cb, (XPointer) scr);
}
}
void
W_CreateIC(WMView *view)
void W_CreateIC(WMView * view)
{
WMScreen *scr = W_VIEW_SCREEN(view);
XVaNestedList preedit_attr = NULL;
WMScreen *scr = W_VIEW_SCREEN(view);
XVaNestedList preedit_attr = NULL;
if (view->xic || !view->flags.realized || !scr->imctx)
return;
if (view->xic || !view->flags.realized || !scr->imctx)
return;
if (scr->imctx->ximstyle & XIMPreeditPosition) {
XPoint spot;
XRectangle rect;
int ofs;
if (scr->imctx->ximstyle & XIMPreeditPosition) {
XPoint spot;
XRectangle rect;
int ofs;
ofs = (view->size.height - WMFontHeight(scr->normalFont))/2;
ofs = (view->size.height - WMFontHeight(scr->normalFont)) / 2;
rect.x = ofs;
rect.y = ofs;
rect.height = WMFontHeight(scr->normalFont);
rect.width = view->size.width - ofs*2;
spot.x = rect.x;
spot.y = rect.y + rect.height;
rect.x = ofs;
rect.y = ofs;
rect.height = WMFontHeight(scr->normalFont);
rect.width = view->size.width - ofs * 2;
spot.x = rect.x;
spot.y = rect.y + rect.height;
// this really needs to be changed, but I don't know how yet -Dan
// it used to be like this with fontsets, but no longer applies to xft
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot,
XNArea, &rect, XNFontInfo,
scr->normalFont->font, NULL);
}
// this really needs to be changed, but I don't know how yet -Dan
// it used to be like this with fontsets, but no longer applies to xft
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot,
XNArea, &rect, XNFontInfo, scr->normalFont->font, NULL);
}
view->xic = XCreateIC(scr->imctx->xim, XNInputStyle, scr->imctx->ximstyle,
XNClientWindow, view->window,
preedit_attr ? XNPreeditAttributes : NULL, preedit_attr,
NULL);
view->xic = XCreateIC(scr->imctx->xim, XNInputStyle, scr->imctx->ximstyle,
XNClientWindow, view->window,
preedit_attr ? XNPreeditAttributes : NULL, preedit_attr, NULL);
if (preedit_attr)
XFree(preedit_attr);
if (preedit_attr)
XFree(preedit_attr);
if (view->xic) {
unsigned long fevent = 0;
XGetICValues(view->xic, XNFilterEvents, &fevent, NULL);
XSelectInput(scr->display, view->window,
ButtonPressMask | ButtonReleaseMask | ExposureMask |
KeyPressMask | FocusChangeMask| ButtonMotionMask |fevent);
}
if (view->xic) {
unsigned long fevent = 0;
XGetICValues(view->xic, XNFilterEvents, &fevent, NULL);
XSelectInput(scr->display, view->window,
ButtonPressMask | ButtonReleaseMask | ExposureMask |
KeyPressMask | FocusChangeMask | ButtonMotionMask | fevent);
}
}
void
W_DestroyIC(WMView *view)
void W_DestroyIC(WMView * view)
{
if (view->xic) {
XDestroyIC(view->xic);
view->xic = 0;
}
if (view->xic) {
XDestroyIC(view->xic);
view->xic = 0;
}
}
static void
setPreeditArea(W_View *view)
static void setPreeditArea(W_View * view)
{
WMScreen *scr = W_VIEW_SCREEN(view);
XVaNestedList preedit_attr = NULL;
WMScreen *scr = W_VIEW_SCREEN(view);
XVaNestedList preedit_attr = NULL;
if (view->xic && (scr->imctx->ximstyle & XIMPreeditPosition)) {
XRectangle rect;
int ofs;
if (view->xic && (scr->imctx->ximstyle & XIMPreeditPosition)) {
XRectangle rect;
int ofs;
ofs = (view->size.height - WMFontHeight(scr->normalFont))/2;
rect.x = ofs;
rect.y = ofs;
rect.height = WMFontHeight(scr->normalFont);
rect.width = view->size.width - ofs*2;
ofs = (view->size.height - WMFontHeight(scr->normalFont)) / 2;
rect.x = ofs;
rect.y = ofs;
rect.height = WMFontHeight(scr->normalFont);
rect.width = view->size.width - ofs * 2;
preedit_attr = XVaCreateNestedList(0, XNArea, &rect, NULL);
XSetICValues(view->xic, XNPreeditAttributes, preedit_attr, NULL);
preedit_attr = XVaCreateNestedList(0, XNArea, &rect, NULL);
XSetICValues(view->xic, XNPreeditAttributes, preedit_attr, NULL);
if (preedit_attr) {
XFree(preedit_attr);
}
}
if (preedit_attr) {
XFree(preedit_attr);
}
}
}
void
W_FocusIC(WMView *view)
void W_FocusIC(WMView * view)
{
WMScreen *scr = W_VIEW_SCREEN(view);
WMScreen *scr = W_VIEW_SCREEN(view);
if (view->xic) {
XSetICFocus(view->xic);
XSetICValues(view->xic, XNFocusWindow, view->window, NULL);
if (view->xic) {
XSetICFocus(view->xic);
XSetICValues(view->xic, XNFocusWindow, view->window, NULL);
if (scr->imctx->ximstyle & XIMPreeditPosition) {
setPreeditArea(view);
}
}
if (scr->imctx->ximstyle & XIMPreeditPosition) {
setPreeditArea(view);
}
}
}
void
W_UnFocusIC(WMView *view)
void W_UnFocusIC(WMView * view)
{
if (view->xic) {
XUnsetICFocus(view->xic);
}
if (view->xic) {
XUnsetICFocus(view->xic);
}
}
void
W_SetPreeditPositon(W_View *view, int x, int y)
void W_SetPreeditPositon(W_View * view, int x, int y)
{
WMScreen *scr = W_VIEW_SCREEN(view);
XVaNestedList preedit_attr = NULL;
WMScreen *scr = W_VIEW_SCREEN(view);
XVaNestedList preedit_attr = NULL;
if (view->xic && (scr->imctx->ximstyle & XIMPreeditPosition)) {
XPoint spot;
int ofs;
if (view->xic && (scr->imctx->ximstyle & XIMPreeditPosition)) {
XPoint spot;
int ofs;
ofs = (view->size.height - WMFontHeight(scr->normalFont))/2;
spot.x = x;
spot.y = y + view->size.height - ofs - 3;
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
XSetICValues(view->xic, XNPreeditAttributes, preedit_attr, NULL);
if (preedit_attr) {
XFree(preedit_attr);
}
}
ofs = (view->size.height - WMFontHeight(scr->normalFont)) / 2;
spot.x = x;
spot.y = y + view->size.height - ofs - 3;
preedit_attr = XVaCreateNestedList(0, XNSpotLocation, &spot, NULL);
XSetICValues(view->xic, XNPreeditAttributes, preedit_attr, NULL);
if (preedit_attr) {
XFree(preedit_attr);
}
}
}
int
W_LookupString(W_View *view, XKeyPressedEvent *event, char *buffer, int buflen,
KeySym *keysym, Status *status)
W_LookupString(W_View * view, XKeyPressedEvent * event, char *buffer, int buflen, KeySym * keysym, Status * status)
{
WMScreen *scr = W_VIEW_SCREEN(view);
WMScreen *scr = W_VIEW_SCREEN(view);
XSetInputFocus(scr->display, view->window, RevertToParent, CurrentTime);
XSetInputFocus(scr->display, view->window, RevertToParent, CurrentTime);
if (view->xic) {
if (view->xic) {
#ifdef X_HAVE_UTF8_STRING
return Xutf8LookupString(view->xic, event, buffer, buflen, keysym, status);
return Xutf8LookupString(view->xic, event, buffer, buflen, keysym, status);
#else
return XLookupString(event, buffer, buflen, keysym, (XComposeStatus *)status);
return XLookupString(event, buffer, buflen, keysym, (XComposeStatus *) status);
#endif
} else {
return XLookupString(event, buffer, buflen, keysym, (XComposeStatus *)status);
}
} else {
return XLookupString(event, buffer, buflen, keysym, (XComposeStatus *) status);
}
}