Re: Window border problems



On Sun, May 16, 2010 at 07:57:48PM +0400, Alexey I. Froloff wrote:
> The problem is - I don't see this border.  There's one-pixel
> space around window, but it looks transparent regardless of
> color.  I am stuck, can anyone help me?
LOL, XShapeCombineShape(3X) also affect border.

Please take a look at this patch.  set-window-border and
set-window-border-width might have to set flag to rebuild window
frame.  Also, id would be nice if border could be set from
theme.jl, not from hook.  It could also be turned into propeties
or frame attributes.  I'm not really familiar with sawfish
sources, maybe you can suggest something.

-- 
Regards,    --
Sir Raorn.   --- http://thousandsofhate.blogspot.com/
 src/events.c  |    2 +-
 src/frames.c  |   10 ++++++----
 src/sawfish.h |    3 +++
 src/windows.c |   44 ++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 50 insertions(+), 9 deletions(-)

diff --git a/src/events.c b/src/events.c
index 6daefd7..1d037fc 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1290,7 +1290,7 @@ send_synthetic_configure (Lisp_Window *w)
 	}
 	ev.xconfigure.width = w->attr.width;
 	ev.xconfigure.height = w->attr.height;
-	ev.xconfigure.border_width = w->attr.border_width;
+	ev.xconfigure.border_width = w->border_width;
 	ev.xconfigure.above = w->reparented ? w->frame : root_window;
 	ev.xconfigure.override_redirect = False;
 	XSendEvent (dpy, w->id, False, StructureNotifyMask, &ev);
diff --git a/src/frames.c b/src/frames.c
index 14e4d10..6fb7ba9 100644
--- a/src/frames.c
+++ b/src/frames.c
@@ -338,11 +338,11 @@ set_frame_shapes (Lisp_Window *w, bool atomic)
 	XSetWindowAttributes wa;
 	int wamask;
 	wa.colormap = image_cmap;
-	wa.border_pixel = BlackPixel (dpy, screen_num);
+	wa.border_pixel = w->border_pixel;
 	wamask = CWColormap | CWBorderPixel;
 	shape_win = XCreateWindow (dpy, root_window, -100, -100,
 				   w->frame_width, w->frame_height,
-				   0, image_depth, InputOutput,
+				   w->border_width, image_depth, InputOutput,
 				   image_visual, wamask, &wa);
     }
     else
@@ -1581,12 +1581,12 @@ list_frame_generator (Lisp_Window *w)
 
 	wa.override_redirect = True;
 	wa.colormap = colormap;
-	wa.border_pixel = BlackPixel (dpy, screen_num);
+	wa.border_pixel = w->border_pixel;
 	wa.save_under = w->attr.save_under;
 	wamask = CWOverrideRedirect | CWColormap | CWBorderPixel | CWSaveUnder;
 
 	w->frame = XCreateWindow (dpy, root_window, w->attr.x, w->attr.y,
-				  w->frame_width, w->frame_height, 0,
+				  w->frame_width, w->frame_height, w->border_width,
 				  depth, InputOutput, visual, wamask, &wa);
     }
     else
@@ -1595,6 +1595,8 @@ list_frame_generator (Lisp_Window *w)
 	w->attr.x += w->frame_x - old_x_off;
 	w->attr.y += w->frame_y - old_y_off;
 
+	XSetWindowBorder (dpy, w->frame, w->border_pixel);
+	XSetWindowBorderWidth (dpy, w->frame, w->border_width);
 	XMoveResizeWindow (dpy, w->frame, w->attr.x, w->attr.y,
 			   w->frame_width, w->frame_height);
 
