all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* GTK pixmap background support?
@ 2003-08-13 11:04 Miles Bader
  2003-08-14 16:30 ` Jan D.
  0 siblings, 1 reply; 3+ messages in thread
From: Miles Bader @ 2003-08-13 11:04 UTC (permalink / raw)
  Cc: emacs-devel

Hi,

I've been working on my pixmap background patch for emacs, and have run
into a slight bad interaction with the GTK toolkit support; I think it
can be worked around, but would like to see if it's possible to solve
it more cleanly.

Basically, when emacs sets the default background color, it this (in
src/xfns.c):

   void
   x_set_background_color (f, arg, oldval)
   {
     ...
         XSetWindowBackground (dpy, FRAME_X_WINDOW (f), bg);
     ...
   #ifdef USE_GTK
         xg_set_background_color (f, bg);
   #endif
     ...
   }

`xg_set_background_color' looks like this:

   xg_set_background_color (f, bg)
   {
     ...
        gtk_widget_modify_bg (FRAME_GTK_WIDGET (f), GTK_STATE_NORMAL, &gdk_bg);
     ...
   }

This means that calls to XClear*, and exposures, will start out with the
correct background color, and emacs need only worry about changing other
things.  When using the GTK toolkit, GTK itself apparently uses
XSetWindowBackground for its own purposes, but the xg_set_background gives
GTK enough info to keep things basically how emacs likes.

However, with pixmap backgrounds, I want to use `XSetWindowBackgroundPixmap'
instead -- but there doesn't appear to be any equivalent call to
`gtk_widget_modify_bg' that takes a pixmap instead of a color!  So you can
see the problem:  even though I've done a XSetWindowBackgroundPixmap, GTK
will at some point set the window background to a color, and there doesn't
seem to be any way to tell it not to, so clears/exposures come out
incorrectly.

As it happens, I think I have to support more complete redrawing modes in
emacs anyway (for more complicated background tiling than just simple
frame-relative pixmaps), but it would be nice to be able to use the native X
calls when possible, as it's more efficient, and probably going to be less
buggy for a while... :-)

So can you see any possible GTK solution to this qunadary?  I thought maybe
it would possible to do something tricky by consing up a theme or something,
but that seems rather hairy and certainly beyond my limited experience.

Thanks,

-Miles
-- 
.Numeric stability is probably not all that important when you're guessing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GTK pixmap background support?
  2003-08-13 11:04 GTK pixmap background support? Miles Bader
@ 2003-08-14 16:30 ` Jan D.
  2003-08-18  6:42   ` Miles Bader
  0 siblings, 1 reply; 3+ messages in thread
From: Jan D. @ 2003-08-14 16:30 UTC (permalink / raw)
  Cc: emacs-devel

> This means that calls to XClear*, and exposures, will start out with 
> the
> correct background color, and emacs need only worry about changing 
> other
> things.  When using the GTK toolkit, GTK itself apparently uses
> XSetWindowBackground for its own purposes, but the xg_set_background 
> gives
> GTK enough info to keep things basically how emacs likes.

Yes, since the display engine in Emacs uses X calls, GTK must be kept
in sync so it doesn't mess things up.

>
> However, with pixmap backgrounds, I want to use 
> `XSetWindowBackgroundPixmap'
> instead -- but there doesn't appear to be any equivalent call to
> `gtk_widget_modify_bg' that takes a pixmap instead of a color!  So you 
> can
> see the problem:  even though I've done a XSetWindowBackgroundPixmap, 
> GTK
> will at some point set the window background to a color, and there 
> doesn't
> seem to be any way to tell it not to, so clears/exposures come out
> incorrectly.
>
> As it happens, I think I have to support more complete redrawing modes 
> in
> emacs anyway (for more complicated background tiling than just simple
> frame-relative pixmaps), but it would be nice to be able to use the 
> native X
> calls when possible, as it's more efficient, and probably going to be 
> less
> buggy for a while... :-)
>
> So can you see any possible GTK solution to this qunadary?  I thought 
> maybe
> it would possible to do something tricky by consing up a theme or 
> something,
> but that seems rather hairy and certainly beyond my limited experience.

I have no solution to this.  I disabled setting of a background pixmap
by GTK themes because of the problems you are seeing.  I suspect you
need to look at the GTK (or rather GDK) code to see exactly what it
is doing, and how Emacs can work with it.

In general you set a background pixmap with styles.  If you look at
xg_create_frame_widgets (near the end) in gtkutil.c, you can see how
it is disabled.  By setting bg_pixmap in a GtkStyle to a suitable
GdkPixmap, and the apply the style to the widget, you can set a 
background
pixmap for the GTK widget.

	Jan D.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: GTK pixmap background support?
  2003-08-14 16:30 ` Jan D.
@ 2003-08-18  6:42   ` Miles Bader
  0 siblings, 0 replies; 3+ messages in thread
From: Miles Bader @ 2003-08-18  6:42 UTC (permalink / raw)
  Cc: emacs-devel

"Jan D." <jan.h.d@swipnet.se> writes:
> I have no solution to this.  I disabled setting of a background pixmap
> by GTK themes because of the problems you are seeing.  I suspect you
> need to look at the GTK (or rather GDK) code to see exactly what it
> is doing, and how Emacs can work with it.
> 
> In general you set a background pixmap with styles.  If you look at
> xg_create_frame_widgets (near the end) in gtkutil.c, you can see how
> it is disabled.  By setting bg_pixmap in a GtkStyle to a suitable
> GdkPixmap, and the apply the style to the widget, you can set a
> background pixmap for the GTK widget.

Hmmm, I suppose I ought to look at what libvte does, since it also
allows background pixmaps.

My workaround of simply never using XClearArea works reasonably well,
but there's occasionally a bit of flickering for large area scrolls
(though I do set the gtk bg color to something `compatible' with the
pixmap to reduce it as much as possible).

-Miles
-- 
Fast, small, soon; pick any 2.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-08-18  6:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-13 11:04 GTK pixmap background support? Miles Bader
2003-08-14 16:30 ` Jan D.
2003-08-18  6:42   ` Miles Bader

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.