DRAWS!!
authorDana Jansens <danakj@orodu.net>
Tue, 27 May 2003 04:32:53 +0000 (04:32 +0000)
committerDana Jansens <danakj@orodu.net>
Tue, 27 May 2003 04:32:53 +0000 (04:32 +0000)
openbox/event.c
openbox/menu.c
openbox/popup.c
render2/Makefile.am
render2/instance.c
render2/instance.h
render2/paint.c
render2/render.h
render2/surface.c

index 19beeae66202d38408dd7f1212e707f8b4d60324..ff3a2f83440771fb3d33029c6fe7ff9821eb5b37 100644 (file)
@@ -427,6 +427,13 @@ static void event_process(XEvent *e)
     Menu *menu = NULL;
     ObWindow *obwin = NULL;
 
+    /* expose events aren't related to any internal stuff */
+    if (e->type == Expose) {
+        if (ob_state != State_Exiting)
+            RrExpose(ob_render_inst, &e->xexpose);
+        return;
+    }
+
     window = event_get_window(e);
     if ((obwin = g_hash_table_lookup(window_map, &window))) {
         switch (obwin->type) {
index 41b0d749b9dbe6b0a7d30e85b5862da3d56b92a6..83546cca65641cbd9df7f0041633cccccc6f1e76 100644 (file)
@@ -8,11 +8,11 @@
 
 GHashTable *menu_hash = NULL;
 
-#define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask | \
-                        LeaveWindowMask)
-#define TITLE_EVENTMASK (ButtonPressMask | ButtonMotionMask)
+#define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask |\
+                        LeaveWindowMask | ExposureMask)
+#define TITLE_EVENTMASK (ButtonPressMask | ButtonMotionMask | ExposureMask)
 #define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \
-                         ButtonPressMask | ButtonReleaseMask)
+                         ButtonPressMask | ButtonReleaseMask | ExposureMask)
 
 void menu_control_show(Menu *self, int x, int y, Client *client);
 
index 22b1c230b6651b7551ef1cb0d1b7ed95e2857924..ee69a5197597c8d3153f3eaec36338fae9d8251c 100644 (file)
@@ -30,6 +30,7 @@ Popup *popup_new(gboolean hasicon)
 {
     XSetWindowAttributes attrib;
     Popup *self;
+    struct RrColor pri, sec;
 
     self = g_new(Popup, 1);
     self->obwin.type = Window_Internal;
@@ -40,10 +41,11 @@ Popup *popup_new(gboolean hasicon)
     stacking_raise(INTERNAL_AS_WINDOW(self));
 
     attrib.override_redirect = True;
+    attrib.event_mask = ExposureMask;
     self->bg = XCreateWindow(ob_display, ob_root,
                              0, 0, 1, 1, 0, RrInstanceDepth(ob_render_inst),
                              InputOutput, RrInstanceVisual(ob_render_inst),
-                             CWOverrideRedirect, &attrib);
+                             CWEventMask|CWOverrideRedirect, &attrib);
     self->s_bg = RrSurfaceNew(ob_render_inst, RR_SURFACE_PLANAR, self->bg, 0);
     self->s_text = RrSurfaceNewChild(RR_SURFACE_PLANAR, self->s_bg, 1);
     self->text = RrSurfaceWindow(self->s_text);
@@ -55,6 +57,18 @@ Popup *popup_new(gboolean hasicon)
         self->icon = None;
     }
 
+    RrColorSet(&pri, 1, 0, 0, 0);
+    RrColorSet(&pri, 0, 1, 0, 0);
+    RrPlanarSet(self->s_bg, RR_PLANAR_VERTICAL, &pri, &sec);
+    RrColorSet(&pri, 0, 0.5, 0, 1);
+    RrColorSet(&pri, 0.5, 0, 0.5, 1);
+    RrPlanarSet(self->s_text, RR_PLANAR_HORIZONTAL, &pri, &sec);
+    if (self->s_icon) {
+        RrColorSet(&pri, 0, 0, 1, 1);
+        RrColorSet(&pri, 0.5, 0.5, 0, 1);
+        RrPlanarSet(self->s_icon, RR_PLANAR_HORIZONTAL, &pri, &sec);
+    }
+
     /* XXX COPY THE APPEARANCES FROM THE THEME...... LIKE THIS SORTA!
     self->a_text = appearance_copy(theme_app_hilite_label);
     */