diff --git a/src/sawfish.h b/src/sawfish.h
index 1a6fb7e..69162b8 100644
--- a/src/sawfish.h
+++ b/src/sawfish.h
@@ -142,6 +142,9 @@ typedef struct lisp_window {
        But the position is the position of the frame, while the
        dimensions are those of the client */
     XWindowAttributes attr;
+    unsigned int old_border_width;		/* saved border width of window */
+    unsigned int border_width;
+    unsigned long border_pixel;
     XSizeHints hints;
     XWMHints *wmhints;
     Window *cmap_windows;
diff --git a/src/windows.c b/src/windows.c
index 330f763..5b46c22 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -458,6 +458,7 @@ add_window (Window id)
 	w->name = rep_null_string ();
 	w->net_name = Qnil;
 	w->net_icon_name = Qnil;
+	w->border_pixel = BlackPixel (dpy, screen_num);
 
         /* Don't garbage collect the window before we are done. */
         /* Note: must not return without rep_POPGC. */
@@ -473,6 +474,7 @@ add_window (Window id)
 	XGetWindowAttributes (dpy, id, &w->attr);
 	DB(("  orig: width=%d height=%d x=%d y=%d\n",
 	    w->attr.width, w->attr.height, w->attr.x, w->attr.y));
+	w->old_border_width = w->attr.border_width;
 
 	get_window_name(w);
 
@@ -599,7 +601,7 @@ remove_window (Lisp_Window *w, bool destroyed, bool from_error)
 	    remove_window_frame (w);
 
 	    /* Restore original border width of the client */
-	    XSetWindowBorderWidth (dpy, w->id, w->attr.border_width);
+	    XSetWindowBorderWidth (dpy, w->id, w->old_border_width);
 	}
 
 	if (!from_error)
@@ -960,8 +962,8 @@ surrounding WINDOW.
     rep_DECLARE1(win, WINDOWP);
     if (VWIN(win)->reparented)
     {
-	return Fcons (rep_MAKE_INT(VWIN(win)->frame_width),
-		      rep_MAKE_INT(VWIN(win)->frame_height));
+	return Fcons (rep_MAKE_INT(VWIN(win)->frame_width + 2*VWIN(win)->border_width),
+		      rep_MAKE_INT(VWIN(win)->frame_height + 2*VWIN(win)->border_width));
     }
     else
 	return Fwindow_dimensions (win);
@@ -1255,6 +1257,38 @@ member of, or nil if it is not a member of a group.
 	    : Qnil);
 }
 
+/* FIXME */
+DEFUN("set-window-border", Fset_window_border, Sset_window_border,
+      (repv win, repv color), rep_Subr2) /*
+::doc:sawfish.wm.windows.subrs#set-window-border::
+set-window-border WINDOW COLOR
+::end:: */
+{
+    rep_DECLARE1(win, WINDOWP);
+    rep_DECLARE2(color, COLORP);
+
+    VWIN(win)->border_pixel = VCOLOR(color)->pixel;
+    DB(("  border_pixel=%d\n", VWIN(win)->border_pixel));
+
+    return win;
+}
+
+/* FIXME */
+DEFUN("set-window-border-width", Fset_window_border_width, Sset_window_border_width,
+      (repv win, repv width), rep_Subr2) /*
+::doc:sawfish.wm.windows.subrs#set-window-border-width::
+set-window-border-width WINDOW INTEGER
+::end:: */
+{
+    rep_DECLARE1(win, WINDOWP);
+    rep_DECLARE2(width, rep_INTEGERP);
+
+    VWIN(win)->border_width = rep_get_long_uint(width);
+    DB(("  border_width=%d\n", VWIN(win)->border_width));
+
+    return win;
+}
+
 DEFUN("window-border-width", Fwindow_border_width, Swindow_border_width,
       (repv win), rep_Subr1) /*
 ::doc:sawfish.wm.windows.subrs#window-border-width::
@@ -1262,7 +1296,7 @@ window-border-width WINDOW
 ::end:: */
 {
     rep_DECLARE1(win, WINDOWP);
-    return rep_MAKE_INT(VWIN(win)->attr.border_width);
+    return rep_MAKE_INT(VWIN(win)->border_width);
 }
 
 DEFUN("window-size-hints", Fwindow_size_hints, Swindow_size_hints,
@@ -1697,6 +1731,8 @@ windows_init (void)
     rep_ADD_SUBR(Swindow_group_id);
     rep_ADD_SUBR(Swindow_size_hints);
     rep_ADD_SUBR(Scall_window_hook);
+    rep_ADD_SUBR(Sset_window_border);
+    rep_ADD_SUBR(Sset_window_border_width);
     rep_ADD_SUBR(Swindow_border_width);
     rep_ADD_SUBR(Swindow_icon_image);
     rep_ADD_SUBR(Smap_windows);

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]