mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backing out d883ab4b8f41:7540abc35c97
This commit is contained in:
parent
b2f92eae66
commit
02e6b86b3b
@ -84,11 +84,8 @@ MOZ_CHROME_FILE_FORMAT = @MOZ_CHROME_FILE_FORMAT@
|
||||
|
||||
MOZ_WIDGET_TOOLKIT = @MOZ_WIDGET_TOOLKIT@
|
||||
MOZ_GFX_TOOLKIT = @MOZ_GFX_TOOLKIT@
|
||||
MOZ_DFB = @MOZ_DFB@
|
||||
MOZ_X11 = @MOZ_X11@
|
||||
|
||||
MOZ_PANGO = @MOZ_PANGO@
|
||||
|
||||
MOZ_JS_LIBS = @MOZ_JS_LIBS@
|
||||
|
||||
MOZ_DEBUG = @MOZ_DEBUG@
|
||||
|
@ -80,6 +80,7 @@ cairo-atsui.h
|
||||
cairo-beos.h
|
||||
cairo-ft.h
|
||||
cairo-glitz.h
|
||||
cairo-nquartz.h
|
||||
cairo-os2.h
|
||||
cairo-pdf.h
|
||||
cairo-ps.h
|
||||
@ -87,8 +88,6 @@ cairo-quartz.h
|
||||
cairo-win32.h
|
||||
cairo-xlib.h
|
||||
cairo-xlib-xrender.h
|
||||
cairo-directfb.h
|
||||
cairo-qpainter.h
|
||||
#endif
|
||||
callconv.h
|
||||
Carbon/Carbon.h
|
||||
|
@ -35,22 +35,22 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef GFXGDKNATIVERENDER_H_
|
||||
#define GFXGDKNATIVERENDER_H_
|
||||
#ifndef GFXXLIBNATIVERENDER_H_
|
||||
#define GFXXLIBNATIVERENDER_H_
|
||||
|
||||
#include "gfxColor.h"
|
||||
#include <gdk/gdk.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
class gfxASurface;
|
||||
class gfxContext;
|
||||
|
||||
/**
|
||||
* This class lets us take code that draws into an GDK drawable and lets us
|
||||
* This class lets us take code that draws into an X drawable and lets us
|
||||
* use it to draw into any Thebes context. The user should subclass this class,
|
||||
* override NativeDraw, and then call Draw(). The drawing will be subjected
|
||||
* to all Thebes transformations, clipping etc.
|
||||
*/
|
||||
class THEBES_API gfxGdkNativeRenderer {
|
||||
class THEBES_API gfxXlibNativeRenderer {
|
||||
public:
|
||||
/**
|
||||
* Perform the native drawing.
|
||||
@ -60,8 +60,10 @@ public:
|
||||
* @param numClipRects the number of rects in the array, or zero if
|
||||
* no clipping is required
|
||||
*/
|
||||
virtual nsresult NativeDraw(GdkDrawable * drawable, short offsetX,
|
||||
short offsetY, GdkRectangle * clipRects, PRUint32 numClipRects) = 0;
|
||||
virtual nsresult NativeDraw(Screen* screen, Drawable drawable,
|
||||
Visual* visual, Colormap colormap,
|
||||
short offsetX, short offsetY,
|
||||
XRectangle* clipRects, PRUint32 numClipRects) = 0;
|
||||
|
||||
enum {
|
||||
// If set, then Draw() is opaque, i.e., every pixel in the intersection
|
||||
@ -78,7 +80,7 @@ public:
|
||||
// nor CLIP_RECT are set, then numClipRects will be zero
|
||||
DRAW_SUPPORTS_CLIP_LIST = 0x08,
|
||||
// If set, then the visual passed in can be any visual, otherwise the
|
||||
// visual passed in must be the default visual for dpy's default screen
|
||||
// visual passed in must be the default visual for 'screen'
|
||||
DRAW_SUPPORTS_NONDEFAULT_VISUAL = 0x10,
|
||||
// If set, then the Screen 'screen' in the callback can be different
|
||||
// from the default Screen of the display passed to 'Draw' and can be
|
||||
@ -103,8 +105,8 @@ public:
|
||||
* successful, a pointer to the new gfxASurface is stored in *resultSurface,
|
||||
* otherwise *resultSurface is set to nsnull.
|
||||
*/
|
||||
nsresult Draw(gfxContext* ctx, int width, int height,
|
||||
nsresult Draw(Display* dpy, gfxContext* ctx, int width, int height,
|
||||
PRUint32 flags, DrawOutput* output);
|
||||
};
|
||||
|
||||
#endif /*GFXGDKNATIVERENDER_H_*/
|
||||
#endif /*GFXXLIBNATIVERENDER_H_*/
|
@ -1,108 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Novell code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Novell.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* rocallahan@novell.com
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "cairo-gdk-utils.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#elif HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#elif HAVE_SYS_INT_TYPES_H
|
||||
#include <sys/int_types.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* We have three basic strategies available:
|
||||
1) 'direct': cr targets a native surface, and other conditions are met: we can
|
||||
pass the underlying drawable directly to the callback
|
||||
2) 'opaque': the image is opaque: we can create a temporary cairo native surface,
|
||||
pass its underlying drawable to the callback, and paint the result
|
||||
using cairo
|
||||
3) 'default': create a temporary cairo native surface, fill with black, pass its
|
||||
underlying drawable to the callback, copy the results to a cairo
|
||||
image surface, repeat with a white background, update the on-black
|
||||
image alpha values by comparing the two images, then paint the on-black
|
||||
image using cairo
|
||||
Sure would be nice to have an X extension to do 3 for us on the server...
|
||||
*/
|
||||
|
||||
static cairo_bool_t
|
||||
_convert_coord_to_short (double coord, short *v)
|
||||
{
|
||||
*v = (short)coord;
|
||||
/* XXX allow some tolerance here? */
|
||||
return *v == coord;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_convert_coord_to_unsigned_short (double coord, unsigned short *v)
|
||||
{
|
||||
*v = (unsigned short)coord;
|
||||
/* XXX allow some tolerance here? */
|
||||
return *v == coord;
|
||||
}
|
||||
|
||||
|
||||
void cairo_draw_with_gdk (cairo_t *cr,
|
||||
GdkDrawable * drawable,
|
||||
cairo_gdk_drawing_callback callback,
|
||||
void * closure,
|
||||
unsigned int width, unsigned int height,
|
||||
cairo_gdk_drawing_opacity_t is_opaque,
|
||||
cairo_gdk_drawing_support_t capabilities,
|
||||
cairo_gdk_drawing_result_t *result)
|
||||
{
|
||||
double device_offset_x, device_offset_y;
|
||||
short offset_x = 0, offset_y = 0;
|
||||
//cairo_surface_t * target = cairo_get_group_target (cr);
|
||||
cairo_surface_t * target = cairo_get_target (cr);
|
||||
cairo_matrix_t matrix;
|
||||
|
||||
cairo_surface_get_device_offset (target, &device_offset_x, &device_offset_y);
|
||||
cairo_get_matrix (cr, &matrix);
|
||||
|
||||
_convert_coord_to_short (matrix.x0 + device_offset_x, &offset_x);
|
||||
_convert_coord_to_short (matrix.y0 + device_offset_y, &offset_y);
|
||||
|
||||
cairo_surface_flush (target);
|
||||
callback (closure, drawable, offset_x, offset_y, NULL, 0);
|
||||
cairo_surface_mark_dirty (target);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "cairo-gdk-utils.h"
|
||||
#include "cairo-xlib-utils.h"
|
||||
|
||||
#include "cairo-xlib.h"
|
||||
#include <stdlib.h>
|
||||
@ -48,20 +48,25 @@
|
||||
#include <sys/int_types.h>
|
||||
#endif
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
|
||||
#if 0
|
||||
#include <stdio.h>
|
||||
#define CAIRO_GDK_DRAWING_NOTE(m) fprintf(stderr, m)
|
||||
#define CAIRO_XLIB_DRAWING_NOTE(m) fprintf(stderr, m)
|
||||
#else
|
||||
#define CAIRO_GDK_DRAWING_NOTE(m) do {} while (0)
|
||||
#define CAIRO_XLIB_DRAWING_NOTE(m) do {} while (0)
|
||||
#endif
|
||||
|
||||
static cairo_user_data_key_t pixmap_free_key;
|
||||
|
||||
typedef struct {
|
||||
Display *dpy;
|
||||
Pixmap pixmap;
|
||||
} pixmap_free_struct;
|
||||
|
||||
static void pixmap_free_func (void *data)
|
||||
{
|
||||
GdkPixmap *pixmap = (GdkPixmap *) data;
|
||||
g_object_unref(pixmap);
|
||||
pixmap_free_struct *pfs = (pixmap_free_struct *) data;
|
||||
XFreePixmap (pfs->dpy, pfs->pixmap);
|
||||
free (pfs);
|
||||
}
|
||||
|
||||
/* We have three basic strategies available:
|
||||
@ -79,9 +84,17 @@ static void pixmap_free_func (void *data)
|
||||
*/
|
||||
|
||||
static cairo_bool_t
|
||||
_convert_coord_to_int (double coord, int *v)
|
||||
_convert_coord_to_short (double coord, short *v)
|
||||
{
|
||||
*v = (int)coord;
|
||||
*v = (short)coord;
|
||||
/* XXX allow some tolerance here? */
|
||||
return *v == coord;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_convert_coord_to_unsigned_short (double coord, unsigned short *v)
|
||||
{
|
||||
*v = (unsigned short)coord;
|
||||
/* XXX allow some tolerance here? */
|
||||
return *v == coord;
|
||||
}
|
||||
@ -106,7 +119,7 @@ _get_rectangular_clip (cairo_t *cr,
|
||||
int bounds_x, int bounds_y,
|
||||
int bounds_width, int bounds_height,
|
||||
cairo_bool_t *need_clip,
|
||||
GdkRectangle *rectangles, int max_rectangles,
|
||||
XRectangle *rectangles, int max_rectangles,
|
||||
int *num_rectangles)
|
||||
{
|
||||
cairo_rectangle_list_t *cliplist;
|
||||
@ -148,17 +161,17 @@ _get_rectangular_clip (cairo_t *cr,
|
||||
&intersect_x, &intersect_x_most) &&
|
||||
_intersect_interval (b_y, b_y_most, clips[i].y, clips[i].y + clips[i].height,
|
||||
&intersect_y, &intersect_y_most)) {
|
||||
GdkRectangle *rect = &rectangles[rect_count];
|
||||
XRectangle *rect = &rectangles[rect_count];
|
||||
|
||||
if (rect_count >= max_rectangles) {
|
||||
retval = False;
|
||||
goto FINISH;
|
||||
}
|
||||
|
||||
if (!_convert_coord_to_int (intersect_x, &rect->x) ||
|
||||
!_convert_coord_to_int (intersect_y, &rect->y) ||
|
||||
!_convert_coord_to_int (intersect_x_most - intersect_x, &rect->width) ||
|
||||
!_convert_coord_to_int (intersect_y_most - intersect_y, &rect->height))
|
||||
if (!_convert_coord_to_short (intersect_x, &rect->x) ||
|
||||
!_convert_coord_to_short (intersect_y, &rect->y) ||
|
||||
!_convert_coord_to_unsigned_short (intersect_x_most - intersect_x, &rect->width) ||
|
||||
!_convert_coord_to_unsigned_short (intersect_y_most - intersect_y, &rect->height))
|
||||
{
|
||||
retval = False;
|
||||
goto FINISH;
|
||||
@ -187,17 +200,17 @@ FINISH:
|
||||
static cairo_bool_t
|
||||
_draw_with_xlib_direct (cairo_t *cr,
|
||||
Display *default_display,
|
||||
cairo_gdk_drawing_callback callback,
|
||||
cairo_xlib_drawing_callback callback,
|
||||
void *closure,
|
||||
int bounds_width, int bounds_height,
|
||||
cairo_gdk_drawing_support_t capabilities)
|
||||
cairo_xlib_drawing_support_t capabilities)
|
||||
{
|
||||
cairo_surface_t *target;
|
||||
Drawable d;
|
||||
cairo_matrix_t matrix;
|
||||
int offset_x, offset_y;
|
||||
short offset_x, offset_y;
|
||||
cairo_bool_t needs_clip;
|
||||
GdkRectangle rectangles[MAX_STATIC_CLIP_RECTANGLES];
|
||||
XRectangle rectangles[MAX_STATIC_CLIP_RECTANGLES];
|
||||
int rect_count;
|
||||
double device_offset_x, device_offset_y;
|
||||
int max_rectangles;
|
||||
@ -214,22 +227,22 @@ _draw_with_xlib_direct (cairo_t *cr,
|
||||
/* Check that the matrix is a pure translation */
|
||||
/* XXX test some approximation to == 1.0 here? */
|
||||
if (matrix.xx != 1.0 || matrix.yy != 1.0 || matrix.xy != 0.0 || matrix.yx != 0.0) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: matrix not a pure translation\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: matrix not a pure translation\n");
|
||||
return False;
|
||||
}
|
||||
/* Check that the matrix translation offsets (adjusted for
|
||||
device offset) are integers */
|
||||
if (!_convert_coord_to_int (matrix.x0 + device_offset_x, &offset_x) ||
|
||||
!_convert_coord_to_int (matrix.y0 + device_offset_y, &offset_y)) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: non-integer offset\n");
|
||||
if (!_convert_coord_to_short (matrix.x0 + device_offset_x, &offset_x) ||
|
||||
!_convert_coord_to_short (matrix.y0 + device_offset_y, &offset_y)) {
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: non-integer offset\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
max_rectangles = 0;
|
||||
if (capabilities & CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT) {
|
||||
if (capabilities & CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT) {
|
||||
max_rectangles = 1;
|
||||
}
|
||||
if (capabilities & CAIRO_GDK_DRAWING_SUPPORTS_CLIP_LIST) {
|
||||
if (capabilities & CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST) {
|
||||
max_rectangles = MAX_STATIC_CLIP_RECTANGLES;
|
||||
}
|
||||
|
||||
@ -246,26 +259,26 @@ _draw_with_xlib_direct (cairo_t *cr,
|
||||
rectangles, max_rectangles, &rect_count);
|
||||
cairo_set_matrix (cr, &matrix);
|
||||
if (!have_rectangular_clip) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: unsupported clip\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: unsupported clip\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Stop now if everything is clipped out */
|
||||
if (needs_clip && rect_count == 0) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING FAST PATH: all clipped\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING FAST PATH: all clipped\n");
|
||||
return True;
|
||||
}
|
||||
|
||||
/* Check that the operator is OVER */
|
||||
if (cairo_get_operator (cr) != CAIRO_OPERATOR_OVER) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: non-OVER operator\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: non-OVER operator\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Check that the offset is supported */
|
||||
if (!(capabilities & CAIRO_GDK_DRAWING_SUPPORTS_OFFSET) &&
|
||||
if (!(capabilities & CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET) &&
|
||||
(offset_x != 0 || offset_y != 0)) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: unsupported offset\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: unsupported offset\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -273,36 +286,35 @@ _draw_with_xlib_direct (cairo_t *cr,
|
||||
we might complete early above when when the object to be drawn is
|
||||
completely clipped out. */
|
||||
if (!d) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: non-X surface\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: non-X surface\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Check that the display is supported */
|
||||
screen = cairo_xlib_surface_get_screen (target);
|
||||
if (!(capabilities & CAIRO_GDK_DRAWING_SUPPORTS_ALTERNATE_SCREEN) &&
|
||||
if (!(capabilities & CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN) &&
|
||||
screen != DefaultScreenOfDisplay (default_display)) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: non-default display\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: non-default display\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Check that there is a visual */
|
||||
visual = cairo_xlib_surface_get_visual (target);
|
||||
if (!visual) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: no Visual for surface\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: no Visual for surface\n");
|
||||
return False;
|
||||
}
|
||||
/* Check that the visual is supported */
|
||||
if (!(capabilities & CAIRO_GDK_DRAWING_SUPPORTS_NONDEFAULT_VISUAL) &&
|
||||
if (!(capabilities & CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL) &&
|
||||
DefaultVisualOfScreen (screen) != visual) {
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING SLOW PATH: non-default visual\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING SLOW PATH: non-default visual\n");
|
||||
return False;
|
||||
}
|
||||
|
||||
/* we're good to go! */
|
||||
CAIRO_GDK_DRAWING_NOTE("TAKING FAST PATH\n");
|
||||
CAIRO_XLIB_DRAWING_NOTE("TAKING FAST PATH\n");
|
||||
cairo_surface_flush (target);
|
||||
callback (closure, GDK_DRAWABLE(gdk_xid_table_lookup(d)),
|
||||
offset_x, offset_y, rectangles,
|
||||
callback (closure, screen, d, visual, offset_x, offset_y, rectangles,
|
||||
needs_clip ? rect_count : 0);
|
||||
cairo_surface_mark_dirty (target);
|
||||
return True;
|
||||
@ -310,53 +322,73 @@ _draw_with_xlib_direct (cairo_t *cr,
|
||||
|
||||
static cairo_surface_t *
|
||||
_create_temp_xlib_surface (cairo_t *cr, Display *dpy, int width, int height,
|
||||
cairo_gdk_drawing_support_t capabilities)
|
||||
cairo_xlib_drawing_support_t capabilities)
|
||||
{
|
||||
cairo_surface_t *result = NULL;
|
||||
|
||||
/* base the temp surface on the *screen* surface, not any intermediate
|
||||
* group surface, because the screen surface is more likely to have
|
||||
* characteristics that the xlib-using code is likely to be happy with */
|
||||
cairo_surface_t *target = cairo_get_target (cr);
|
||||
Drawable target_drawable = cairo_xlib_surface_get_drawable (target);
|
||||
GdkDrawable *gdk_target_drawable = GDK_DRAWABLE(gdk_xid_table_lookup(target_drawable));
|
||||
|
||||
GdkPixmap *pixmap = NULL;
|
||||
if (gdk_target_drawable) {
|
||||
pixmap = gdk_pixmap_new(gdk_target_drawable,
|
||||
width, height,
|
||||
-1);
|
||||
} else {
|
||||
int screen_index = DefaultScreen (dpy);
|
||||
int depth = DefaultDepth (dpy, screen_index);
|
||||
int screen_index = DefaultScreen (dpy);
|
||||
Drawable drawable = RootWindow (dpy, screen_index);
|
||||
Screen *screen = DefaultScreenOfDisplay (dpy);
|
||||
Visual *visual = DefaultVisual (dpy, screen_index);
|
||||
int depth = DefaultDepth (dpy, screen_index);
|
||||
|
||||
pixmap = gdk_pixmap_new(NULL,
|
||||
width, height,
|
||||
depth);
|
||||
Pixmap pixmap;
|
||||
cairo_surface_t *result;
|
||||
pixmap_free_struct *pfs;
|
||||
|
||||
/* make the temporary surface match target_drawable to the extent supported
|
||||
by the native rendering code */
|
||||
if (target_drawable) {
|
||||
Screen *target_screen = cairo_xlib_surface_get_screen (target);
|
||||
Visual *target_visual = cairo_xlib_surface_get_visual (target);
|
||||
if ((target_screen == screen ||
|
||||
(capabilities & CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN)) &&
|
||||
target_visual &&
|
||||
(target_visual == DefaultVisualOfScreen (target_screen) ||
|
||||
(capabilities & CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL))) {
|
||||
drawable = target_drawable;
|
||||
dpy = cairo_xlib_surface_get_display (target);
|
||||
visual = target_visual;
|
||||
depth = cairo_xlib_surface_get_depth (target);
|
||||
}
|
||||
}
|
||||
|
||||
result = cairo_xlib_surface_create (gdk_x11_drawable_get_xdisplay(pixmap),
|
||||
gdk_x11_drawable_get_xid(pixmap),
|
||||
gdk_x11_visual_get_xvisual(gdk_drawable_get_visual(pixmap)),
|
||||
width, height);
|
||||
|
||||
pfs = malloc (sizeof(pixmap_free_struct));
|
||||
if (pfs == NULL)
|
||||
return NULL;
|
||||
|
||||
pixmap = XCreatePixmap (dpy, drawable, width, height, depth);
|
||||
if (!pixmap) {
|
||||
free (pfs);
|
||||
return NULL;
|
||||
}
|
||||
pfs->dpy = dpy;
|
||||
pfs->pixmap = pixmap;
|
||||
|
||||
result = cairo_xlib_surface_create (dpy, pixmap, visual, width, height);
|
||||
if (cairo_surface_status (result) != CAIRO_STATUS_SUCCESS) {
|
||||
pixmap_free_func (pixmap);
|
||||
pixmap_free_func (pfs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cairo_surface_set_user_data (result, &pixmap_free_key, pixmap, pixmap_free_func);
|
||||
cairo_surface_set_user_data (result, &pixmap_free_key, pfs, pixmap_free_func);
|
||||
return result;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
_draw_onto_temp_xlib_surface (cairo_surface_t *temp_xlib_surface,
|
||||
cairo_gdk_drawing_callback callback,
|
||||
cairo_xlib_drawing_callback callback,
|
||||
void *closure,
|
||||
double background_gray_value)
|
||||
{
|
||||
Drawable d = cairo_xlib_surface_get_drawable (temp_xlib_surface);
|
||||
Screen *screen = cairo_xlib_surface_get_screen (temp_xlib_surface);
|
||||
Visual *visual = cairo_xlib_surface_get_visual (temp_xlib_surface);
|
||||
cairo_bool_t result;
|
||||
|
||||
cairo_t *cr = cairo_create (temp_xlib_surface);
|
||||
cairo_set_source_rgb (cr, background_gray_value, background_gray_value,
|
||||
background_gray_value);
|
||||
@ -367,8 +399,7 @@ _draw_onto_temp_xlib_surface (cairo_surface_t *temp_xlib_surface,
|
||||
cairo_surface_flush (temp_xlib_surface);
|
||||
/* no clipping is needed because the callback can't draw outside the native
|
||||
surface anyway */
|
||||
result = callback (closure, GDK_DRAWABLE(gdk_xid_table_lookup(d)),
|
||||
0, 0, NULL, 0);
|
||||
result = callback (closure, screen, d, visual, 0, 0, NULL, 0);
|
||||
cairo_surface_mark_dirty (temp_xlib_surface);
|
||||
return result;
|
||||
}
|
||||
@ -420,7 +451,7 @@ static void
|
||||
_compute_alpha_values (uint32_t *black_data,
|
||||
uint32_t *white_data,
|
||||
int width, int height,
|
||||
cairo_gdk_drawing_result_t *analysis)
|
||||
cairo_xlib_drawing_result_t *analysis)
|
||||
{
|
||||
int num_pixels = width*height;
|
||||
int i;
|
||||
@ -480,22 +511,21 @@ _compute_alpha_values (uint32_t *black_data,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
cairo_draw_with_gdk (cairo_t *cr,
|
||||
GdkDrawable * drawable,
|
||||
cairo_gdk_drawing_callback callback,
|
||||
void * closure,
|
||||
unsigned int width, unsigned int height,
|
||||
cairo_gdk_drawing_opacity_t is_opaque,
|
||||
cairo_gdk_drawing_support_t capabilities,
|
||||
cairo_gdk_drawing_result_t *result)
|
||||
void
|
||||
cairo_draw_with_xlib (cairo_t *cr,
|
||||
cairo_xlib_drawing_callback callback,
|
||||
void *closure,
|
||||
Display *dpy,
|
||||
unsigned int width, unsigned int height,
|
||||
cairo_xlib_drawing_opacity_t is_opaque,
|
||||
cairo_xlib_drawing_support_t capabilities,
|
||||
cairo_xlib_drawing_result_t *result)
|
||||
{
|
||||
cairo_surface_t *temp_xlib_surface;
|
||||
cairo_surface_t *black_image_surface;
|
||||
cairo_surface_t *white_image_surface;
|
||||
unsigned char *black_data;
|
||||
unsigned char *white_data;
|
||||
Display *dpy = gdk_x11_drawable_get_xdisplay(drawable);
|
||||
|
||||
if (result) {
|
||||
result->surface = NULL;
|
||||
@ -526,7 +556,7 @@ cairo_draw_with_gdk (cairo_t *cr,
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_opaque == CAIRO_GDK_DRAWING_OPAQUE) {
|
||||
if (is_opaque == CAIRO_XLIB_DRAWING_OPAQUE) {
|
||||
cairo_set_source_surface (cr, temp_xlib_surface, 0.0, 0.0);
|
||||
cairo_paint (cr);
|
||||
if (result) {
|
||||
|
@ -35,30 +35,32 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef CAIROGDKUTILS_H_
|
||||
#define CAIROGDKUTILS_H_
|
||||
#ifndef CAIROXLIBUTILS_H_
|
||||
#define CAIROXLIBUTILS_H_
|
||||
|
||||
#include "cairo.h"
|
||||
#include <gdk/gdk.h>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* This callback encapsulates GDK-based rendering. We assume that the
|
||||
* This callback encapsulates Xlib-based rendering. We assume that the
|
||||
* execution of the callback is equivalent to compositing some RGBA image of
|
||||
* size (bounds_width, bounds_height) onto the drawable at offset (offset_x,
|
||||
* offset_y), clipped to the union of the clip_rects if num_rects is greater
|
||||
* than zero. This includes the assumption that the same RGBA image
|
||||
* is composited if you call the callback multiple times with the same closure,
|
||||
* display and visual during a single cairo_draw_with_gdk call.
|
||||
* display and visual during a single cairo_draw_with_xlib call.
|
||||
*
|
||||
* @return True on success, False on non-recoverable error
|
||||
*/
|
||||
typedef cairo_bool_t (* cairo_gdk_drawing_callback)
|
||||
typedef cairo_bool_t (* cairo_xlib_drawing_callback)
|
||||
(void *closure,
|
||||
GdkDrawable * drawable,
|
||||
Screen *screen,
|
||||
Drawable drawable,
|
||||
Visual *visual,
|
||||
short offset_x, short offset_y,
|
||||
GdkRectangle * clip_rects, unsigned int num_rects);
|
||||
XRectangle* clip_rects, unsigned int num_rects);
|
||||
|
||||
/**
|
||||
* This structure captures the result of the native drawing, in case the
|
||||
@ -70,7 +72,7 @@ typedef struct {
|
||||
cairo_bool_t uniform_color;
|
||||
double alpha; /* valid only if uniform_alpha is TRUE */
|
||||
double r, g, b; /* valid only if uniform_color is TRUE */
|
||||
} cairo_gdk_drawing_result_t;
|
||||
} cairo_xlib_drawing_result_t;
|
||||
|
||||
/**
|
||||
* This type specifies whether the native drawing callback draws all pixels
|
||||
@ -78,50 +80,50 @@ typedef struct {
|
||||
* or whether it leaves pixels transparent/translucent or depends on the
|
||||
* existing contents of the target drawable in some way.
|
||||
*/
|
||||
typedef enum _cairo_gdk_drawing_opacity {
|
||||
CAIRO_GDK_DRAWING_OPAQUE,
|
||||
CAIRO_GDK_DRAWING_TRANSPARENT
|
||||
} cairo_gdk_drawing_opacity_t;
|
||||
typedef enum _cairo_xlib_drawing_opacity {
|
||||
CAIRO_XLIB_DRAWING_OPAQUE,
|
||||
CAIRO_XLIB_DRAWING_TRANSPARENT
|
||||
} cairo_xlib_drawing_opacity_t;
|
||||
|
||||
/**
|
||||
* This type encodes the capabilities of the native drawing callback.
|
||||
*
|
||||
* If CAIRO_GDK_DRAWING_SUPPORTS_OFFSET is set, 'offset_x' and 'offset_y'
|
||||
* If CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET is set, 'offset_x' and 'offset_y'
|
||||
* can be nonzero in the call to the callback; otherwise they will be zero.
|
||||
*
|
||||
* If CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT is set, then 'num_rects' can be
|
||||
* If CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT is set, then 'num_rects' can be
|
||||
* zero or one in the call to the callback. If
|
||||
* CAIRO_GDK_DRAWING_SUPPORTS_CLIP_LIST is set, then 'num_rects' can be
|
||||
* CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST is set, then 'num_rects' can be
|
||||
* anything in the call to the callback. Otherwise 'num_rects' will be zero.
|
||||
* Do not set both of these values.
|
||||
*
|
||||
* If CAIRO_GDK_DRAWING_SUPPORTS_ALTERNATE_DISPLAY is set, then 'dpy' can be
|
||||
* any display, otherwise it will be the display passed into
|
||||
* cairo_draw_with_gdk.
|
||||
* If CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN is set, then 'screen' can
|
||||
* be any screen on any display, otherwise it will be the default screen of
|
||||
* the display passed into cairo_draw_with_xlib.
|
||||
*
|
||||
* If CAIRO_GDK_DRAWING_SUPPORTS_NONDEFAULT_VISUAL is set, then 'visual' can be
|
||||
* If CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL is set, then 'visual' can be
|
||||
* any visual, otherwise it will be equal to
|
||||
* DefaultVisual (dpy, DefaultScreen (dpy)).
|
||||
* DefaultVisualOfScreen (screen).
|
||||
*/
|
||||
typedef enum {
|
||||
CAIRO_GDK_DRAWING_SUPPORTS_OFFSET = 0x01,
|
||||
CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT = 0x02,
|
||||
CAIRO_GDK_DRAWING_SUPPORTS_CLIP_LIST = 0x04,
|
||||
CAIRO_GDK_DRAWING_SUPPORTS_ALTERNATE_SCREEN = 0x08,
|
||||
CAIRO_GDK_DRAWING_SUPPORTS_NONDEFAULT_VISUAL = 0x10
|
||||
} cairo_gdk_drawing_support_t;
|
||||
CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET = 0x01,
|
||||
CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT = 0x02,
|
||||
CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST = 0x04,
|
||||
CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN = 0x08,
|
||||
CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL = 0x10
|
||||
} cairo_xlib_drawing_support_t;
|
||||
|
||||
/**
|
||||
* Draw GDK output into any cairo context. All cairo transforms and effects
|
||||
* Draw Xlib output into any cairo context. All cairo transforms and effects
|
||||
* are honored, including the current operator. This is equivalent to a
|
||||
* cairo_set_source_surface and then cairo_paint.
|
||||
* @param cr the context to draw into
|
||||
* @param drawable a GDK Drawable that we're targetting
|
||||
* @param callback the code to perform GDK rendering
|
||||
* @param callback the code to perform Xlib rendering
|
||||
* @param closure associated data
|
||||
* @param dpy an X display to use in case the cairo context has no associated X display
|
||||
* @param width the width of the putative image drawn by the callback
|
||||
* @param height the height of the putative image drawn by the callback
|
||||
* @param is_opaque set to CAIRO_GDK_DRAWING_IS_OPAQUE to indicate
|
||||
* @param is_opaque set to CAIRO_XLIB_DRAWING_IS_OPAQUE to indicate
|
||||
* that all alpha values of the putative image will be 1.0; the pixels drawn into
|
||||
* the Drawable must not depend on the prior contents of the Drawable
|
||||
* in any way
|
||||
@ -135,15 +137,15 @@ typedef enum {
|
||||
* in which case the color is always uniform) then we won't bother returning
|
||||
* a surface for it.
|
||||
*/
|
||||
void cairo_draw_with_gdk (cairo_t *cr,
|
||||
GdkDrawable * drawable,
|
||||
cairo_gdk_drawing_callback callback,
|
||||
void * closure,
|
||||
unsigned int width, unsigned int height,
|
||||
cairo_gdk_drawing_opacity_t is_opaque,
|
||||
cairo_gdk_drawing_support_t capabilities,
|
||||
cairo_gdk_drawing_result_t *result);
|
||||
void cairo_draw_with_xlib (cairo_t *cr,
|
||||
cairo_xlib_drawing_callback callback,
|
||||
void *closure,
|
||||
Display *dpy,
|
||||
unsigned int width, unsigned int height,
|
||||
cairo_xlib_drawing_opacity_t is_opaque,
|
||||
cairo_xlib_drawing_support_t capabilities,
|
||||
cairo_xlib_drawing_result_t *result);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#endif /*CAIROGDKUTILS_H_*/
|
||||
#endif /*CAIROXLIBUTILS_H_*/
|
@ -1,128 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Novell code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Novell.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* rocallahan@novell.com
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxGdkNativeRenderer.h"
|
||||
#include "gfxContext.h"
|
||||
|
||||
#include "cairo-gdk-utils.h"
|
||||
|
||||
#include "gfxPlatformGtk.h"
|
||||
|
||||
typedef struct {
|
||||
gfxGdkNativeRenderer* mRenderer;
|
||||
nsresult mRV;
|
||||
} NativeRenderingClosure;
|
||||
|
||||
|
||||
static cairo_bool_t
|
||||
NativeRendering(void *closure,
|
||||
GdkDrawable * drawable,
|
||||
short offset_x, short offset_y,
|
||||
GdkRectangle * rectangles, unsigned int num_rects)
|
||||
{
|
||||
NativeRenderingClosure* cl = (NativeRenderingClosure*)closure;
|
||||
nsresult rv = cl->mRenderer->
|
||||
NativeDraw(drawable, offset_x, offset_y,
|
||||
rectangles, num_rects);
|
||||
cl->mRV = rv;
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
gfxGdkNativeRenderer::Draw(gfxContext* ctx, int width, int height,
|
||||
PRUint32 flags, DrawOutput* output)
|
||||
{
|
||||
NativeRenderingClosure closure = { this, NS_OK };
|
||||
cairo_gdk_drawing_result_t result;
|
||||
// Make sure result.surface is null to start with; we rely on it
|
||||
// being non-null meaning that a surface actually got allocated.
|
||||
result.surface = NULL;
|
||||
|
||||
if (output) {
|
||||
output->mSurface = NULL;
|
||||
output->mUniformAlpha = PR_FALSE;
|
||||
output->mUniformColor = PR_FALSE;
|
||||
}
|
||||
|
||||
int cairoFlags = 0;
|
||||
if (flags & DRAW_SUPPORTS_OFFSET) {
|
||||
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_OFFSET;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_CLIP_RECT) {
|
||||
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_CLIP_LIST) {
|
||||
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_CLIP_LIST;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_ALTERNATE_SCREEN) {
|
||||
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_ALTERNATE_SCREEN;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_NONDEFAULT_VISUAL) {
|
||||
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_NONDEFAULT_VISUAL;
|
||||
}
|
||||
cairo_draw_with_gdk(ctx->GetCairo(),
|
||||
gfxPlatformGtk::GetPlatform()->GetGdkDrawable(ctx->OriginalSurface()),
|
||||
NativeRendering,
|
||||
&closure, width, height,
|
||||
(flags & DRAW_IS_OPAQUE) ? CAIRO_GDK_DRAWING_OPAQUE : CAIRO_GDK_DRAWING_TRANSPARENT,
|
||||
(cairo_gdk_drawing_support_t)cairoFlags,
|
||||
output ? &result : NULL);
|
||||
if (NS_FAILED(closure.mRV)) {
|
||||
if (result.surface) {
|
||||
NS_ASSERTION(output, "How did that happen?");
|
||||
cairo_surface_destroy (result.surface);
|
||||
}
|
||||
return closure.mRV;
|
||||
}
|
||||
|
||||
if (output) {
|
||||
if (result.surface) {
|
||||
output->mSurface = gfxASurface::Wrap(result.surface);
|
||||
if (!output->mSurface) {
|
||||
cairo_surface_destroy (result.surface);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
output->mUniformAlpha = result.uniform_alpha;
|
||||
output->mUniformColor = result.uniform_color;
|
||||
output->mColor = gfxRGBA(result.r, result.g, result.b, result.alpha);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
@ -120,9 +120,13 @@ gfxPlatformGtk::gfxPlatformGtk()
|
||||
FT_Init_FreeType(&gPlatformFTLibrary);
|
||||
|
||||
gPlatformFonts = new FontTable();
|
||||
gPlatformFonts->Init(100);
|
||||
/* FIXME: DFB */
|
||||
//gPlatformFonts->Init(100);
|
||||
gPlatformFonts->Init(20);
|
||||
gPlatformFontAliases = new FontTable();
|
||||
gPlatformFontAliases->Init(100);
|
||||
/* FIXME: DFB */
|
||||
//gPlatformFontAliases->Init(100);
|
||||
gPlatformFontAliases->Init(20);
|
||||
UpdateFontList();
|
||||
#endif
|
||||
|
||||
@ -261,10 +265,6 @@ gfxPlatformGtk::CreateOffscreenSurface(const gfxIntSize& size,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
newSurface = new gfxDirectFBSurface(size, imageFormat);
|
||||
#endif
|
||||
|
||||
if (newSurface) {
|
||||
gfxContext tmpCtx(newSurface);
|
||||
tmpCtx.SetOperator(gfxContext::OPERATOR_CLEAR);
|
||||
|
209
gfx/thebes/src/gfxXlibNativeRenderer.cpp
Normal file
209
gfx/thebes/src/gfxXlibNativeRenderer.cpp
Normal file
@ -0,0 +1,209 @@
|
||||
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Novell code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Novell.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2006
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* rocallahan@novell.com
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxXlibNativeRenderer.h"
|
||||
#include "gfxContext.h"
|
||||
|
||||
#include "cairo-xlib-utils.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include <gdk/gdkscreen.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
// Look for an existing Colormap that known to be associated with visual.
|
||||
static Colormap
|
||||
LookupColormapForVisual(const Screen* screen, const Visual* visual)
|
||||
{
|
||||
// common case
|
||||
if (visual == DefaultVisualOfScreen(screen))
|
||||
return DefaultColormapOfScreen(screen);
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
// I wish there were a gdk_x11_display_lookup_screen.
|
||||
Display* dpy = DisplayOfScreen(screen);
|
||||
GdkDisplay* gdkDpy = gdk_x11_lookup_xdisplay(dpy);
|
||||
if (gdkDpy) {
|
||||
gint screen_num = 0;
|
||||
for (int s = 0; s < ScreenCount(dpy); ++s) {
|
||||
if (ScreenOfDisplay(dpy, s) == screen) {
|
||||
screen_num = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
GdkScreen* gdkScreen = gdk_display_get_screen(gdkDpy, screen_num);
|
||||
|
||||
GdkColormap* gdkColormap = NULL;
|
||||
if (visual ==
|
||||
GDK_VISUAL_XVISUAL(gdk_screen_get_rgb_visual(gdkScreen))) {
|
||||
// widget/src/gtk2/mozcontainer.c uses gdk_rgb_get_colormap()
|
||||
// which is inherited by child widgets, so this is the visual
|
||||
// expected when drawing directly to widget surfaces or surfaces
|
||||
// created using cairo_surface_create_similar with
|
||||
// CAIRO_CONTENT_COLOR.
|
||||
// gdk_screen_get_rgb_colormap is the generalization of
|
||||
// gdk_rgb_get_colormap for any screen.
|
||||
gdkColormap = gdk_screen_get_rgb_colormap(gdkScreen);
|
||||
}
|
||||
else if (visual ==
|
||||
GDK_VISUAL_XVISUAL(gdk_screen_get_rgba_visual(gdkScreen))) {
|
||||
// This is the visual expected on displays with the Composite
|
||||
// extension enabled when the surface has been created using
|
||||
// cairo_surface_create_similar with CAIRO_CONTENT_COLOR_ALPHA,
|
||||
// as happens with non-unit opacity.
|
||||
gdkColormap = gdk_screen_get_rgba_colormap(gdkScreen);
|
||||
}
|
||||
if (gdkColormap != NULL)
|
||||
return GDK_COLORMAP_XCOLORMAP(gdkColormap);
|
||||
}
|
||||
#endif
|
||||
|
||||
return None;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
gfxXlibNativeRenderer* mRenderer;
|
||||
nsresult mRV;
|
||||
} NativeRenderingClosure;
|
||||
|
||||
static cairo_bool_t
|
||||
NativeRendering(void *closure,
|
||||
Screen *screen,
|
||||
Drawable drawable,
|
||||
Visual *visual,
|
||||
short offset_x, short offset_y,
|
||||
XRectangle* rectangles, unsigned int num_rects)
|
||||
{
|
||||
// Cairo doesn't provide a Colormap.
|
||||
// See if a suitable existing Colormap is known.
|
||||
Colormap colormap = LookupColormapForVisual(screen, visual);
|
||||
PRBool allocColormap = colormap == None;
|
||||
if (allocColormap) {
|
||||
// No existing colormap found.
|
||||
// This case is not expected with MOZ_WIDGET_GTK2.
|
||||
// Create a Colormap for the Visual.
|
||||
// This is only really useful for Visual classes with predefined
|
||||
// Colormap entries, but cairo would be all confused with
|
||||
// non-default non-TrueColor colormaps anyway.
|
||||
NS_ASSERTION(visual->c_class == TrueColor ||
|
||||
visual->c_class == StaticColor ||
|
||||
visual->c_class == StaticGray,
|
||||
"Creating empty colormap");
|
||||
// If this case were expected then it might be worth considering
|
||||
// using a service that maintains a set of Colormaps for associated
|
||||
// Visuals so as to avoid repeating the LockDisplay required in
|
||||
// XCreateColormap, but then it's no worse than the XCreatePixmap
|
||||
// that produced the Drawable here.
|
||||
colormap = XCreateColormap(DisplayOfScreen(screen),
|
||||
RootWindowOfScreen(screen),
|
||||
visual, AllocNone);
|
||||
}
|
||||
|
||||
NativeRenderingClosure* cl = (NativeRenderingClosure*)closure;
|
||||
nsresult rv = cl->mRenderer->
|
||||
NativeDraw(screen, drawable, visual, colormap, offset_x, offset_y,
|
||||
rectangles, num_rects);
|
||||
cl->mRV = rv;
|
||||
|
||||
if (allocColormap) {
|
||||
XFreeColormap(DisplayOfScreen(screen), colormap);
|
||||
}
|
||||
return NS_SUCCEEDED(rv);
|
||||
}
|
||||
|
||||
nsresult
|
||||
gfxXlibNativeRenderer::Draw(Display* dpy, gfxContext* ctx, int width, int height,
|
||||
PRUint32 flags, DrawOutput* output)
|
||||
{
|
||||
NativeRenderingClosure closure = { this, NS_OK };
|
||||
cairo_xlib_drawing_result_t result;
|
||||
// Make sure result.surface is null to start with; we rely on it
|
||||
// being non-null meaning that a surface actually got allocated.
|
||||
result.surface = NULL;
|
||||
|
||||
if (output) {
|
||||
output->mSurface = NULL;
|
||||
output->mUniformAlpha = PR_FALSE;
|
||||
output->mUniformColor = PR_FALSE;
|
||||
}
|
||||
|
||||
int cairoFlags = 0;
|
||||
if (flags & DRAW_SUPPORTS_OFFSET) {
|
||||
cairoFlags |= CAIRO_XLIB_DRAWING_SUPPORTS_OFFSET;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_CLIP_RECT) {
|
||||
cairoFlags |= CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_RECT;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_CLIP_LIST) {
|
||||
cairoFlags |= CAIRO_XLIB_DRAWING_SUPPORTS_CLIP_LIST;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_ALTERNATE_SCREEN) {
|
||||
cairoFlags |= CAIRO_XLIB_DRAWING_SUPPORTS_ALTERNATE_SCREEN;
|
||||
}
|
||||
if (flags & DRAW_SUPPORTS_NONDEFAULT_VISUAL) {
|
||||
cairoFlags |= CAIRO_XLIB_DRAWING_SUPPORTS_NONDEFAULT_VISUAL;
|
||||
}
|
||||
cairo_draw_with_xlib(ctx->GetCairo(), NativeRendering, &closure, dpy,
|
||||
width, height,
|
||||
(flags & DRAW_IS_OPAQUE) ? CAIRO_XLIB_DRAWING_OPAQUE
|
||||
: CAIRO_XLIB_DRAWING_TRANSPARENT,
|
||||
(cairo_xlib_drawing_support_t)cairoFlags,
|
||||
output ? &result : NULL);
|
||||
if (NS_FAILED(closure.mRV)) {
|
||||
if (result.surface) {
|
||||
NS_ASSERTION(output, "How did that happen?");
|
||||
cairo_surface_destroy (result.surface);
|
||||
}
|
||||
return closure.mRV;
|
||||
}
|
||||
|
||||
if (output) {
|
||||
if (result.surface) {
|
||||
output->mSurface = gfxASurface::Wrap(result.surface);
|
||||
if (!output->mSurface) {
|
||||
cairo_surface_destroy (result.surface);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
output->mUniformAlpha = result.uniform_alpha;
|
||||
output->mUniformColor = result.uniform_color;
|
||||
output->mColor = gfxRGBA(result.r, result.g, result.b, result.alpha);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
@ -159,16 +159,13 @@ enum { XKeyPress = KeyPress };
|
||||
#ifdef KeyPress
|
||||
#undef KeyPress
|
||||
#endif
|
||||
#include "gfxXlibNativeRenderer.h"
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include <gdk/gdkwindow.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
#include "gfxGdkNativeRenderer.h"
|
||||
#endif
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <wtypes.h>
|
||||
#include <winuser.h>
|
||||
@ -364,7 +361,7 @@ public:
|
||||
void Paint(const nsRect& aDirtyRect, HDC ndc);
|
||||
#elif defined(XP_MACOSX)
|
||||
void Paint(const nsRect& aDirtyRect);
|
||||
#elif defined(MOZ_X11) || defined(MOZ_DFB)
|
||||
#elif defined(MOZ_X11)
|
||||
void Paint(gfxContext* aContext,
|
||||
const gfxRect& aFrameRect,
|
||||
const gfxRect& aDirtyRect);
|
||||
@ -480,16 +477,18 @@ private:
|
||||
|
||||
nsresult EnsureCachedAttrParamArrays();
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
class Renderer : public gfxGdkNativeRenderer {
|
||||
#ifdef MOZ_X11
|
||||
class Renderer : public gfxXlibNativeRenderer {
|
||||
public:
|
||||
Renderer(nsPluginWindow* aWindow, nsIPluginInstance* aInstance,
|
||||
const nsIntSize& aPluginSize, const nsIntRect& aDirtyRect)
|
||||
: mWindow(aWindow), mInstance(aInstance),
|
||||
mPluginSize(aPluginSize), mDirtyRect(aDirtyRect)
|
||||
{}
|
||||
virtual nsresult NativeDraw(GdkDrawable * drawable, short offsetX,
|
||||
short offsetY, GdkRectangle * clipRects, PRUint32 numClipRects);
|
||||
virtual nsresult NativeDraw(Screen* screen, Drawable drawable,
|
||||
Visual* visual, Colormap colormap,
|
||||
short offsetX, short offsetY,
|
||||
XRectangle* clipRects, PRUint32 numClipRects);
|
||||
private:
|
||||
nsPluginWindow* mWindow;
|
||||
nsIPluginInstance* mInstance;
|
||||
@ -1373,7 +1372,7 @@ nsObjectFrame::PaintPlugin(nsIRenderingContext& aRenderingContext,
|
||||
mInstanceOwner->Paint(aDirtyRect);
|
||||
}
|
||||
}
|
||||
#elif defined(MOZ_X11) || defined(MOZ_DFB)
|
||||
#elif defined(MOZ_X11)
|
||||
if (mInstanceOwner)
|
||||
{
|
||||
nsPluginWindow * window;
|
||||
@ -2503,9 +2502,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetValue(nsPluginInstancePeerVariable varia
|
||||
if (!gdkWindow)
|
||||
return rv;
|
||||
gdkWindow = gdk_window_get_toplevel(gdkWindow);
|
||||
#ifdef MOZ_X11
|
||||
*static_cast<Window*>(value) = GDK_WINDOW_XID(gdkWindow);
|
||||
#endif
|
||||
return NS_OK;
|
||||
#endif
|
||||
} else NS_ASSERTION(mOwner, "plugin owner has no owner in getting doc's window handle");
|
||||
@ -4045,7 +4042,7 @@ void nsPluginInstanceOwner::Paint(const nsRect& aDirtyRect, HPS aHPS)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MOZ_X11) || defined(MOZ_DFB)
|
||||
#ifdef MOZ_X11
|
||||
void nsPluginInstanceOwner::Paint(gfxContext* aContext,
|
||||
const gfxRect& aFrameRect,
|
||||
const gfxRect& aDirtyRect)
|
||||
@ -4108,11 +4105,16 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
|
||||
gfxContextAutoSaveRestore autoSR(aContext);
|
||||
aContext->Translate(pluginRect.pos);
|
||||
|
||||
renderer.Draw(aContext, window->width, window->height,
|
||||
// The display used by gfxXlibNativeRenderer will be the one for the cairo
|
||||
// surface (provided that it is an Xlib surface) but the display argument
|
||||
// here needs to be non-NULL for cairo_draw_with_xlib ->
|
||||
// _create_temp_xlib_surface -> DefaultScreen(dpy).
|
||||
NPSetWindowCallbackStruct* ws_info =
|
||||
static_cast<NPSetWindowCallbackStruct*>(window->ws_info);
|
||||
renderer.Draw(ws_info->display, aContext, pluginSize.width, pluginSize.height,
|
||||
rendererFlags, nsnull);
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
static int
|
||||
DepthOfVisual(const Screen* screen, const Visual* visual)
|
||||
{
|
||||
@ -4127,20 +4129,14 @@ DepthOfVisual(const Screen* screen, const Visual* visual)
|
||||
NS_ERROR("Visual not on Screen.");
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable,
|
||||
nsPluginInstanceOwner::Renderer::NativeDraw(Screen* screen, Drawable drawable,
|
||||
Visual* visual, Colormap colormap,
|
||||
short offsetX, short offsetY,
|
||||
GdkRectangle * clipRects,
|
||||
XRectangle* clipRects,
|
||||
PRUint32 numClipRects)
|
||||
|
||||
{
|
||||
#ifdef MOZ_X11
|
||||
Visual * visual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(drawable));
|
||||
Colormap colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(drawable));
|
||||
Screen * screen = GDK_SCREEN_XSCREEN (gdk_drawable_get_screen(drawable));
|
||||
#endif
|
||||
// See if the plugin must be notified of new window parameters.
|
||||
PRBool doupdatewindow = PR_FALSE;
|
||||
|
||||
@ -4191,19 +4187,16 @@ nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable,
|
||||
|
||||
NPSetWindowCallbackStruct* ws_info =
|
||||
static_cast<NPSetWindowCallbackStruct*>(mWindow->ws_info);
|
||||
#ifdef MOZ_X11
|
||||
if (ws_info->visual != visual || ws_info->colormap != colormap) {
|
||||
ws_info->visual = visual;
|
||||
ws_info->colormap = colormap;
|
||||
ws_info->depth = DepthOfVisual(screen, visual);
|
||||
doupdatewindow = PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (doupdatewindow)
|
||||
mInstance->SetWindow(mWindow);
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// Translate the dirty rect to drawable coordinates.
|
||||
nsIntRect dirtyRect = mDirtyRect + nsIntPoint(offsetX, offsetY);
|
||||
// Intersect the dirty rect with the clip rect to ensure that it lies within
|
||||
@ -4216,11 +4209,11 @@ nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable,
|
||||
// set the drawing info
|
||||
exposeEvent.type = GraphicsExpose;
|
||||
exposeEvent.display = DisplayOfScreen(screen);
|
||||
exposeEvent.drawable = GDK_DRAWABLE_XID(drawable);
|
||||
exposeEvent.x = mDirtyRect.x + offsetX;
|
||||
exposeEvent.y = mDirtyRect.y + offsetY;
|
||||
exposeEvent.width = mDirtyRect.width;
|
||||
exposeEvent.height = mDirtyRect.height;
|
||||
exposeEvent.drawable = drawable;
|
||||
exposeEvent.x = dirtyRect.x;
|
||||
exposeEvent.y = dirtyRect.y;
|
||||
exposeEvent.width = dirtyRect.width;
|
||||
exposeEvent.height = dirtyRect.height;
|
||||
exposeEvent.count = 0;
|
||||
// information not set:
|
||||
exposeEvent.serial = 0;
|
||||
@ -4230,7 +4223,6 @@ nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable,
|
||||
|
||||
PRBool eventHandled = PR_FALSE;
|
||||
mInstance->HandleEvent(&pluginEvent, &eventHandled);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsContentErrors.h"
|
||||
|
||||
#if defined(XP_UNIX) && defined(MOZ_WIDGET_GTK2) & defined(MOZ_X11)
|
||||
#if defined(XP_UNIX) && defined(MOZ_WIDGET_GTK2)
|
||||
#include <gdk/gdkx.h> // for GDK_DISPLAY()
|
||||
#endif
|
||||
|
||||
|
@ -50,9 +50,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
/* Xlib/Xt stuff */
|
||||
|
@ -277,10 +277,8 @@ endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
ifdef MOZ_X11
|
||||
STATIC_LIBS += gtkxtbin
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_IPCD
|
||||
DEFINES += -DMOZ_IPCD
|
||||
|
@ -84,10 +84,8 @@ tier_gecko_dirs += \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
ifdef MOZ_X11
|
||||
tier_gecko_dirs += widget/src/gtkxtbin
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_IPCD
|
||||
tier_gecko_dirs += ipc/ipcd
|
||||
|
@ -269,9 +269,7 @@ static char **gRestartArgv;
|
||||
|
||||
#if defined(MOZ_WIDGET_GTK2)
|
||||
#include <gtk/gtk.h>
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif /* MOZ_X11 */
|
||||
#include "nsGTKToolkit.h"
|
||||
#endif
|
||||
|
||||
@ -2388,7 +2386,6 @@ static void MOZ_gdk_display_close(GdkDisplay *display)
|
||||
// gdk_display_manager_set_default_display (gdk_display_manager_get(), NULL)
|
||||
// was also broken.
|
||||
if (gtk_check_version(2,10,0) != NULL) {
|
||||
#ifdef MOZ_X11
|
||||
// Version check failed - broken gdk_display_close.
|
||||
//
|
||||
// Let the gdk structures leak but at least close the Display,
|
||||
@ -2396,9 +2393,6 @@ static void MOZ_gdk_display_close(GdkDisplay *display)
|
||||
Display* dpy = GDK_DISPLAY_XDISPLAY(display);
|
||||
if (!theme_is_qt)
|
||||
XCloseDisplay(dpy);
|
||||
#else
|
||||
gdk_display_close(display);
|
||||
#endif /* MOZ_X11 */
|
||||
}
|
||||
else {
|
||||
if (!theme_is_qt)
|
||||
|
@ -297,8 +297,6 @@ nsNativeAppSupportUnix::Start(PRBool *aRetVal)
|
||||
|
||||
*aRetVal = PR_TRUE;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
|
||||
PRLibrary *gnomeuiLib = PR_LoadLibrary("libgnomeui-2.so.0");
|
||||
if (!gnomeuiLib)
|
||||
return NS_OK;
|
||||
@ -318,8 +316,6 @@ nsNativeAppSupportUnix::Start(PRBool *aRetVal)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
// We will load gail, atk-bridge by ourself later
|
||||
// We can't run atk-bridge init here, because gail get the control
|
||||
@ -329,9 +325,7 @@ nsNativeAppSupportUnix::Start(PRBool *aRetVal)
|
||||
setenv(accEnv, "0", 1);
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
gnome_program_init("Gecko", "1.0", libgnomeui_module_info_get(), gArgc, gArgv, NULL);
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
if (accOldValue) {
|
||||
@ -345,7 +339,6 @@ nsNativeAppSupportUnix::Start(PRBool *aRetVal)
|
||||
// gnome_program_init causes atexit handlers to be registered. Strange
|
||||
// crashes will occur if these libraries are unloaded.
|
||||
|
||||
#ifdef MOZ_X11
|
||||
gnome_client_request_interaction = (_gnome_client_request_interaction_fn)
|
||||
PR_FindFunctionSymbol(gnomeuiLib, "gnome_client_request_interaction");
|
||||
gnome_interaction_key_return = (_gnome_interaction_key_return_fn)
|
||||
@ -359,7 +352,6 @@ nsNativeAppSupportUnix::Start(PRBool *aRetVal)
|
||||
GnomeClient *client = gnome_master_client();
|
||||
g_signal_connect(client, "save-yourself", G_CALLBACK(save_yourself_cb), NULL);
|
||||
g_signal_connect(client, "die", G_CALLBACK(die_cb), NULL);
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -70,10 +70,8 @@ endif
|
||||
#
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
DIRS += gtk2
|
||||
ifdef MOZ_X11
|
||||
DIRS += gtkxtbin
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_PHOTON
|
||||
DIRS += photon
|
||||
|
@ -63,6 +63,7 @@ REQUIRES = xpcom \
|
||||
necko \
|
||||
uconv \
|
||||
intl \
|
||||
gtkxtbin \
|
||||
imglib2 \
|
||||
view \
|
||||
content \
|
||||
@ -73,10 +74,6 @@ REQUIRES = xpcom \
|
||||
cairo \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_X11
|
||||
REQUIRES += gtkxtbin
|
||||
endif
|
||||
|
||||
ifeq ($(MOZ_ENABLE_GLITZ),1)
|
||||
REQUIRES += glitz glitzglx
|
||||
endif
|
||||
@ -101,6 +98,8 @@ CPPSRCS = \
|
||||
nsCommonWidget.cpp \
|
||||
nsLookAndFeel.cpp \
|
||||
nsGtkKeyUtils.cpp \
|
||||
nsClipboard.cpp \
|
||||
nsDragService.cpp \
|
||||
nsFilePicker.cpp \
|
||||
nsSound.cpp \
|
||||
nsNativeKeyBindings.cpp \
|
||||
@ -113,10 +112,8 @@ CPPSRCS = \
|
||||
ifdef NS_OSSO
|
||||
CPPSRCS += nsIdleServiceOSSO.cpp
|
||||
else
|
||||
ifdef MOZ_X11
|
||||
CPPSRCS += nsIdleServiceGTK.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef NS_PRINTING
|
||||
CPPSRCS += \
|
||||
@ -127,12 +124,6 @@ CPPSRCS += \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ifdef MOZ_X11
|
||||
CPPSRCS += nsClipboard.cpp \
|
||||
nsDragService.cpp \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
# build our subdirs, too
|
||||
ifdef ACCESSIBILITY
|
||||
REQUIRES += accessibility
|
||||
@ -143,6 +134,7 @@ SHARED_LIBRARY_LIBS = ../xpwidgets/libxpwidgets_s.a
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
-lgkgfx \
|
||||
-lgtkxtbin \
|
||||
$(MOZ_STARTUP_NOTIFICATION_LIBS) \
|
||||
$(XLDFLAGS) \
|
||||
$(XLIBS) \
|
||||
@ -151,10 +143,6 @@ EXTRA_DSO_LDOPTS += \
|
||||
$(LCMS_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_X11
|
||||
EXTRA_DSO_LDOPTS += -lgtkxtbin
|
||||
endif
|
||||
|
||||
EXPORTS = \
|
||||
nsGTKToolkit.h \
|
||||
nsIImageToPixbuf.h \
|
||||
|
@ -45,11 +45,7 @@
|
||||
* (UCS, Unicode) values.
|
||||
*/
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#include <X11/X.h>
|
||||
#else
|
||||
#define KeySym unsigned int
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -53,15 +53,8 @@ NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
|
||||
|
||||
nsBidiKeyboard::nsBidiKeyboard()
|
||||
{
|
||||
#if defined(MOZ_X11)
|
||||
if (!gtklib)
|
||||
gtklib = PR_LoadLibrary("libgtk-x11-2.0.so.0");
|
||||
#elif defined(MOZ_DFB)
|
||||
if (!gtklib)
|
||||
gtklib = PR_LoadLibrary("libgtk-directfb-2.0.so.0");
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (gtklib && !GdkKeymapHaveBidiLayouts)
|
||||
GdkKeymapHaveBidiLayouts = (GdkKeymapHaveBidiLayoutsType) PR_FindFunctionSymbol(gtklib, "gdk_keymap_have_bidi_layouts");
|
||||
|
@ -39,9 +39,7 @@
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gdk/gdkevents.h>
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif /* MOZ_X11 */
|
||||
#include "nsGUIEvent.h"
|
||||
#include "keysym2ucs.h"
|
||||
|
||||
@ -156,10 +154,8 @@ struct nsKeyConverter nsKeycodes[] = {
|
||||
{ NS_VK_EQUALS, GDK_plus }
|
||||
};
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#define IS_XSUN_XSERVER(dpy) \
|
||||
(strstr(XServerVendor(dpy), "Sun Microsystems") != NULL)
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
// map Sun Keyboard special keysyms on to NS_VK keys
|
||||
struct nsKeyConverter nsSunKeycodes[] = {
|
||||
@ -197,7 +193,6 @@ GdkKeyCodeToDOMKeyCode(int aKeysym)
|
||||
if (aKeysym >= GDK_KP_0 && aKeysym <= GDK_KP_9)
|
||||
return aKeysym - GDK_KP_0 + NS_VK_NUMPAD0;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// map Sun Keyboard special keysyms
|
||||
if (IS_XSUN_XSERVER(GDK_DISPLAY())) {
|
||||
length = sizeof(nsSunKeycodes) / sizeof(struct nsKeyConverter);
|
||||
@ -206,7 +201,6 @@ GdkKeyCodeToDOMKeyCode(int aKeysym)
|
||||
return(nsSunKeycodes[i].vkCode);
|
||||
}
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
// misc other things
|
||||
length = sizeof(nsKeycodes) / sizeof(struct nsKeyConverter);
|
||||
|
@ -62,15 +62,16 @@
|
||||
#include "nsWidgetAtoms.h"
|
||||
|
||||
#include <gdk/gdkprivate.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxPlatformGtk.h"
|
||||
#include "gfxGdkNativeRenderer.h"
|
||||
#include "gfxXlibNativeRenderer.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsNativeThemeGTK, nsITheme, nsIObserver)
|
||||
|
||||
static int gLastGdkError;
|
||||
static int gLastXError;
|
||||
|
||||
static inline bool IsCheckboxWidgetType(PRUint8 aWidgetType)
|
||||
{
|
||||
@ -615,15 +616,22 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
class ThemeRenderer : public gfxGdkNativeRenderer {
|
||||
static int
|
||||
NativeThemeErrorHandler(Display* dpy, XErrorEvent* error) {
|
||||
gLastXError = error->error_code;
|
||||
return 0;
|
||||
}
|
||||
|
||||
class ThemeRenderer : public gfxXlibNativeRenderer {
|
||||
public:
|
||||
ThemeRenderer(GtkWidgetState aState, GtkThemeWidgetType aGTKWidgetType,
|
||||
gint aFlags, GtkTextDirection aDirection,
|
||||
const GdkRectangle& aGDKRect, const GdkRectangle& aGDKClip)
|
||||
: mState(aState), mGTKWidgetType(aGTKWidgetType), mFlags(aFlags),
|
||||
mDirection(aDirection), mGDKRect(aGDKRect), mGDKClip(aGDKClip) {}
|
||||
nsresult NativeDraw(GdkDrawable * drawable, short offsetX, short offsetY,
|
||||
GdkRectangle * clipRects, PRUint32 numClipRects);
|
||||
nsresult NativeDraw(Screen* screen, Drawable drawable, Visual* visual,
|
||||
Colormap colormap, short offsetX, short offsetY,
|
||||
XRectangle* clipRects, PRUint32 numClipRects);
|
||||
private:
|
||||
GtkWidgetState mState;
|
||||
GtkThemeWidgetType mGTKWidgetType;
|
||||
@ -635,8 +643,9 @@ private:
|
||||
};
|
||||
|
||||
nsresult
|
||||
ThemeRenderer::NativeDraw(GdkDrawable * drawable, short offsetX,
|
||||
short offsetY, GdkRectangle * clipRects, PRUint32 numClipRects)
|
||||
ThemeRenderer::NativeDraw(Screen* screen, Drawable drawable, Visual* visual,
|
||||
Colormap colormap, short offsetX, short offsetY,
|
||||
XRectangle* clipRects, PRUint32 numClipRects)
|
||||
{
|
||||
GdkRectangle gdk_rect = mGDKRect;
|
||||
gdk_rect.x += offsetX;
|
||||
@ -646,10 +655,38 @@ ThemeRenderer::NativeDraw(GdkDrawable * drawable, short offsetX,
|
||||
gdk_clip.x += offsetX;
|
||||
gdk_clip.y += offsetY;
|
||||
|
||||
NS_ASSERTION(numClipRects == 0, "We don't support clipping!!!");
|
||||
moz_gtk_widget_paint(mGTKWidgetType, drawable, &gdk_rect, &gdk_clip,
|
||||
&mState, mFlags, mDirection);
|
||||
GdkDisplay* gdkDpy = gdk_x11_lookup_xdisplay(DisplayOfScreen(screen));
|
||||
if (!gdkDpy)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
GdkPixmap* gdkPixmap = gdk_pixmap_lookup_for_display(gdkDpy, drawable);
|
||||
if (gdkPixmap) {
|
||||
g_object_ref(G_OBJECT(gdkPixmap));
|
||||
} else {
|
||||
// XXX gtk+-2.10 has gdk_pixmap_foreign_new_for_screen which would not
|
||||
// use XGetGeometry.
|
||||
gdkPixmap = gdk_pixmap_foreign_new_for_display(gdkDpy, drawable);
|
||||
if (!gdkPixmap)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// We requested that gfxXlibNativeRenderer give us the default screen
|
||||
GdkScreen* gdkScreen = gdk_display_get_default_screen(gdkDpy);
|
||||
NS_ASSERTION(screen == GDK_SCREEN_XSCREEN(gdkScreen),
|
||||
"'screen' should be the default Screen");
|
||||
// GDK requires a GdkColormap to be set on the GdkPixmap.
|
||||
GdkVisual* gdkVisual =
|
||||
gdk_x11_screen_lookup_visual(gdkScreen, visual->visualid);
|
||||
GdkColormap* gdkColormap =
|
||||
gdk_x11_colormap_foreign_new(gdkVisual, colormap);
|
||||
gdk_drawable_set_colormap(gdkPixmap, gdkColormap);
|
||||
g_object_unref(G_OBJECT(gdkColormap));
|
||||
}
|
||||
|
||||
NS_ASSERTION(numClipRects == 0, "We don't support clipping!!!");
|
||||
moz_gtk_widget_paint(mGTKWidgetType, gdkPixmap, &gdk_rect, &gdk_clip, &mState,
|
||||
mFlags, mDirection);
|
||||
|
||||
g_object_unref(G_OBJECT(gdkPixmap));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -767,8 +804,8 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
|
||||
// Some themes (e.g. Clearlooks) just don't clip properly to any
|
||||
// clip rect we provide, so we cannot advertise support for clipping within
|
||||
// the widget bounds.
|
||||
PRUint32 rendererFlags = gfxGdkNativeRenderer::DRAW_SUPPORTS_OFFSET;
|
||||
|
||||
PRUint32 rendererFlags = gfxXlibNativeRenderer::DRAW_SUPPORTS_OFFSET;
|
||||
|
||||
// translate everything so (0,0) is the top left of the drawingRect
|
||||
gfxContextAutoSaveRestore autoSR(ctx);
|
||||
if (snapXY) {
|
||||
@ -781,22 +818,25 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
|
||||
"Trying to render an unsafe widget!");
|
||||
|
||||
PRBool safeState = IsWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
|
||||
XErrorHandler oldHandler = nsnull;
|
||||
if (!safeState) {
|
||||
gLastGdkError = 0;
|
||||
gdk_error_trap_push ();
|
||||
gLastXError = 0;
|
||||
oldHandler = XSetErrorHandler(NativeThemeErrorHandler);
|
||||
}
|
||||
|
||||
renderer.Draw(ctx, drawingRect.width, drawingRect.height, rendererFlags, nsnull);
|
||||
renderer.Draw(gdk_x11_get_default_xdisplay(), ctx,
|
||||
drawingRect.width, drawingRect.height,
|
||||
rendererFlags, nsnull);
|
||||
|
||||
if (!safeState) {
|
||||
gdk_flush();
|
||||
gLastGdkError = gdk_error_trap_pop ();
|
||||
XSetErrorHandler(oldHandler);
|
||||
|
||||
if (gLastGdkError) {
|
||||
if (gLastXError) {
|
||||
#ifdef DEBUG
|
||||
printf("GTK theme failed for widget type %d, error was %d, state was "
|
||||
"[active=%d,focused=%d,inHover=%d,disabled=%d]\n",
|
||||
aWidgetType, gLastGdkError, state.active, state.focused,
|
||||
aWidgetType, gLastXError, state.active, state.focused,
|
||||
state.inHover, state.disabled);
|
||||
#endif
|
||||
NS_WARNING("GTK theme failed; disabling unsafe widget");
|
||||
|
@ -38,12 +38,9 @@
|
||||
|
||||
#include "nsScreenGtk.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/Xatom.h>
|
||||
#endif
|
||||
#include <gtk/gtk.h>
|
||||
#include <X11/Xatom.h>
|
||||
|
||||
nsScreenGtk :: nsScreenGtk ( )
|
||||
: mScreenNum(0),
|
||||
@ -116,7 +113,6 @@ nsScreenGtk :: Init (GdkWindow *aRootWindow)
|
||||
// versions of GDK predating the GdkScreen object. See bug 256646.
|
||||
mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// We need to account for the taskbar, etc in the available rect.
|
||||
// See http://freedesktop.org/Standards/wm-spec/index.html#id2767771
|
||||
|
||||
@ -180,10 +176,8 @@ nsScreenGtk :: Init (GdkWindow *aRootWindow)
|
||||
}
|
||||
}
|
||||
g_free (workareas);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
void
|
||||
nsScreenGtk :: Init (XineramaScreenInfo *aScreenInfo)
|
||||
{
|
||||
@ -194,4 +188,3 @@ nsScreenGtk :: Init (XineramaScreenInfo *aScreenInfo)
|
||||
|
||||
mAvailRect = mRect = xineRect;
|
||||
}
|
||||
#endif
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIScreen.h"
|
||||
#include "nsRect.h"
|
||||
#include "gdk/gdk.h"
|
||||
#ifdef MOZ_X11
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
// from Xinerama.h
|
||||
@ -52,7 +51,6 @@ typedef struct {
|
||||
short width;
|
||||
short height;
|
||||
} XineramaScreenInfo;
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
@ -66,9 +64,7 @@ public:
|
||||
NS_DECL_NSISCREEN
|
||||
|
||||
void Init(GdkWindow *aRootWindow);
|
||||
#ifdef MOZ_X11
|
||||
void Init(XineramaScreenInfo *aScreenInfo);
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
private:
|
||||
PRUint32 mScreenNum;
|
||||
|
@ -43,29 +43,21 @@
|
||||
#include "nsRect.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define SCREEN_MANAGER_LIBRARY_LOAD_FAILED ((PRLibrary*)1)
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
#include <directfb.h>
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
// prototypes from Xinerama.h
|
||||
typedef Bool (*_XnrmIsActive_fn)(Display *dpy);
|
||||
typedef XineramaScreenInfo* (*_XnrmQueryScreens_fn)(Display *dpy, int *number);
|
||||
#endif
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
static GdkFilterReturn
|
||||
root_window_event_filter(GdkXEvent *aGdkXEvent, GdkEvent *aGdkEvent,
|
||||
gpointer aClosure)
|
||||
{
|
||||
nsScreenManagerGtk *manager = static_cast<nsScreenManagerGtk*>(aClosure);
|
||||
#ifdef MOZ_X11
|
||||
XEvent *xevent = static_cast<XEvent*>(aGdkXEvent);
|
||||
nsScreenManagerGtk *manager = static_cast<nsScreenManagerGtk*>(aClosure);
|
||||
|
||||
// See comments in nsScreenGtk::Init below.
|
||||
switch (xevent->type) {
|
||||
@ -83,24 +75,6 @@ root_window_event_filter(GdkXEvent *aGdkXEvent, GdkEvent *aGdkEvent,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
DFBWindowEvent * dfbEvent = static_cast<DFBWindowEvent *> (aGdkXEvent);
|
||||
|
||||
switch (dfbEvent->type)
|
||||
{
|
||||
case DWET_POSITION :
|
||||
case DWET_SIZE :
|
||||
manager->Init();
|
||||
break;
|
||||
|
||||
/* TODO: Need to find out PropertyNotify equivalent in
|
||||
* DFB.. */
|
||||
default :
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
@ -123,11 +97,9 @@ nsScreenManagerGtk :: ~nsScreenManagerGtk()
|
||||
mRootWindow = nsnull;
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
if (mXineramalib && mXineramalib != SCREEN_MANAGER_LIBRARY_LOAD_FAILED) {
|
||||
PR_UnloadLibrary(mXineramalib);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -156,10 +128,8 @@ nsScreenManagerGtk :: EnsureInit()
|
||||
GDK_STRUCTURE_MASK |
|
||||
GDK_PROPERTY_CHANGE_MASK));
|
||||
gdk_window_add_filter(mRootWindow, root_window_event_filter, this);
|
||||
#ifdef MOZ_X11
|
||||
mNetWorkareaAtom =
|
||||
XInternAtom(GDK_WINDOW_XDISPLAY(mRootWindow), "_NET_WORKAREA", False);
|
||||
#endif
|
||||
|
||||
return Init();
|
||||
}
|
||||
@ -167,7 +137,6 @@ nsScreenManagerGtk :: EnsureInit()
|
||||
nsresult
|
||||
nsScreenManagerGtk :: Init()
|
||||
{
|
||||
#ifdef MOZ_X11
|
||||
XineramaScreenInfo *screenInfo = NULL;
|
||||
int numScreens;
|
||||
|
||||
@ -193,9 +162,8 @@ nsScreenManagerGtk :: Init()
|
||||
// screenInfo == NULL if either Xinerama couldn't be loaded or
|
||||
// isn't running on the current display
|
||||
if (!screenInfo || numScreens == 1) {
|
||||
numScreens = 1;
|
||||
#endif
|
||||
nsRefPtr<nsScreenGtk> screen;
|
||||
numScreens = 1;
|
||||
|
||||
if (mCachedScreenArray.Count() > 0) {
|
||||
screen = static_cast<nsScreenGtk*>(mCachedScreenArray[0]);
|
||||
@ -207,7 +175,6 @@ nsScreenManagerGtk :: Init()
|
||||
}
|
||||
|
||||
screen->Init(mRootWindow);
|
||||
#ifdef MOZ_X11
|
||||
}
|
||||
// If Xinerama is enabled and there's more than one screen, fill
|
||||
// in the info for all of the screens. If that's not the case
|
||||
@ -239,7 +206,6 @@ nsScreenManagerGtk :: Init()
|
||||
if (screenInfo) {
|
||||
XFree(screenInfo);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -45,9 +45,7 @@
|
||||
#include "nsCOMArray.h"
|
||||
#include "prlink.h"
|
||||
#include "gdk/gdk.h"
|
||||
#ifdef MOZ_X11
|
||||
#include <X11/Xlib.h>
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
@ -60,9 +58,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISCREENMANAGER
|
||||
|
||||
#ifdef MOZ_X11
|
||||
Atom NetWorkareaAtom() { return mNetWorkareaAtom; }
|
||||
#endif
|
||||
|
||||
// For internal use, or reinitialization from change notification.
|
||||
nsresult Init();
|
||||
@ -77,9 +73,7 @@ private:
|
||||
PRLibrary *mXineramalib;
|
||||
|
||||
GdkWindow *mRootWindow;
|
||||
#ifdef MOZ_X11
|
||||
Atom mNetWorkareaAtom;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // nsScreenManagerGtk_h___
|
||||
|
@ -225,7 +225,6 @@ static const nsModuleComponentInfo components[] =
|
||||
NS_TRANSFERABLE_CID,
|
||||
"@mozilla.org/widget/transferable;1",
|
||||
nsTransferableConstructor },
|
||||
#ifdef MOZ_X11
|
||||
{ "Gtk Clipboard",
|
||||
NS_CLIPBOARD_CID,
|
||||
"@mozilla.org/widget/clipboard;1",
|
||||
@ -238,7 +237,6 @@ static const nsModuleComponentInfo components[] =
|
||||
NS_DRAGSERVICE_CID,
|
||||
"@mozilla.org/widget/dragservice;1",
|
||||
nsDragServiceConstructor },
|
||||
#endif
|
||||
{ "HTML Format Converter",
|
||||
NS_HTMLFORMATCONVERTER_CID,
|
||||
"@mozilla.org/widget/htmlformatconverter;1",
|
||||
|
@ -57,12 +57,9 @@
|
||||
#include "nsGtkCursors.h"
|
||||
|
||||
#include <gtk/gtkwindow.h>
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#include <X11/XF86keysym.h>
|
||||
#include "gtk2xtbin.h"
|
||||
#endif /* MOZ_X11 */
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <X11/XF86keysym.h>
|
||||
|
||||
#include "nsWidgetAtoms.h"
|
||||
|
||||
@ -71,6 +68,8 @@
|
||||
#include <startup-notification-1.0/libsn/sn.h>
|
||||
#endif
|
||||
|
||||
#include "gtk2xtbin.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIServiceManager.h"
|
||||
@ -109,29 +108,10 @@ static const char sAccessibilityKey [] = "config.use_system_prefs.accessibility"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
#include "gfxPlatformGtk.h"
|
||||
#include "gfxXlibSurface.h"
|
||||
#include "gfxContext.h"
|
||||
#include "gfxImageSurface.h"
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#include "gfxXlibSurface.h"
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
extern "C" {
|
||||
#ifdef MOZ_DIRECT_DEBUG
|
||||
#define DIRECT_ENABLE_DEBUG
|
||||
#endif
|
||||
|
||||
#include <direct/debug.h>
|
||||
|
||||
D_DEBUG_DOMAIN( ns_Window, "nsWindow", "nsWindow" );
|
||||
}
|
||||
#include "gfxDirectFBSurface.h"
|
||||
#define GDK_WINDOW_XWINDOW(_win) _win
|
||||
#else
|
||||
#define D_DEBUG_AT(x,y...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_ENABLE_GLITZ
|
||||
#include "gfxGlitzSurface.h"
|
||||
#include "glitz-glx.h"
|
||||
@ -204,14 +184,12 @@ static nsWindow* GetFirstNSWindowForGDKWindow (GdkWindow *aGdkWindow);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#ifdef MOZ_X11
|
||||
static GdkFilterReturn plugin_window_filter_func (GdkXEvent *gdk_xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static GdkFilterReturn plugin_client_message_filter (GdkXEvent *xevent,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
#endif /* MOZ_X11 */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
@ -242,12 +220,10 @@ static void drag_data_received_event_cb(GtkWidget *aWidget,
|
||||
gpointer aData);
|
||||
|
||||
static GdkModifierType gdk_keyboard_get_modifiers();
|
||||
#ifdef MOZ_X11
|
||||
static PRBool gdk_keyboard_get_modmap_masks(Display* aDisplay,
|
||||
PRUint32* aCapsLockMask,
|
||||
PRUint32* aNumLockMask,
|
||||
PRUint32* aScrollLockMask);
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
/* initialization static functions */
|
||||
static nsresult initialize_prefs (void);
|
||||
@ -347,9 +323,7 @@ nsWindow::nsWindow()
|
||||
mTransientParent = nsnull;
|
||||
mWindowType = eWindowType_child;
|
||||
mSizeState = nsSizeMode_Normal;
|
||||
#ifdef MOZ_X11
|
||||
mOldFocusWindow = 0;
|
||||
#endif /* MOZ_X11 */
|
||||
mPluginType = PluginType_NONE;
|
||||
|
||||
if (!gGlobalsInitialized) {
|
||||
@ -383,16 +357,6 @@ nsWindow::nsWindow()
|
||||
|
||||
mTransparencyBitmapWidth = 0;
|
||||
mTransparencyBitmapHeight = 0;
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
mDFBCursorX = 0;
|
||||
mDFBCursorY = 0;
|
||||
|
||||
mDFBCursorCount = 0;
|
||||
|
||||
mDFB = NULL;
|
||||
mDFBLayer = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsWindow::~nsWindow()
|
||||
@ -405,14 +369,6 @@ nsWindow::~nsWindow()
|
||||
delete[] mTransparencyBitmap;
|
||||
mTransparencyBitmap = nsnull;
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
if (mDFBLayer)
|
||||
mDFBLayer->Release( mDFBLayer );
|
||||
|
||||
if (mDFB)
|
||||
mDFB->Release( mDFB );
|
||||
#endif
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
||||
@ -502,12 +458,10 @@ nsWindow::Destroy(void)
|
||||
gFocusWindow = nsnull;
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// make sure that we remove ourself as the plugin focus window
|
||||
if (gPluginFocusWindow == this) {
|
||||
gPluginFocusWindow->LoseNonXEmbedPluginFocus();
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
if (mWindowGroup) {
|
||||
g_object_unref(G_OBJECT(mWindowGroup));
|
||||
@ -1274,13 +1228,6 @@ nsWindow::Scroll(PRInt32 aDx,
|
||||
if (!mDrawingarea)
|
||||
return NS_OK;
|
||||
|
||||
D_DEBUG_AT( ns_Window, "%s( %4d,%4d )\n", __FUNCTION__, aDx, aDy );
|
||||
|
||||
if (aClipRect) {
|
||||
D_DEBUG_AT( ns_Window, " -> aClipRect: %4d,%4d-%4dx%4d\n",
|
||||
aClipRect->x, aClipRect->y, aClipRect->width, aClipRect->height );
|
||||
}
|
||||
|
||||
moz_drawingarea_scroll(mDrawingarea, aDx, aDy);
|
||||
|
||||
// Update bounds on our child windows
|
||||
@ -1334,11 +1281,7 @@ nsWindow::GetNativeData(PRUint32 aDataType)
|
||||
break;
|
||||
|
||||
case NS_NATIVE_DISPLAY:
|
||||
#ifdef MOZ_X11
|
||||
return GDK_DISPLAY();
|
||||
#else
|
||||
return nsnull;
|
||||
#endif /* MOZ_X11 */
|
||||
break;
|
||||
|
||||
case NS_NATIVE_GRAPHIC: {
|
||||
@ -1616,7 +1559,6 @@ nsWindow::LoseFocus(void)
|
||||
#define WANT_PAINT_FLASHING \
|
||||
(debug_WantPaintFlashing() && CAPS_LOCK_IS_ON)
|
||||
|
||||
#ifdef MOZ_X11
|
||||
static void
|
||||
gdk_window_flash(GdkWindow * aGdkWindow,
|
||||
unsigned int aTimes,
|
||||
@ -1676,7 +1618,6 @@ gdk_window_flash(GdkWindow * aGdkWindow,
|
||||
|
||||
gdk_region_offset(aRegion, -x, -y);
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
#endif // DEBUG
|
||||
|
||||
gboolean
|
||||
@ -1720,28 +1661,6 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
||||
LOGDRAW(("\t%d %d %d %d\n", r->x, r->y, r->width, r->height));
|
||||
}
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
nsCOMPtr<nsIRenderingContext> rc = getter_AddRefs(GetRenderingContext());
|
||||
if (NS_UNLIKELY(!rc)) {
|
||||
g_free(rects);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// do double-buffering and clipping here
|
||||
nsRefPtr<gfxContext> ctx = rc->ThebesContext();
|
||||
|
||||
gfxPlatformGtk::GetPlatform()->SetGdkDrawable(ctx->OriginalSurface(), GDK_DRAWABLE(mDrawingarea->inner_window));
|
||||
|
||||
// clip to the update region
|
||||
ctx->Save();
|
||||
ctx->NewPath();
|
||||
for (r = rects; r < r_end; ++r) {
|
||||
ctx->Rectangle(gfxRect(r->x, r->y, r->width, r->height));
|
||||
}
|
||||
ctx->Clip();
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
nsCOMPtr<nsIRenderingContext> rc = getter_AddRefs(GetRenderingContext());
|
||||
if (NS_UNLIKELY(!rc)) {
|
||||
g_free(rects);
|
||||
@ -1789,7 +1708,6 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
||||
GdkDrawable* d = GDK_DRAWABLE(mDrawingarea->inner_window);
|
||||
gint depth = gdk_drawable_get_depth(d);
|
||||
bufferPixmap = gdk_pixmap_new(d, boundsRect.width, boundsRect.height, depth);
|
||||
|
||||
if (bufferPixmap) {
|
||||
bufferPixmapSurface = GetSurfaceForGdkDrawable(GDK_DRAWABLE(bufferPixmap),
|
||||
boundsRect.Size());
|
||||
@ -1797,9 +1715,6 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
||||
bufferPixmapSurface = nsnull;
|
||||
}
|
||||
if (bufferPixmapSurface) {
|
||||
gfxPlatformGtk::GetPlatform()->SetGdkDrawable(
|
||||
static_cast<gfxASurface *>(bufferPixmapSurface),
|
||||
GDK_DRAWABLE(bufferPixmap));
|
||||
bufferPixmapSurface->SetDeviceOffset(gfxPoint(-boundsRect.x, -boundsRect.y));
|
||||
nsCOMPtr<nsIRenderingContext> newRC;
|
||||
nsresult rv = GetDeviceContext()->
|
||||
@ -1829,8 +1744,6 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // MOZ_X11
|
||||
|
||||
nsPaintEvent event(PR_TRUE, NS_PAINT, this);
|
||||
event.refPoint.x = aEvent->area.x;
|
||||
event.refPoint.y = aEvent->area.y;
|
||||
@ -1841,7 +1754,6 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// DispatchEvent can Destroy us (bug 378273), avoid doing any paint
|
||||
// operations below if that happened - it will lead to XError and exit().
|
||||
if (NS_LIKELY(!mIsDestroyed)) {
|
||||
@ -1897,11 +1809,6 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
|
||||
|
||||
ctx->Restore();
|
||||
}
|
||||
#endif // MOZ_X11
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
ctx->Restore();
|
||||
#endif
|
||||
|
||||
g_free(rects);
|
||||
|
||||
@ -2042,63 +1949,6 @@ nsWindow::OnLeaveNotifyEvent(GtkWidget *aWidget, GdkEventCrossing *aEvent)
|
||||
DispatchEvent(&event, status);
|
||||
}
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
void
|
||||
nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
|
||||
{
|
||||
int cursorX = (int) aEvent->x_root;
|
||||
int cursorY = (int) aEvent->y_root;
|
||||
|
||||
D_DEBUG_AT( ns_Window, "%s( %4d,%4d - [%d] )\n", __FUNCTION__, cursorX, cursorY, mDFBCursorCount );
|
||||
|
||||
D_ASSUME( mDFBLayer != NULL );
|
||||
|
||||
if (mDFBLayer)
|
||||
mDFBLayer->GetCursorPosition( mDFBLayer, &cursorX, &cursorY );
|
||||
|
||||
mDFBCursorCount++;
|
||||
|
||||
#if D_DEBUG_ENABLED
|
||||
if (cursorX != (int) aEvent->x_root || cursorY != (int) aEvent->y_root)
|
||||
D_DEBUG_AT( ns_Window, " -> forward to %4d,%4d\n", cursorX, cursorY );
|
||||
#endif
|
||||
|
||||
if (cursorX == mDFBCursorX && cursorY == mDFBCursorY) {
|
||||
D_DEBUG_AT( ns_Window, " -> dropping %4d,%4d\n", cursorX, cursorY );
|
||||
|
||||
/* drop zero motion */
|
||||
return;
|
||||
}
|
||||
|
||||
mDFBCursorX = cursorX;
|
||||
mDFBCursorY = cursorY;
|
||||
|
||||
|
||||
// when we receive this, it must be that the gtk dragging is over,
|
||||
// it is dropped either in or out of mozilla, clear the flag
|
||||
sIsDraggingOutOf = PR_FALSE;
|
||||
|
||||
nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, this, nsMouseEvent::eReal);
|
||||
|
||||
nsRect windowRect;
|
||||
ScreenToWidget(nsRect(nscoord(cursorX), nscoord(cursorY), 1, 1), windowRect);
|
||||
|
||||
event.refPoint.x = windowRect.x;
|
||||
event.refPoint.y = windowRect.y;
|
||||
|
||||
event.isShift = (aEvent->state & GDK_SHIFT_MASK)
|
||||
? PR_TRUE : PR_FALSE;
|
||||
event.isControl = (aEvent->state & GDK_CONTROL_MASK)
|
||||
? PR_TRUE : PR_FALSE;
|
||||
event.isAlt = (aEvent->state & GDK_MOD1_MASK)
|
||||
? PR_TRUE : PR_FALSE;
|
||||
|
||||
event.time = aEvent->time;
|
||||
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
}
|
||||
#else
|
||||
void
|
||||
nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
|
||||
{
|
||||
@ -2109,10 +1959,8 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
|
||||
// see if we can compress this event
|
||||
// XXXldb Why skip every other motion event when we have multiple,
|
||||
// but not more than that?
|
||||
PRPackedBool synthEvent = PR_FALSE;
|
||||
#ifdef MOZ_X11
|
||||
XEvent xevent;
|
||||
|
||||
PRPackedBool synthEvent = PR_FALSE;
|
||||
while (XCheckWindowEvent(GDK_WINDOW_XDISPLAY(aEvent->window),
|
||||
GDK_WINDOW_XWINDOW(aEvent->window),
|
||||
ButtonMotionMask, &xevent)) {
|
||||
@ -2124,12 +1972,10 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
|
||||
nsRefPtr<nsWindow> kungFuDeathGrip = gPluginFocusWindow;
|
||||
gPluginFocusWindow->LoseNonXEmbedPluginFocus();
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, this, nsMouseEvent::eReal);
|
||||
|
||||
if (synthEvent) {
|
||||
#ifdef MOZ_X11
|
||||
event.refPoint.x = nscoord(xevent.xmotion.x);
|
||||
event.refPoint.y = nscoord(xevent.xmotion.y);
|
||||
|
||||
@ -2141,19 +1987,6 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
|
||||
? PR_TRUE : PR_FALSE;
|
||||
|
||||
event.time = xevent.xmotion.time;
|
||||
#else
|
||||
event.refPoint.x = nscoord(aEvent->x);
|
||||
event.refPoint.y = nscoord(aEvent->y);
|
||||
|
||||
event.isShift = (aEvent->state & GDK_SHIFT_MASK)
|
||||
? PR_TRUE : PR_FALSE;
|
||||
event.isControl = (aEvent->state & GDK_CONTROL_MASK)
|
||||
? PR_TRUE : PR_FALSE;
|
||||
event.isAlt = (aEvent->state & GDK_MOD1_MASK)
|
||||
? PR_TRUE : PR_FALSE;
|
||||
|
||||
event.time = aEvent->time;
|
||||
#endif /* MOZ_X11 */
|
||||
}
|
||||
else {
|
||||
// XXX see OnScrollEvent()
|
||||
@ -2181,7 +2014,6 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsWindow::InitButtonEvent(nsMouseEvent &aEvent,
|
||||
@ -2383,13 +2215,11 @@ nsWindow::OnContainerFocusOutEvent(GtkWidget *aWidget, GdkEventFocus *aEvent)
|
||||
{
|
||||
LOGFOCUS(("OnContainerFocusOutEvent [%p]\n", (void *)this));
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// plugin lose focus
|
||||
if (gPluginFocusWindow) {
|
||||
nsRefPtr<nsWindow> kungFuDeathGrip = gPluginFocusWindow;
|
||||
gPluginFocusWindow->LoseNonXEmbedPluginFocus();
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
// Figure out if the focus widget is the child of this window. If
|
||||
// it is, send a focus out and deactivate event for it.
|
||||
@ -2548,7 +2378,6 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// Look for specialized app-command keys
|
||||
switch (aEvent->keyval) {
|
||||
case XF86XK_Back:
|
||||
@ -2566,7 +2395,6 @@ nsWindow::OnKeyPressEvent(GtkWidget *aWidget, GdkEventKey *aEvent)
|
||||
case XF86XK_HomePage:
|
||||
return DispatchCommandEvent(nsWidgetAtoms::Home);
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
nsKeyEvent event(PR_TRUE, NS_KEY_PRESS, this);
|
||||
InitKeyEvent(event, aEvent);
|
||||
@ -3422,13 +3250,8 @@ nsWindow::NativeCreate(nsIWidget *aParent,
|
||||
}
|
||||
// Disable the double buffer because it will make the caret crazy
|
||||
// For bug#153805 (Gtk2 double buffer makes carets misbehave)
|
||||
// DirectFB's expose code depends on gtk double buffering
|
||||
// XXX - I think this bug is probably dead, we can just use gtk's
|
||||
// double-buffering everywhere
|
||||
#ifdef MOZ_X11
|
||||
if (mContainer)
|
||||
gtk_widget_set_double_buffered (GTK_WIDGET(mContainer),FALSE);
|
||||
#endif
|
||||
|
||||
// label the drawing area with this object so we can find our way
|
||||
// home
|
||||
@ -3572,22 +3395,6 @@ nsWindow::NativeCreate(nsIWidget *aParent,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
if (!mDFB) {
|
||||
DirectFBCreate( &mDFB );
|
||||
|
||||
D_ASSUME( mDFB != NULL );
|
||||
|
||||
if (mDFB)
|
||||
mDFB->GetDisplayLayer( mDFB, DLID_PRIMARY, &mDFBLayer );
|
||||
|
||||
D_ASSUME( mDFBLayer != NULL );
|
||||
|
||||
if (mDFBLayer)
|
||||
mDFBLayer->GetCursorPosition( mDFBLayer, &mDFBCursorX, &mDFBCursorY );
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -3597,7 +3404,6 @@ nsWindow::SetWindowClass(const nsAString &xulWinType)
|
||||
if (!mShell)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
nsXPIDLString brandName;
|
||||
GetBrandName(brandName);
|
||||
|
||||
@ -3641,39 +3447,6 @@ nsWindow::SetWindowClass(const nsAString &xulWinType)
|
||||
nsMemory::Free(class_hint->res_class);
|
||||
nsMemory::Free(class_hint->res_name);
|
||||
XFree(class_hint);
|
||||
#else /* MOZ_X11 */
|
||||
|
||||
char *res_name;
|
||||
|
||||
res_name = ToNewCString(xulWinType);
|
||||
if (!res_name)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
printf("WARN: res_name = '%s'\n", res_name);
|
||||
|
||||
|
||||
const char *role = NULL;
|
||||
|
||||
// Parse res_name into a name and role. Characters other than
|
||||
// [A-Za-z0-9_-] are converted to '_'. Anything after the first
|
||||
// colon is assigned to role; if there's no colon, assign the
|
||||
// whole thing to both role and res_name.
|
||||
for (char *c = res_name; *c; c++) {
|
||||
if (':' == *c) {
|
||||
*c = 0;
|
||||
role = c + 1;
|
||||
}
|
||||
else if (!isascii(*c) || (!isalnum(*c) && ('_' != *c) && ('-' != *c)))
|
||||
*c = '_';
|
||||
}
|
||||
res_name[0] = toupper(res_name[0]);
|
||||
if (!role) role = res_name;
|
||||
|
||||
gdk_window_set_role(GTK_WIDGET(mShell)->window, role);
|
||||
|
||||
nsMemory::Free(res_name);
|
||||
|
||||
#endif /* MOZ_X11 */
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -4197,7 +3970,6 @@ nsWindow::SetupPluginPort(void)
|
||||
// we have to flush the X queue here so that any plugins that
|
||||
// might be running on separate X connections will be able to use
|
||||
// this window in case it was just created
|
||||
#ifdef MOZ_X11
|
||||
XWindowAttributes xattrs;
|
||||
XGetWindowAttributes(GDK_DISPLAY (),
|
||||
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window),
|
||||
@ -4212,7 +3984,6 @@ nsWindow::SetupPluginPort(void)
|
||||
this);
|
||||
|
||||
XSync(GDK_DISPLAY(), False);
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
return (void *)GDK_WINDOW_XWINDOW(mDrawingarea->inner_window);
|
||||
}
|
||||
@ -4256,7 +4027,6 @@ nsWindow::SetPluginType(PluginType aPluginType)
|
||||
mPluginType = aPluginType;
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
void
|
||||
nsWindow::SetNonXEmbedPluginFocus()
|
||||
{
|
||||
@ -4351,7 +4121,6 @@ nsWindow::LoseNonXEmbedPluginFocus()
|
||||
|
||||
LOGFOCUS(("nsWindow::LoseNonXEmbedPluginFocus end\n"));
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
|
||||
gint
|
||||
@ -4435,11 +4204,7 @@ nsWindow::HideWindowChrome(PRBool aShouldHide)
|
||||
// and flush the queue here so that we don't end up with a BadWindow
|
||||
// error later when this happens (when the persistence timer fires
|
||||
// and GetWindowPos is called)
|
||||
#ifdef MOZ_X11
|
||||
XSync(GDK_DISPLAY(), False);
|
||||
#else
|
||||
gdk_flush ();
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -4947,7 +4712,6 @@ focus_out_event_cb(GtkWidget *widget, GdkEventFocus *event)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
/* static */
|
||||
GdkFilterReturn
|
||||
plugin_window_filter_func(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
|
||||
@ -5046,7 +4810,6 @@ plugin_client_message_filter(GdkXEvent *gdk_xevent,
|
||||
|
||||
return return_val;
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
/* static */
|
||||
gboolean
|
||||
@ -5433,7 +5196,6 @@ gdk_keyboard_get_modifiers()
|
||||
return m;
|
||||
}
|
||||
|
||||
#ifdef MOZ_X11
|
||||
// Get the modifier masks for GDK_Caps_Lock, GDK_Num_Lock and GDK_Scroll_Lock.
|
||||
// Return PR_TRUE on success, PR_FALSE on error.
|
||||
static PRBool
|
||||
@ -5491,7 +5253,6 @@ gdk_keyboard_get_modmap_masks(Display* aDisplay,
|
||||
XFree(xkeymap);
|
||||
return PR_TRUE;
|
||||
}
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
/**
|
||||
@ -6149,8 +5910,6 @@ nsWindow::GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aLEDState);
|
||||
|
||||
#ifdef MOZ_X11
|
||||
|
||||
GdkModifierType modifiers = gdk_keyboard_get_modifiers();
|
||||
PRUint32 capsLockMask, numLockMask, scrollLockMask;
|
||||
PRBool foundMasks = gdk_keyboard_get_modmap_masks(
|
||||
@ -6170,9 +5929,6 @@ nsWindow::GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState)
|
||||
|
||||
*aLEDState = (modifiers & mask) != 0;
|
||||
return NS_OK;
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif /* MOZ_X11 */
|
||||
}
|
||||
|
||||
/* static */
|
||||
@ -6451,7 +6207,6 @@ IM_get_input_context(nsWindow *aWindow)
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_X11
|
||||
/* static */ already_AddRefed<gfxASurface>
|
||||
nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
|
||||
const nsSize& aSize)
|
||||
@ -6466,40 +6221,81 @@ nsWindow::GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
|
||||
NS_IF_ADDREF(result);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
// return the gfxASurface for rendering to this widget
|
||||
gfxASurface*
|
||||
nsWindow::GetThebesSurface()
|
||||
{
|
||||
GdkDrawable* d;
|
||||
gint x_offset, y_offset;
|
||||
gdk_window_get_internal_paint_info(mDrawingarea->inner_window,
|
||||
&d, &x_offset, &y_offset);
|
||||
// XXXvlad always create a new thebes surface for now,
|
||||
// because the old clip doesn't get cleared otherwise.
|
||||
// we should fix this at some point, and just reset
|
||||
// the clip.
|
||||
mThebesSurface = nsnull;
|
||||
|
||||
#ifdef MOZ_X11
|
||||
gint width, height;
|
||||
gdk_drawable_get_size(d, &width, &height);
|
||||
// Owen Taylor says this is the right thing to do!
|
||||
width = PR_MIN(32767, width);
|
||||
height = PR_MIN(32767, height);
|
||||
if (!mThebesSurface) {
|
||||
GdkDrawable* d;
|
||||
gint x_offset, y_offset;
|
||||
gdk_window_get_internal_paint_info(mDrawingarea->inner_window,
|
||||
&d, &x_offset, &y_offset);
|
||||
|
||||
mThebesSurface = new gfxXlibSurface
|
||||
(GDK_WINDOW_XDISPLAY(d),
|
||||
GDK_WINDOW_XWINDOW(d),
|
||||
GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(d)),
|
||||
gfxIntSize(width, height));
|
||||
#endif
|
||||
#ifdef MOZ_DFB
|
||||
mThebesSurface = new gfxDirectFBSurface(gdk_directfb_surface_lookup(d));
|
||||
gint width, height;
|
||||
gdk_drawable_get_size(d, &width, &height);
|
||||
// Owen Taylor says this is the right thing to do!
|
||||
width = PR_MIN(32767, width);
|
||||
height = PR_MIN(32767, height);
|
||||
|
||||
if (!gfxPlatform::UseGlitz()) {
|
||||
mThebesSurface = new gfxXlibSurface
|
||||
(GDK_WINDOW_XDISPLAY(d),
|
||||
GDK_WINDOW_XWINDOW(d),
|
||||
GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(d)),
|
||||
gfxIntSize(width, height));
|
||||
|
||||
// if the surface creation is reporting an error, then
|
||||
// we don't have a surface to give back
|
||||
if (mThebesSurface && mThebesSurface->CairoStatus() != 0)
|
||||
mThebesSurface = nsnull;
|
||||
} else {
|
||||
#ifdef MOZ_ENABLE_GLITZ
|
||||
glitz_surface_t *gsurf;
|
||||
glitz_drawable_t *gdraw;
|
||||
|
||||
glitz_drawable_format_t *gdformat = glitz_glx_find_window_format (GDK_DISPLAY(),
|
||||
gdk_x11_get_default_screen(),
|
||||
0, NULL, 0);
|
||||
if (!gdformat)
|
||||
NS_ERROR("Failed to find glitz drawable format");
|
||||
|
||||
Display* dpy = GDK_WINDOW_XDISPLAY(d);
|
||||
Window wnd = GDK_WINDOW_XWINDOW(d);
|
||||
|
||||
gdraw =
|
||||
glitz_glx_create_drawable_for_window (dpy,
|
||||
DefaultScreen(dpy),
|
||||
gdformat,
|
||||
wnd,
|
||||
width,
|
||||
height);
|
||||
glitz_format_t *gformat =
|
||||
glitz_find_standard_format (gdraw, GLITZ_STANDARD_RGB24);
|
||||
gsurf =
|
||||
glitz_surface_create (gdraw,
|
||||
gformat,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
NULL);
|
||||
glitz_surface_attach (gsurf, gdraw, GLITZ_DRAWABLE_BUFFER_FRONT_COLOR);
|
||||
|
||||
|
||||
//fprintf (stderr, "## nsThebesDrawingSurface::Init Glitz DRAWABLE %p (DC: %p)\n", aWidget, aDC);
|
||||
mThebesSurface = new gfxGlitzSurface (gdraw, gsurf, PR_TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
// if the surface creation is reporting an error, then
|
||||
// we don't have a surface to give back
|
||||
if (mThebesSurface && mThebesSurface->CairoStatus() != 0) {
|
||||
mThebesSurface = nsnull;
|
||||
} else {
|
||||
mThebesSurface->SetDeviceOffset(gfxPoint(-x_offset, -y_offset));
|
||||
if (mThebesSurface) {
|
||||
mThebesSurface->SetDeviceOffset(gfxPoint(-x_offset, -y_offset));
|
||||
}
|
||||
}
|
||||
|
||||
return mThebesSurface;
|
||||
|
@ -56,13 +56,7 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
#include <gdk/gdkdirectfb.h>
|
||||
#endif /* MOZ_DFB */
|
||||
|
||||
#ifdef MOZ_X11
|
||||
#include <gdk/gdkx.h>
|
||||
#endif /* MOZ_X11 */
|
||||
#include <gtk/gtkwindow.h>
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
@ -262,16 +256,12 @@ public:
|
||||
};
|
||||
|
||||
void SetPluginType(PluginType aPluginType);
|
||||
#ifdef MOZ_X11
|
||||
void SetNonXEmbedPluginFocus(void);
|
||||
void LoseNonXEmbedPluginFocus(void);
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
void ThemeChanged(void);
|
||||
|
||||
#ifdef MOZ_X11
|
||||
Window mOldFocusWindow;
|
||||
#endif /* MOZ_X11 */
|
||||
|
||||
static guint32 mLastButtonPressTime;
|
||||
static guint32 mLastButtonReleaseTime;
|
||||
@ -412,14 +402,6 @@ private:
|
||||
|
||||
nsRefPtr<gfxASurface> mThebesSurface;
|
||||
|
||||
#ifdef MOZ_DFB
|
||||
int mDFBCursorX;
|
||||
int mDFBCursorY;
|
||||
PRUint32 mDFBCursorCount;
|
||||
IDirectFB *mDFB;
|
||||
IDirectFBDisplayLayer *mDFBLayer;
|
||||
#endif
|
||||
|
||||
#ifdef ACCESSIBILITY
|
||||
nsCOMPtr<nsIAccessible> mRootAccessible;
|
||||
void CreateRootAccessible();
|
||||
|
Loading…
Reference in New Issue
Block a user