@@ -188,12 +202,16 @@ void popup_show(Popup *self, char *text, Icon *icon)
     if (!RrSurfaceVisible(self->s_bg)) {
         RrSurfaceShow(self->s_bg);
         stacking_raise(INTERNAL_AS_WINDOW(self));
+    } else {
+        /* XXX only need to paint top level surface in the future */
+        RrPaint(self->s_bg);
+        RrPaint(self->s_text);
+        if (self->s_icon)
+            RrPaint(self->s_icon);
     }
 }
 
 void popup_hide(Popup *self)
 {
-    if (RrSurfaceVisible(self->s_bg)) {
-        RrSurfaceHide(self->s_bg);
-    }
+    RrSurfaceHide(self->s_bg);
 }
index 36a3c081fe4a935375a7d829120336182bfbe317..6be6282cf6efdcaf3e68724b5f53232417ba6a42 100644 (file)
@@ -8,7 +8,7 @@ CPPFLAGS=$(FC_CFLAGS) $(GLIB_CFLAGS) $(GL_CFLAGS) @CPPFLAGS@ \
          -DTHEMEDIR=\"$(themedir)\"
 
 INCLUDES=-I..
-LIBS=$(GL_LIBS) @LIBS@
+LIBS=$(GL_LIBS) $(GLIB_LIBS) @LIBS@
 
 noinst_PROGRAMS=rendertest
 rendertest_LDFLAGS=-lobrender2 -L.
index f48593c312fb5181d3b07165c42cbf7e4f7baf9b..b2abb3dd41f351d7c5404c4ae10205879467dbb0 100644 (file)
@@ -1,4 +1,5 @@
 #include "instance.h"
+#include "surface.h"
 #include "debug.h"
 #include "glft/glft.h"
 #include <stdlib.h>
@@ -96,6 +97,7 @@ struct RrInstance *RrInstanceNew(Display *display, int screen)
                                      RrVisual(inst), AllocNone);
         inst->glx_context = glXCreateContext(display, &vilist[best],
                                              NULL, True);
+        inst->surface_map = g_hash_table_new(g_int_hash, g_int_equal);
 
         assert(inst->glx_context);
 
@@ -129,3 +131,18 @@ Visual *RrInstanceVisual(struct RrInstance *inst)
 {
     return inst->visinfo.visual;
 }
+
+void RrInstaceAddSurface(struct RrSurface *sur)
+{
+    g_hash_table_replace(RrSurfaceInstance(sur)->surface_map, &sur->win, sur);
+}
+
+void RrInstaceRemoveSurface(struct RrSurface *sur)
+{
+    g_hash_table_remove(RrSurfaceInstance(sur)->surface_map, &sur->win);
+}
+
+struct RrSurface *RrInstaceLookupSurface(struct RrInstance *inst, Window win)
+{
+    return g_hash_table_lookup(inst->surface_map, &win);
+}
index 94b194ab6e227372870bc8a40a035821aca794f2..c41a96af66d9f8290f719f2dbc4bc5b9df896220 100644 (file)
@@ -5,12 +5,16 @@
 #include <X11/Xutil.h>
 #include <GL/glx.h>
 
+#include <glib.h>
+
 struct RrInstance {
     Display *display;
     int screen;
     XVisualInfo visinfo;
     Colormap cmap;
     GLXContext glx_context;
+
+    GHashTable *surface_map;
 };
 
 #define RrDisplay(i)  ((i)->display)
