diff --git a/app.c b/app.c index 82c157f..ad4d44e 100644 --- a/app.c +++ b/app.c @@ -59,7 +59,7 @@ int appInit(App *app, const char *touch_dev) { app->dpy, app->root, // display and parent window app->x, app->y, app->w, app->h, 0, // position, size and border width CopyFromParent, CopyFromParent, CopyFromParent, // depth, class and visual - CWOverrideRedirect, &attr); // mask with attributes + CWOverrideRedirect, &attr ); // mask with attributes XSelectInput( app->dpy, app->win, @@ -69,6 +69,13 @@ int appInit(App *app, const char *touch_dev) { | ButtonReleaseMask | Button1MotionMask ); + #if defined(NOBORDER) || defined(DOCK) + LOGDBG("app: init: disable decorations"); + Atom amh = XInternAtom(app->dpy, "_MOTIF_WM_HINTS", False); + long amhv[5] = { 2 }; + XChangeProperty(app->dpy, app->win, amh, amh, 32, PropModeReplace, (unsigned char*)amhv, 5); + #endif + #ifndef NOBORDER LOGDBG("app: init: set window title"); char *title = TITLE; @@ -81,18 +88,19 @@ int appInit(App *app, const char *touch_dev) { } #endif - #if !defined(NOBORDER) && defined(DOCK) + #ifdef DOCK LOGDBG("app: init: set window as dock"); Atom awt = XInternAtom(app->dpy, "_NET_WM_WINDOW_TYPE", False); Atom awtv = XInternAtom(app->dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); - if (awt != None && awtv != None) - XChangeProperty(app->dpy, app->win, awt, XA_ATOM, 32, PropModeReplace, (unsigned char*)&awtv, 1); + XChangeProperty(app->dpy, app->win, awt, XA_ATOM, 32, PropModeReplace, (unsigned char*)&awtv, 1); + Atom aaa = XInternAtom(app->dpy, "_NET_WM_ALLOWED_ACTIONS", False); + XChangeProperty(app->dpy, app->win, aaa, XA_ATOM, 32, PropModeReplace, NULL, 0); #endif - Atom ahps = XInternAtom(app->dpy, "_HILDON_PORTRAIT_MODE_SUPPORT", False); + Atom ahps = XInternAtom(app->dpy, "_HILDON_PORTRAIT_MODE_SUPPORT", True); if (ahps) { LOGDBG("app: init: set portrait mode support for hildon"); - unsigned int v = 1; + long v = 1; XChangeProperty(app->dpy, app->win, ahps, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&v, 1); } @@ -143,6 +151,9 @@ int appInit(App *app, const char *touch_dev) { } #endif + //appMove(app, app->x, app->y, app->w, app->h, 1); + //appUpdateStrut(app); + // init submodules touchInit(&app->touch, app, touch_dev); // touch is optional if (graphInit(&app->graph, app)) { @@ -180,10 +191,8 @@ int appRun(App *app) { LOGDBG("app: run: show window"); XMapWindow(app->dpy, app->win); - XFlush(app->dpy); - appUpdateStrut(app); - XFlush(app->dpy); + appMove(app, app->x, app->y, app->w, app->h, 1); LOGDBG("app: run: get connection file descriptor"); int fd = ConnectionNumber(app->dpy); @@ -282,8 +291,8 @@ int appRun(App *app) { app->y = event.xconfigure.y; app->w = event.xconfigure.width; app->h = event.xconfigure.height; - //appUpdateStrut(app); if (resized) graphResize(&app->graph); + appUpdateStrut(app); } break; } @@ -293,6 +302,7 @@ int appRun(App *app) { if (!buttonDown) { buttonDown = 1; buttonDownMs = monotonicMs(); } keyboardMouseDown(&app->keyboard, event.xbutton.x, event.xbutton.y); } + appUpdateStrut(app); break; } case ButtonRelease: { @@ -384,11 +394,13 @@ void appStop(App *app, int err) { void appUpdateStrut(App *app) { - unsigned int v[12] = {0, 0, 0, 0, 0, app->sh, 0, app->sh, 0, app->sw, 0, app->sw}; - #ifdef DOCK - if (app->y == 0) v[2] = app->h; else - if (app->y + app->h == app->sh) v[3] = app->h; + long v[12] = { 0, 0, 0, app->h, 0, app->sh, 0, app->sh, 0, app->sw, 0, app->sw }; + + #ifdef TOP + v[2] = app->h; + #else + v[3] = app->h; #endif if (app->dockt == v[2] && app->dockb == v[3]) @@ -396,15 +408,20 @@ void appUpdateStrut(App *app) { app->dockt = v[2]; app->dockb = v[3]; - LOGDBG("app: update strut: %u %u %u %u", v[0], v[1], v[2], v[3]); + LOGDBG("app: update strut: %lu %lu %lu %lu", v[0], v[1], v[2], v[3]); Atom k = XInternAtom(app->dpy, "_NET_WM_STRUT", False); - if (k != None) - XChangeProperty(app->dpy, app->win, k, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)v, 4); + XChangeProperty(app->dpy, app->win, k, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)v, 4); - k = XInternAtom(app->dpy, "_NET_WM_STRUT_PARTIAL", False); - if (k != None) - XChangeProperty(app->dpy, app->win, k, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)v, 12); + Atom kp = XInternAtom(app->dpy, "_NET_WM_STRUT_PARTIAL", False); + XChangeProperty(app->dpy, app->win, kp, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)v, 12); + + #ifdef TOP + appMove(app, 0, 0, app->sw, app->h, 1); + #else + appMove(app, 0, app->sh - app->h, app->sw, app->h, 1); + #endif + #endif // DOCK } @@ -465,23 +482,23 @@ void appUpdateScreenSize(App *app, int sw, int sh, Rotation sr) { app->sw = sw; app->sh = sh; - appMove(app, x0, y0, w, h); + appMove(app, x0, y0, w, h, 0); } -void appMove(App *app, int x, int y, int w, int h) { - LOGDBG("app: move: x=%d, y=%d, w=%d, h=%d", x, y, w, h); +void appMove(App *app, int x, int y, int w, int h, int force) { if (w < MIN_WIDTH) w = MIN_WIDTH; if (h < MIN_HEIGHT) h = MIN_HEIGHT; unsigned int mask = 0; XWindowChanges ch = {}; - if (app->x != x) ch.x = x, mask |= CWX; - if (app->y != y) ch.y = y, mask |= CWY; - if (app->w != w) ch.width = w, mask |= CWWidth; - if (app->h != h) ch.height = h, mask |= CWHeight; + if (force || app->x != x) ch.x = x, mask |= CWX; + if (force || app->y != y) ch.y = y, mask |= CWY; + if (force || app->w != w) ch.width = w, mask |= CWWidth; + if (force || app->h != h) ch.height = h, mask |= CWHeight; if (!mask) return; + LOGDBG("app: move: x=%d, y=%d, w=%d, h=%d", x, y, w, h); XConfigureWindow(app->dpy, app->win, mask, &ch); XFlush(app->dpy); } diff --git a/app.h b/app.h index 00b2eb9..b071a8c 100644 --- a/app.h +++ b/app.h @@ -43,7 +43,7 @@ int appRun(App *app); void appStop(App *app, int err); void appUpdateStrut(App *app); void appUpdateScreenSize(App *app, int sw, int sh, Rotation sr); -void appMove(App *app, int x, int y, int w, int h); +void appMove(App *app, int x, int y, int w, int h, int force); void appInvalidateRect(App *app, int x, int y, int w, int h); diff --git a/keyboard.c b/keyboard.c index 5bea302..f8adda5 100644 --- a/keyboard.c +++ b/keyboard.c @@ -138,13 +138,13 @@ void keyMotion(Key *k, int x, int y) { return keyMotion(k->orig, x, y); App *app = k->l->kbd->app; if (k->flags & KF_MOVE) { - appMove(app, app->x + x - k->mx, app->y + y - k->my, app->w, app->h); + appMove(app, app->x + x - k->mx, app->y + y - k->my, app->w, app->h, 0); } else if (k->flags & KF_SIZE) { #ifdef TOP_RESIZE - appMove(app, app->x, app->y - k->my + y, app->w, app->h + k->my - y); + appMove(app, app->x, app->y - k->my + y, app->w, app->h + k->my - y, 0); #else - appMove(app, app->x, app->y, x + k->mx, y + k->my); + appMove(app, app->x, app->y, x + k->mx, y + k->my, 0); #endif } } @@ -390,7 +390,7 @@ int keyboardInit(Keyboard *kbd, App *app) { } } - //appMove(app, app->x, app->y, kbd->ow, kbd->oh); + //appMove(app, app->x, app->y, kbd->ow, kbd->oh, 0); return 1; }