diff options
-rw-r--r-- | main.c | 53 | ||||
-rw-r--r-- | ocm.h | 6 | ||||
-rw-r--r-- | utils.c | 6 | ||||
-rw-r--r-- | window.c | 27 |
4 files changed, 63 insertions, 29 deletions
@@ -12,7 +12,9 @@ * * - XRender, not OpenGL * - * - There is no theming + * - No theming + * + * - No workspaces. They are crack. * * - There is very little configuation */ @@ -45,19 +47,19 @@ get_time (ocm_app_t *app) static ocm_window_t * app_find_xwindow (ocm_app_t *app, Window xwindow) { - ocm_window_t *window = app->windows; + ocm_window_t *w; - while (window) + for (w = app->windows; w != NULL; w = w->next) { - if (window->xwindow == xwindow) - return window; - - window = window->next; + if (w->xwindow == xwindow) + return w; } + + return NULL; } static void -app_unmanage_xwindow (ocm_app_t *app, Window xwindow) +app_unmanage_window (ocm_app_t *app, Window xwindow) { ocm_window_t *prev, *window; @@ -81,24 +83,6 @@ app_unmanage_xwindow (ocm_app_t *app, Window xwindow) } } -static void -app_manage_window (ocm_app_t *app, Window window) -{ - XWindowAttributes attrs; - - XGrabServer (app->display); - - if (XGetWindowAttributes (app->display, window, &attrs)) - { - ocm_window_t *owindow = ocm_window_new (app, window); - - owindow->next = app->windows; - app->windows = owindow; - } - - XUngrabServer (app->display); -} - static Window create_offscreen_window (ocm_app_t *app) { @@ -236,17 +220,30 @@ ocm_app_new (int argc, char **argv) CWEventMask | CWOverrideRedirect | CWBackPixmap | CWBorderPixel, &attr); + app->wm_owner = create_offscreen_window (app); - app->cm_owner = create_offscreen_window (app); acquire_manager_selection (app, "WM_S0", app->wm_owner, replace); + + app->cm_owner = create_offscreen_window (app); acquire_manager_selection (app, "WM_CM_S0", app->cm_owner, replace); + + XCompositeRedirectSubwindows ( + app->display, app->root, CompositeRedirectManual); /* Now manage all the windows */ if (!XQueryTree (app->display, app->root, &r, &p, &children, &n_children)) ocm_error ("XQueryTree() failed"); for (i = 0; i < n_children; ++i) - app_manage_window (app, children[i]); + { + ocm_window_t *owindow = ocm_window_new (app, children[i]); + + if (owindow) + { + owindow->next = app->windows; + app->windows = owindow; + } + } if (children) XFree (children); @@ -48,6 +48,8 @@ struct ocm_window_t Window xwindow; ocm_window_t * next; + + Damage damage; }; /* window.c */ @@ -72,3 +74,7 @@ ocm_begin_ignore_errors (ocm_app_t *app); void ocm_end_ignore_errors (ocm_app_t *app); + +bool +ocm_window_owns_xwindow (ocm_window_t *window, + Window xwindow); @@ -28,6 +28,12 @@ ocm_malloc (size_t n) return mem; } +void +ocm_free (void *mem) +{ + free (mem); +} + static int ignore_errors (Display *dpy, XErrorEvent *event) { @@ -1,12 +1,37 @@ #include "ocm.h" +bool +ocm_window_owns_xwindow (ocm_window_t *window, Window xwindow) +{ + if (window->xwindow == xwindow) + return TRUE; + + return FALSE; +} + ocm_window_t * ocm_window_new (ocm_app_t *app, Window xwindow) { ocm_window_t *owindow = ocm_malloc (sizeof *owindow); + XWindowAttributes attrs; + + XGrabServer (app->display); + ocm_begin_ignore_errors (app); + + if (!XGetWindowAttributes (app->display, xwindow, &attrs)) + { + owindow = NULL; + goto out; + } owindow->app = app; owindow->xwindow = xwindow; + owindow->damage = XDamageCreate ( + app->display, owindow->xwindow, XDamageReportNonEmpty); + +out: + ocm_end_ignore_errors (app); + XUngrabServer (app->display); return owindow; } @@ -14,5 +39,5 @@ ocm_window_new (ocm_app_t *app, Window xwindow) void ocm_window_free (ocm_window_t *window) { - free (window); + ocm_free (window); } |