@@ -24,4 +28,10 @@ struct RrInstance {
 #define RrColormap(i) ((i)->cmap)
 #define RrContext(i)  ((i)->glx_context)
 
+struct RrSurface;
+
+void RrInstaceAddSurface(struct RrSurface *sur);
+void RrInstaceRemoveSurface(struct RrSurface *sur);
+struct RrSurface *RrInstaceLookupSurface(struct RrInstance *inst, Window win);
+
 #endif
index acbe89305fea341a54758894b9d823c9f0734ebf..426c136d9632cd176767717fe251cbe6a9547a35 100644 (file)
@@ -5,6 +5,17 @@
 #include <assert.h>
 #include <GL/glx.h>
 
+void RrExpose(struct RrInstance *inst, XExposeEvent *e)
+{
+    struct RrSurface *sur;
+
+    if ((sur = RrInstaceLookupSurface(inst, e->window))) {
+        RrPaintArea(sur, e->x, e->y, e->width, e->height);
+    } else {
+        RrDebug("Unable to find surface for window 0x%lx\n", e->window);
+    }
+}
+
 /*! Paints the surface, and all its children */
 void RrPaint(struct RrSurface *sur)
 {
index 5ced991b06a77bf73c1f241cf33640cc89561e1e..719427f33225a66b06167bd009b06c0751cd08db 100644 (file)
@@ -196,5 +196,6 @@ void RrPaintArea(struct RrSurface *sur,
                  int y,
                  int w,
                  int h);
+void RrExpose(struct RrInstance *inst, XExposeEvent *e);
 
 #endif
index 3bad5ced6777774b0f7d0a03af0e428c5a3ef6e4..263af69aa6048777fefc85726d0e8f8a16ae6783 100644 (file)
@@ -28,9 +28,13 @@ static struct RrSurface *surface_new(enum RrSurfaceType type,
 
 static Window create_window(struct RrInstance *inst, Window parent)
 {
-    Window win = XCreateWindow(RrDisplay(inst), parent, 0, 0, 1, 1, 0,
-                               RrDepth(inst), InputOutput, RrVisual(inst),
-                               0, NULL);
+    XSetWindowAttributes attrib;
+    Window win;
+
+    attrib.event_mask = ExposureMask;
+    win = XCreateWindow(RrDisplay(inst), parent, 0, 0, 1, 1, 0,
+                        RrDepth(inst), InputOutput, RrVisual(inst),
+                        CWEventMask, &attrib);
     return win;
 }
 
@@ -59,6 +63,8 @@ struct RrSurface *RrSurfaceNew(struct RrInstance *inst,
     sur->win = win;
     sur->parent = NULL;
     sur->visible = 0;
+
+    RrInstaceAddSurface(sur);
     return sur;
 }
 
@@ -77,6 +83,8 @@ struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type,
     sur->win = create_window(sur->inst, parent->win);
     sur->parent = parent;
     RrSurfaceShow(sur);
+
+    RrInstaceAddSurface(sur);
     return sur;
 }
 
@@ -115,6 +123,8 @@ struct RrSurface *RrSurfaceCopy(struct RrInstance *inst,
     sur->win = win;
     sur->parent = NULL;
     sur->visible = 0;
+
+    RrInstaceAddSurface(sur);
     return sur;
 }
 
@@ -132,6 +142,8 @@ struct RrSurface *RrSurfaceCopyChild(struct RrSurface *orig,
     sur->win = create_window(sur->inst, parent->win);
     sur->parent = parent;
     RrSurfaceShow(sur);
+
+    RrInstaceAddSurface(sur);
     return sur;
 }
 
@@ -139,6 +151,7 @@ void RrSurfaceFree(struct RrSurface *sur)
 {
     int i;
     if (sur) {
+        RrInstaceRemoveSurface(sur);
         for (i = 0; i < sur->ntextures; ++i)
             RrTextureFreeContents(&sur->texture[i]);
         if (sur->ntextures)
@@ -198,6 +211,7 @@ void RrSurfaceMinSize(struct RrSurface *sur, int *w, int *h)
         break;
     }
 
+    minw = minh = 0;
     for (i = 0; i < sur->ntextures; ++i) {
         switch (sur->texture[i].type) {
         case RR_TEXTURE_NONE: