Merge branch 'broadway'

This commit is contained in:
Alexander Larsson 2011-03-15 13:00:24 +01:00
commit 4fadd346fa
40 changed files with 8220 additions and 3 deletions

View File

@ -55,11 +55,11 @@ MAINTAINERCLEANFILES = \
## Copy .pc files to target-specific names
gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc: gtk+-3.0.pc
gtk+-x11-3.0.pc gtk+-win32-3.0.pc gtk+-quartz-3.0.pc gtk+-broadway-3.0.pc: gtk+-3.0.pc
rm -f $@ && \
cp gtk+-3.0.pc $@
gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc: gdk-3.0.pc
gdk-x11-3.0.pc gdk-win32-3.0.pc gdk-quartz-3.0.pc gdk-broadway-3.0.pc: gdk-3.0.pc
rm -f $@ && \
cp gdk-3.0.pc $@

View File

@ -297,6 +297,10 @@ AC_ARG_ENABLE(quartz-backend,
[AS_HELP_STRING([--enable-quartz-backend],
[enable the quartz gdk backend])],
[backend_set=yes])
AC_ARG_ENABLE(broadway-backend,
[AC_HELP_STRING([--enable-broadway-backend],
[enable the broadway (HTML5) gdk backend])],
[backend_set=yes])
if test -z "$backend_set"; then
if test "$platform_win32" = yes; then
@ -352,6 +356,17 @@ else
AM_CONDITIONAL(USE_QUARTZ, false)
fi
if test "x$enable_broadway_backend" == xyes; then
GDK_BACKENDS="$GDK_BACKENDS broadway"
cairo_backends="$cairo_backends cairo"
GDK_WINDOWING="$GDK_WINDOWING
#define GDK_WINDOWING_BROADWAY"
GDK_EXTRA_LIBS="$GDK_EXTRA_LIBS -lz"
AM_CONDITIONAL(USE_BROADWAY, true)
else
AM_CONDITIONAL(USE_BROADWAY, false)
fi
# strip leading space
GDK_BACKENDS=${GDK_BACKENDS/# }
@ -1630,6 +1645,7 @@ build/Makefile
build/win32/Makefile
build/win32/vs9/Makefile
gdk/Makefile
gdk/broadway/Makefile
gdk/x11/Makefile
gdk/win32/Makefile
gdk/win32/rc/Makefile

View File

@ -11,7 +11,7 @@ INTROSPECTION_COMPILER_ARGS = \
SUBDIRS = $(GDK_BACKENDS) . tests
DIST_SUBDIRS = win32 x11 quartz tests
DIST_SUBDIRS = win32 x11 quartz broadway tests
CLEANFILES =
@ -173,6 +173,10 @@ libgdk_3_la_DEPENDENCIES = win32/libgdk-win32.la win32/rc/gdk-win32-res.o gdk.de
libgdk_3_la_LDFLAGS += -Wl,win32/rc/gdk-win32-res.o -export-symbols $(srcdir)/gdk.def
endif # USE_WIN32
if USE_BROADWAY
libgdk_3_la_LIBADD += broadway/libgdk-broadway.la
endif # USE_BROADWAY
if HAVE_INTROSPECTION
introspection_files = \

75
gdk/broadway/Makefile.am Normal file
View File

@ -0,0 +1,75 @@
## Process this file with automake to produce Makefile.in
include $(top_srcdir)/Makefile.decl
libgdkincludedir = $(includedir)/gtk-3.0/gdk
INCLUDES = \
-DG_LOG_DOMAIN=\"Gdk\" \
-DGDK_COMPILATION \
-I$(top_srcdir) \
-I$(top_srcdir)/gdk \
-I$(top_builddir)/gdk \
$(GTK_DEBUG_FLAGS) \
$(GDK_DEP_CFLAGS)
LDADDS = $(GDK_DEP_LIBS)
noinst_LTLIBRARIES = libbroadway.la libgdk-broadway.la
libbroadway_la_SOURCES = \
broadway.h \
broadway.c
clienthtml.h: client.html
$(PERL) ./toarray.pl client.html client_html > $@
broadwayjs.h: broadway.js
$(PERL) ./toarray.pl broadway.js broadway_js > $@
# built headers that don't get installed
broadway_built_private_headers = \
clienthtml.h \
broadwayjs.h
broadway_built_sources = \
${broadway_built_private_headers}
libgdk_broadway_la_SOURCES = \
${broadway_built_private_headers}\
gdkbroadwaydisplaymanager.h \
gdkcursor-broadway.c \
gdkdevice-broadway.h \
gdkdevice-broadway.c \
gdkdevicemanager-broadway.h \
gdkdevicemanager-broadway.c \
gdkdisplay-broadway.c \
gdkdisplay-broadway.h \
gdkdisplaymanager-broadway.c \
gdkdnd-broadway.c \
gdkeventsource.c \
gdkeventsource.h \
gdkglobals-broadway.c \
gdkim-broadway.c \
gdkkeys-broadway.c \
gdkmain-broadway.c \
gdkproperty-broadway.c \
gdkscreen-broadway.c \
gdkscreen-broadway.h \
gdkselection-broadway.c \
gdktestutils-broadway.c \
gdkvisual-broadway.c \
gdkwindow-broadway.c \
gdkwindow-broadway.h \
gdkprivate-broadway.h
libgdk_broadway_la_LIBADD = libbroadway.la
MAINTAINERCLEANFILES = $(broadway_built_sources)
EXTRA_DIST += $(broadway_built_sources)
BUILT_SOURCES = $(broadway_built_sources)
noinst_PROGRAMS = broadway-demo
broadway_demo_LDADD = -lz -lcairo libbroadway.la -lglib-2.0
-include $(top_srcdir)/git.mk

View File

@ -0,0 +1,230 @@
/* Build with
gcc -lm -lz -O2 -Wall `pkg-config --libs --cflags cairo` -o broadway broadway.c demo.c
*/
#include "broadway.h"
#include <math.h>
#include <unistd.h>
#include <stdint.h>
#include <cairo.h>
static void
diff_surfaces (cairo_surface_t *surface,
cairo_surface_t *old_surface)
{
uint8_t *data, *old_data;
uint32_t *line, *old_line;
int w, h, stride, old_stride;
int x, y;
data = cairo_image_surface_get_data (surface);
old_data = cairo_image_surface_get_data (old_surface);
w = cairo_image_surface_get_width (surface);
h = cairo_image_surface_get_height (surface);
stride = cairo_image_surface_get_stride (surface);
old_stride = cairo_image_surface_get_stride (old_surface);
for (y = 0; y < h; y++)
{
line = (uint32_t *)data;
old_line = (uint32_t *)old_data;
for (x = 0; x < w; x++)
{
if ((*line & 0xffffff) == (*old_line & 0xffffff))
*old_line = 0;
else
*old_line = *line | 0xff000000;
line ++;
old_line ++;
}
data += stride;
old_data += old_stride;
}
}
static void
snippet(cairo_t *cr, int i)
{
if (1)
{
cairo_save(cr);
cairo_rotate (cr, i * 0.002);
/* a custom shape that could be wrapped in a function */
double x0 = 25.6, /* parameters like cairo_rectangle */
y0 = 25.6,
rect_width = 204.8,
rect_height = 204.8,
radius = 102.4; /* and an approximate curvature radius */
double x1,y1;
x1=x0+rect_width;
y1=y0+rect_height;
if (rect_width/2<radius) {
if (rect_height/2<radius) {
cairo_move_to (cr, x0, (y0 + y1)/2);
cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
} else {
cairo_move_to (cr, x0, y0 + radius);
cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
cairo_line_to (cr, x1 , y1 - radius);
cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
}
} else {
if (rect_height/2<radius) {
cairo_move_to (cr, x0, (y0 + y1)/2);
cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
cairo_line_to (cr, x1 - radius, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
cairo_line_to (cr, x0 + radius, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
} else {
cairo_move_to (cr, x0, y0 + radius);
cairo_curve_to (cr, x0 , y0, x0 , y0, x0 + radius, y0);
cairo_line_to (cr, x1 - radius, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, y0 + radius);
cairo_line_to (cr, x1 , y1 - radius);
cairo_curve_to (cr, x1, y1, x1, y1, x1 - radius, y1);
cairo_line_to (cr, x0 + radius, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, y1- radius);
}
}
cairo_close_path (cr);
cairo_set_source_rgb (cr, 0.5, 0.5, 1);
cairo_fill_preserve (cr);
cairo_set_source_rgba (cr, 0.5, 0, 0, 0.5);
cairo_set_line_width (cr, 10.0);
cairo_stroke (cr);
cairo_restore(cr);
}
if (1)
{
double xc = 128.0;
double yc = 128.0;
double radius = 100.0;
double angle1 = (45.0 + i * 5) * (M_PI/180.0); /* angles are specified */
double angle2 = (180.0 + i * 5) * (M_PI/180.0); /* in radians */
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_set_line_width (cr, 10.0);
cairo_arc (cr, xc, yc, radius, angle1, angle2);
cairo_stroke (cr);
/* draw helping lines */
cairo_set_source_rgba (cr, 1, 0.2, 0.2, 0.6);
cairo_set_line_width (cr, 6.0);
cairo_arc (cr, xc, yc, 10.0, 0, 2*M_PI);
cairo_fill (cr);
cairo_arc (cr, xc, yc, radius, angle1, angle1);
cairo_line_to (cr, xc, yc);
cairo_arc (cr, xc, yc, radius, angle2, angle2);
cairo_line_to (cr, xc, yc);
cairo_stroke (cr);
}
}
static void
demo2 (BroadwayOutput *output)
{
cairo_t *cr;
cairo_surface_t *surface, *old_surface;
BroadwayRect rects[2];
double da = 0;
int i;
broadway_output_new_surface(output, 0, 100, 100, 800, 600);
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
800, 600);
old_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
800, 600);
cr = cairo_create (old_surface);
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
cairo_rectangle (cr, 0, 0, 800, 600);
cairo_fill (cr);
cairo_destroy (cr);
for (i = 0; i < 100; i++)
{
cr = cairo_create (surface);
cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
cairo_rectangle (cr, 0, 0, 800, 600);
cairo_fill (cr);
snippet(cr, i);
cairo_destroy (cr);
if (i == 0)
{
broadway_output_put_rgb (output, 0, 0, 0, 800, 600, 800*4,
cairo_image_surface_get_data(surface)
);
broadway_output_show_surface (output, 0);
}
else
{
diff_surfaces (surface,
old_surface);
broadway_output_put_rgba (output, 0, 0, 0, 800, 600, 800*4,
cairo_image_surface_get_data(old_surface));
}
broadway_output_move_surface (output, 0, 100 + i, 100 + i);
rects[0].x = 500;
rects[0].y = 0;
rects[0].width = 100;
rects[0].height = 100;
rects[1].x = 600;
rects[1].y = 100;
rects[1].width = 100;
rects[1].height = 100;
broadway_output_copy_rectangles (output,
0,
rects, 2,
400, 0);
broadway_output_flush (output);
cr = cairo_create (old_surface);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint (cr);
cairo_destroy (cr);
da += 10;
usleep (50 * 1000);
}
cairo_surface_destroy (surface);
broadway_output_destroy_surface(output, 0);
broadway_output_flush (output);
}
int
main (int argc, char *argv[])
{
BroadwayOutput *output;
output = broadway_output_new (STDOUT_FILENO, 1);
demo2(output);
return 0;
}

1139
gdk/broadway/broadway.c Normal file

File diff suppressed because it is too large Load Diff

67
gdk/broadway/broadway.h Normal file
View File

@ -0,0 +1,67 @@
#include <glib.h>
typedef struct BroadwayOutput BroadwayOutput;
typedef struct {
int x, y;
int width, height;
} BroadwayRect;
BroadwayOutput *broadway_output_new (int fd,
guint32 serial);
void broadway_output_free (BroadwayOutput *output);
int broadway_output_flush (BroadwayOutput *output);
int broadway_output_has_error (BroadwayOutput *output);
guint32 broadway_output_get_next_serial (BroadwayOutput *output);
void broadway_output_new_surface (BroadwayOutput *output,
int id,
int x,
int y,
int w,
int h);
void broadway_output_show_surface (BroadwayOutput *output,
int id);
void broadway_output_hide_surface (BroadwayOutput *output,
int id);
void broadway_output_destroy_surface (BroadwayOutput *output,
int id);
void broadway_output_move_surface (BroadwayOutput *output,
int id,
int x,
int y);
void broadway_output_resize_surface (BroadwayOutput *output,
int id,
int w,
int h);
void broadway_output_put_rgb (BroadwayOutput *output,
int id,
int x,
int y,
int w,
int h,
int byte_stride,
void *data);
void broadway_output_put_rgba (BroadwayOutput *output,
int id,
int x,
int y,
int w,
int h,
int byte_stride,
void *data);
void broadway_output_surface_flush (BroadwayOutput *output,
int id);
void broadway_output_copy_rectangles (BroadwayOutput *output,
int id,
BroadwayRect *rects,
int n_rects,
int dx,
int dy);
guint32 broadway_output_query_pointer (BroadwayOutput *output,
int id);
guint32 broadway_output_grab_pointer (BroadwayOutput *output,
int id,
gboolean owner_event,
guint32 time_);
guint32 broadway_output_ungrab_pointer (BroadwayOutput *output,
guint32 time_);

666
gdk/broadway/broadway.js Normal file
View File

@ -0,0 +1,666 @@
/* Helper functions for debugging */
var logDiv = null;
function log(str) {
if (!logDiv) {
logDiv = document.createElement('div');
document.body.appendChild(logDiv);
logDiv.style["position"] = "absolute";
logDiv.style["right"] = "0px";
}
logDiv.appendChild(document.createTextNode(str));
logDiv.appendChild(document.createElement('br'));
}
var base64Values = [
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,255,255,255,255,255,255,255,255,255, 62,255,255,255, 63,
52, 53, 54, 55, 56, 57, 58, 59, 60, 61,255,255,255, 0,255,255,
255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,255,255,255,255,255,
255, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,255,255,255,255,255
]
function base64_8(str, index) {
var v =
(base64Values[str.charCodeAt(index)]) +
(base64Values[str.charCodeAt(index+1)] << 6);
return v;
}
function base64_16(str, index) {
var v =
(base64Values[str.charCodeAt(index)]) +
(base64Values[str.charCodeAt(index+1)] << 6) +
(base64Values[str.charCodeAt(index+2)] << 12);
return v;
}
function base64_16s(str, index) {
var v = base64_16(str, index);
if (v > 32767)
return v - 65536;
else
return v;
}
function base64_24(str, index) {
var v =
(base64Values[str.charCodeAt(index)]) +
(base64Values[str.charCodeAt(index+1)] << 6) +
(base64Values[str.charCodeAt(index+2)] << 12) +
(base64Values[str.charCodeAt(index+3)] << 18);
return v;
}
function base64_32(str, index) {
var v =
(base64Values[str.charCodeAt(index)]) +
(base64Values[str.charCodeAt(index+1)] << 6) +
(base64Values[str.charCodeAt(index+2)] << 12) +
(base64Values[str.charCodeAt(index+3)] << 18) +
(base64Values[str.charCodeAt(index+4)] << 24) +
(base64Values[str.charCodeAt(index+5)] << 30);
return v;
}
function createXHR()
{
try { return new XMLHttpRequest(); } catch(e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e) {}
try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
return null;
}
var grab = new Object();
grab.window = null;
grab.ownerEvents = false;
grab.time = 0;
grab.implicit = false;
var lastSerial = 0;
var lastX = 0;
var lastY = 0;
var lastState;
var realWindowWithMouse = 0;
var windowWithMouse = 0;
var surfaces = {};
var outstandingCommands = new Array();
var inputSocket = null;
function initContext(canvas, x, y, id)
{
canvas.surfaceId = id;
canvas.style["position"] = "absolute";
canvas.style["left"] = x + "px";
canvas.style["top"] = y + "px";
canvas.style["display"] = "none";
var context = canvas.getContext("2d");
context.globalCompositeOperation = "source-over";
document.body.appendChild(canvas);
context.drawQueue = [];
return context;
}
var GDK_GRAB_SUCCESS = 0;
var GDK_GRAB_ALREADY_GRABBED = 1;
var GDK_GRAB_INVALID_TIME = 2;
var GDK_CROSSING_NORMAL = 0;
var GDK_CROSSING_GRAB = 1;
var GDK_CROSSING_UNGRAB = 2;
// GdkModifierType
var GDK_SHIFT_MASK = 1 << 0;
var GDK_LOCK_MASK = 1 << 1;
var GDK_CONTROL_MASK = 1 << 2;
var GDK_MOD1_MASK = 1 << 3;
var GDK_MOD2_MASK = 1 << 4;
var GDK_MOD3_MASK = 1 << 5;
var GDK_MOD4_MASK = 1 << 6;
var GDK_MOD5_MASK = 1 << 7;
var GDK_BUTTON1_MASK = 1 << 8;
var GDK_BUTTON2_MASK = 1 << 9;
var GDK_BUTTON3_MASK = 1 << 10;
var GDK_BUTTON4_MASK = 1 << 11;
var GDK_BUTTON5_MASK = 1 << 12;
var GDK_SUPER_MASK = 1 << 26;
var GDK_HYPER_MASK = 1 << 27;
var GDK_META_MASK = 1 << 28;
var GDK_RELEASE_MASK = 1 << 30;
function getButtonMask (button) {
if (button == 1)
return GDK_BUTTON1_MASK;
if (button == 2)
return GDK_BUTTON2_MASK;
if (button == 3)
return GDK_BUTTON3_MASK;
if (button == 4)
return GDK_BUTTON4_MASK;
if (button == 5)
return GDK_BUTTON5_MASK;
return 0;
}
function flushSurface(surface)
{
var commands = surface.drawQueue;
surface.queue = [];
var i = 0;
for (i = 0; i < commands.length; i++) {
var cmd = commands[i];
var context = surfaces[cmd.id];
switch (cmd.op) {
/* put image data surface */
case 'i':
context.globalCompositeOperation = "source-over";
context.drawImage(cmd.img, cmd.x, cmd.y);
break;
/* copy rects */
case 'b':
context.save();
context.beginPath();
var minx;
var miny;
var maxx;
var maxy;
for (var j = 0; j < cmd.rects.length; j++) {
var rect = cmd.rects[j];
context.rect(rect.x, rect.y, rect.w, rect.h);
if (j == 0) {
minx = rect.x;
miny = rect.y;
maxx = rect.x + rect.w;
maxy = rect.y + rect.h;
} else {
if (rect.x < minx)
minx = rect.x;
if (rect.y < miny)
miny = rect.y;
if (rect.x + rect.w > maxx)
maxx = rect.x + rect.w;
if (rect.y + rect.h > maxy)
maxy = rect.y + rect.h;
}
}
context.clip();
context.globalCompositeOperation = "copy";
context.drawImage(context.canvas,
minx - cmd.dx, miny - cmd.dy, maxx - minx, maxy - miny,
minx, miny, maxx - minx, maxy - miny);
context.restore();
break;
default:
alert("Unknown drawing op " + cmd.op);
}
}
}
function handleCommands(cmdObj)
{
var cmd = cmdObj.data;
var i = cmdObj.pos;
while (i < cmd.length) {
var command = cmd[i++];
lastSerial = base64_32(cmd, i);
i = i + 6;
switch (command) {
case 's': // create new surface
var id = base64_16(cmd, i);
i = i + 3;
var x = base64_16(cmd, i);
i = i + 3;
var y = base64_16(cmd, i);
i = i + 3;
var w = base64_16(cmd, i);
i = i + 3;
var h = base64_16(cmd, i);
i = i + 3;
var surface = document.createElement("canvas");
surface.width = w;
surface.height = h;
surfaces[id] = initContext(surface, x, y, id);
break;
case 'S': // Show a surface
var id = base64_16(cmd, i);
i = i + 3;
surfaces[id].canvas.style["display"] = "inline";
break;
case 'H': // Hide a surface
var id = base64_16(cmd, i);
i = i + 3;
surfaces[id].canvas.style["display"] = "none";
break;
case 'd': // Delete surface
var id = base64_16(cmd, i);
i = i + 3;
var canvas = surfaces[id].canvas;
delete surfaces[id];
canvas.parentNode.removeChild(canvas);
break;
case 'm': // Move a surface
var id = base64_16(cmd, i);
i = i + 3;
var x = base64_16(cmd, i);
i = i + 3;
var y = base64_16(cmd, i);
i = i + 3;
surfaces[id].canvas.style["left"] = x + "px";
surfaces[id].canvas.style["top"] = y + "px";
break;
case 'r': // Resize a surface
var id = base64_16(cmd, i);
i = i + 3;
var w = base64_16(cmd, i);
i = i + 3;
var h = base64_16(cmd, i);
i = i + 3;
var surface = surfaces[id];
/* Flush any outstanding draw ops before changing size */
flushSurface(surface);
/* Canvas resize clears the data, so we need to save it first */
var tmpCanvas = document.createElement("canvas");
tmpCanvas.width = surface.canvas.width;
tmpCanvas.height = surface.canvas.height;
var tmpContext = tmpCanvas.getContext("2d");
tmpContext.globalCompositeOperation = "copy";
tmpContext.drawImage(surface.canvas, 0, 0, tmpCanvas.width, tmpCanvas.height);
surface.canvas.width = w;
surface.canvas.height = h;
surface.globalCompositeOperation = "copy";
surface.drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height);
break;
case 'i': // Put image data surface
var q = new Object();
q.op = 'i';
q.id = base64_16(cmd, i);
i = i + 3;
q.x = base64_16(cmd, i);
i = i + 3;
q.y = base64_16(cmd, i);
i = i + 3;
var size = base64_32(cmd, i);
i = i + 6;
var url = cmd.slice(i, i + size);
i = i + size;
q.img = new Image();
q.img.src = url;
surfaces[q.id].drawQueue.push(q);
if (!q.img.complete) {
cmdObj.pos = i;
q.img.onload = function() { handleOutstanding(); };
return false;
}
break;
case 'b': // Copy rects
var q = new Object();
q.op = 'b';
q.id = base64_16(cmd, i);
i = i + 3;
var nrects = base64_16(cmd, i);
i = i + 3;
q.rects = [];
for (var r = 0; r < nrects; r++) {
var rect = new Object();
rect.x = base64_16(cmd, i);
i = i + 3;
rect.y = base64_16(cmd, i);
i = i + 3;
rect.w = base64_16(cmd, i);
i = i + 3;
rect.h = base64_16(cmd, i);
i = i + 3;
q.rects.push (rect);
}
q.dx = base64_16s(cmd, i);
i = i + 3;
q.dy = base64_16s(cmd, i);
i = i + 3;
surfaces[q.id].drawQueue.push(q);
break;
case 'f': // Flush surface
var id = base64_16(cmd, i);
i = i + 3;
flushSurface(surfaces[id]);
break;
case 'q': // Query pointer
var id = base64_16(cmd, i);
i = i + 3;
var pos = getPositionsFromAbsCoord(lastX, lastY, id);
sendInput ("q", [pos.rootX, pos.rootY, pos.winX, pos.winY, windowWithMouse]);
break;
case 'g': // Grab
var id = base64_16(cmd, i);
i = i + 3;
var ownerEvents = cmd[i++] == '1';
var time = base64_32(cmd, i);
i = i + 6;
if (grab.window != null) {
/* Previous grab, compare times */
if (time != 0 && grab.time != 0 &&
time > grab.time) {
sendInput ("g", [GDK_GRAB_INVALID_TIME]);
break;
}
}
doGrab(id, ownerEvents, time, false);
sendInput ("g", [GDK_GRAB_SUCCESS]);
break;
case 'u': // Ungrab
var time = base64_32(cmd, i);
i = i + 6;
sendInput ("u", []);
if (grab.window != null) {
if (grab.time == 0 || time == 0 ||
grab.time < time)
grab.window = null;
}
break;
default:
alert("Unknown op " + command);
}
}
return true;
}
function handleOutstanding()
{
while (outstandingCommands.length > 0) {
var cmd = outstandingCommands.shift();
if (!handleCommands(cmd)) {
outstandingCommands.unshift(cmd);
return;
}
}
}
function handleLoad(event)
{
var cmdObj = {};
cmdObj.data = event.target.responseText;
cmdObj.pos = 0;
outstandingCommands.push(cmdObj);
if (outstandingCommands.length == 1) {
handleOutstanding();
}
}
function getSurfaceId(ev) {
var id = ev.target.surfaceId;
if (id != undefined)
return id;
return 0;
}
function sendInput(cmd, args)
{
if (inputSocket != null) {
inputSocket.send(cmd + ([lastSerial].concat(args)).join(","));
}
}
function getDocumentCoordinates(element)
{
var res = new Object();
res.x = element.offsetLeft;
res.y = element.offsetTop;
var offsetParent = element.offsetParent;
while (offsetParent != null) {
res.x += offsetParent.offsetLeft;
res.y += offsetParent.offsetTop;
offsetParent = offsetParent.offsetParent;
}
return res;
}
function getPositionsFromAbsCoord(absX, absY, relativeId) {
var res = Object();
res.rootX = absX;
res.rootY = absY;
res.winX = absX;
res.winY = absY;
if (relativeId != 0) {
var pos = getDocumentCoordinates(surfaces[relativeId].canvas);
res.winX = res.winX - pos.x;
res.winY = res.winY - pos.y;
}
return res;
}
function getPositionsFromEvent(ev, relativeId) {
var res = getPositionsFromAbsCoord(ev.pageX, ev.pageY, relativeId);
lastX = res.rootX;
lastY = res.rootY;
return res;
}
function getEffectiveEventTarget (id) {
if (grab.window != null) {
if (!grab.ownerEvents)
return grab.window;
if (id == 0)
return grab.window;
}
return id;
}
function onMouseMove (ev) {
var id = getSurfaceId(ev);
id = getEffectiveEventTarget (id);
var pos = getPositionsFromEvent(ev, id);
sendInput ("m", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, ev.timeStamp]);
}
function onMouseOver (ev) {
var id = getSurfaceId(ev);
realWindowWithMouse = id;
id = getEffectiveEventTarget (id);
var pos = getPositionsFromEvent(ev, id);
windowWithMouse = id;
if (windowWithMouse != 0) {
sendInput ("e", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, ev.timeStamp, GDK_CROSSING_NORMAL]);
}
}
function onMouseOut (ev) {
var id = getSurfaceId(ev);
var origId = id;
id = getEffectiveEventTarget (id);
var pos = getPositionsFromEvent(ev, id);
if (id != 0) {
sendInput ("l", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, ev.timeStamp, GDK_CROSSING_NORMAL]);
}
realWindowWithMouse = 0;
windowWithMouse = 0;
}
function doGrab(id, ownerEvents, time, implicit) {
var pos;
if (windowWithMouse != id) {
if (windowWithMouse != 0) {
pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
sendInput ("l", [windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, time, GDK_CROSSING_GRAB]);
}
pos = getPositionsFromAbsCoord(lastX, lastY, id);
sendInput ("e", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, time, GDK_CROSSING_GRAB]);
windowWithMouse = id;
}
grab.window = id;
grab.ownerEvents = ownerEvents;
grab.time = time;
grab.implicit = implicit;
}
function doUngrab(time) {
var pos;
if (realWindowWithMouse != windowWithMouse) {
if (windowWithMouse != 0) {
pos = getPositionsFromAbsCoord(lastX, lastY, windowWithMouse);
sendInput ("l", [windowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, time, GDK_CROSSING_UNGRAB]);
}
if (realWindowWithMouse != 0) {
pos = getPositionsFromAbsCoord(lastX, lastY, realWindowWithMouse);
sendInput ("e", [realWindowWithMouse, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, time, GDK_CROSSING_UNGRAB]);
}
windowWithMouse = realWindowWithMouse;
}
grab.window = null;
}
function onMouseDown (ev) {
var id = getSurfaceId(ev);
id = getEffectiveEventTarget (id);
var pos = getPositionsFromEvent(ev, id);
if (grab.window != null)
doGrab (id, false, ev.timeStamp, true);
var button = ev.button + 1;
lastState = lastState | getButtonMask (button);
sendInput ("b", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, ev.timeStamp, button]);
}
function onMouseUp (ev) {
var id = getSurfaceId(ev);
id = getEffectiveEventTarget (id);
var pos = getPositionsFromEvent(ev, id);
var button = ev.button + 1;
lastState = lastState & ~getButtonMask (button);
sendInput ("B", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, ev.timeStamp, button]);
if (grab.window != null && grab.implicit)
doUngrab(ev.timeStamp);
}
var lastKeyDown = 0;
function onKeyDown (ev) {
var keyCode = ev.keyCode;
if (keyCode != lastKeyDown) {
sendInput ("k", [keyCode, ev.timeStamp]);
lastKeyDown = keyCode;
}
}
function onKeyUp (ev) {
var keyCode = ev.keyCode;
sendInput ("K", [keyCode, ev.timeStamp]);
lastKeyDown = 0;
}
function cancelEvent(ev)
{
ev = ev ? ev : window.event;
if (ev.stopPropagation)
ev.stopPropagation();
if (ev.preventDefault)
ev.preventDefault();
ev.cancelBubble = true;
ev.cancel = true;
ev.returnValue = false;
return false;
}
function onMouseWheel(ev)
{
ev = ev ? ev : window.event;
var id = getSurfaceId(ev);
var pos = getPositionsFromEvent(ev, id);
var offset = ev.detail ? ev.detail : ev.wheelDelta;
var dir = 0;
if (offset > 0)
dir = 1;
sendInput ("s", [id, pos.rootX, pos.rootY, pos.winX, pos.winY, lastState, ev.timeStamp, dir]);
return cancelEvent(ev);
}
function connect()
{
var xhr = createXHR();
if (xhr) {
if (typeof xhr.multipart == 'undefined') {
alert("Sorry, this example only works in browsers that support multipart.");
return;
}
xhr.multipart = true;
xhr.open("GET", "/output", true);
xhr.onload = handleLoad;
xhr.send(null);
}
if ("WebSocket" in window) {
var loc = window.location.toString().replace("http:", "ws:");
loc = loc.substr(0, loc.lastIndexOf('/')) + "/input";
var ws = new WebSocket(loc, "broadway");
ws.onopen = function() {
inputSocket = ws;
};
ws.onclose = function() {
inputSocket = null;
};
} else {
alert("WebSocket not supported, input will not work!");
}
document.oncontextmenu = function () { return false; };
document.onmousemove = onMouseMove;
document.onmouseover = onMouseOver;
document.onmouseout = onMouseOut;
document.onmousedown = onMouseDown;
document.onmouseup = onMouseUp;
document.onkeydown = onKeyDown;
document.onkeyup = onKeyUp;
if (document.addEventListener) {
document.addEventListener('DOMMouseScroll', onMouseWheel, false);
document.addEventListener('mousewheel', onMouseWheel, false);
} else if (document.attachEvent) {
element.attachEvent("onmousewheel", onMouseWheel);
}
}

11
gdk/broadway/client.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<title>broadway 2.0</title>
<script type="text/javascript" src="broadway.js"></script>
</head>
<body onload="connect()">
</body>
</html>

View File

@ -0,0 +1,56 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#if !defined (__GDKX_H_INSIDE__) && !defined (GDK_COMPILATION)
#error "Only <gdk/gdkx.h> can be included directly."
#endif
#ifndef __GDK_BROADWAY_CURSOR_H__
#define __GDK_BROADWAY_CURSOR_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GDK_TYPE_BROADWAY_CURSOR (gdk_broadway_cursor_get_type ())
#define GDK_BROADWAY_CURSOR(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_CURSOR, GdkBroadwayCursor))
#define GDK_BROADWAY_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_CURSOR, GdkBroadwayCursorClass))
#define GDK_IS_BROADWAY_CURSOR(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_CURSOR))
#define GDK_IS_BROADWAY_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_CURSOR))
#define GDK_BROADWAY_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_CURSOR, GdkBroadwayCursorClass))
#ifdef GDK_COMPILATION
typedef struct _GdkBroadwayCursor GdkBroadwayCursor;
#else
typedef GdkCursor GdkBroadwayCursor;
#endif
typedef struct _GdkBroadwayCursorClass GdkBroadwayCursorClass;
GType gdk_broadway_cursor_get_type (void);
G_END_DECLS
#endif /* __GDK_BROADWAY_CURSOR_H__ */

View File

@ -0,0 +1,47 @@
/* gdkbroadwaydisplaymanager.h
*
* Copyright (C) 2005-2007 Imendio AB
* Copyright 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__GDKBROADWAY_H_INSIDE__) && !defined (GDK_COMPILATION)
#error "Only <gdk/gdkbroadway.h> can be included directly."
#endif
#ifndef __GDK_BROADWAY_DISPLAY_MANAGER_H__
#define __GDK_BROADWAY_DISPLAY_MANAGER_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GDK_TYPE_BROADWAY_DISPLAY_MANAGER (gdk_broadway_display_manager_get_type ())
#define GDK_BROADWAY_DISPLAY_MANAGER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DISPLAY_MANAGER, GdkBroadwayDisplayManager))
#ifdef GDK_COMPILATION
typedef struct _GdkBroadwayDisplayManager GdkBroadwayDisplayManager;
#else
typedef GdkDisplayManager _GdkBroadwayDisplayManager;
#endif
typedef struct _GdkDisplayManagerClass GdkBroadwayDisplayManagerClass;
GType gdk_broadway_display_manager_get_type (void);
G_END_DECLS
#endif /* __GDK_BROADWAY_DISPLAY_MANAGER_H__ */

View File

@ -0,0 +1,47 @@
/* gdkbroadwayvisual.h
*
* Copyright (C) 2011 Alexander Larsson <alexl@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_BROADWAY_VISUAL_H__
#define __GDK_BROADWAY_VISUAL_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GDK_TYPE_BROADWAY_VISUAL (gdk_broadway_visual_get_type ())
#define GDK_BROADWAY_VISUAL(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_VISUAL, GdkBroadwayVisual))
#define GDK_BROADWAY_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_VISUAL, GdkBroadwayVisualClass))
#define GDK_IS_BROADWAY_VISUAL(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_VISUAL))
#define GDK_IS_BROADWAY_VISUAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_VISUAL))
#define GDK_BROADWAY_VISUAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_VISUAL, GdkBroadwayVisualClass))
#ifdef GDK_COMPILATION
typedef struct _GdkBroadwayVisual GdkBroadwayVisual;
#else
typedef GdkVisual GdkBroadwayVisual;
#endif
typedef struct _GdkBroadwayVisualClass GdkBroadwayVisualClass;
GType gdk_broadway_visual_get_type (void);
G_END_DECLS
#endif /* __GDK_BROADWAY_VISUAL_H__ */

View File

@ -0,0 +1,52 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_BROADWAY_WINDOW_H__
#define __GDK_BROADWAY_WINDOW_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS
#define GDK_TYPE_BROADWAY_WINDOW (gdk_broadway_window_get_type ())
#define GDK_BROADWAY_WINDOW(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_WINDOW, GdkBroadwayWindow))
#define GDK_BROADWAY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_WINDOW, GdkBroadwayWindowClass))
#define GDK_IS_BROADWAY_WINDOW(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_WINDOW))
#define GDK_IS_BROADWAY_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_WINDOW))
#define GDK_BROADWAY_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_WINDOW, GdkBroadwayWindowClass))
#ifdef GDK_COMPILATION
typedef struct _GdkBroadwayWindow GdkBroadwayWindow;
#else
typedef GdkWindow GdkBroadwayWindow;
#endif
typedef struct _GdkBroadwayWindowClass GdkBroadwayWindowClass;
GType gdk_broadway_window_get_type (void);
G_END_DECLS
#endif /* __GDK_BROADWAY_WINDOW_H__ */

View File

@ -0,0 +1,185 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
/* needs to be first because any header might include gdk-pixbuf.h otherwise */
#define GDK_PIXBUF_ENABLE_BACKEND
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "gdkcursor.h"
#include "gdkcursorprivate.h"
#include "gdkprivate-broadway.h"
#include "gdkdisplay-broadway.h"
#include <string.h>
#include <errno.h>
struct _GdkBroadwayCursor
{
GdkCursor cursor;
};
struct _GdkBroadwayCursorClass
{
GdkCursorClass cursor_class;
};
/*** GdkBroadwayCursor ***/
G_DEFINE_TYPE (GdkBroadwayCursor, gdk_broadway_cursor, GDK_TYPE_CURSOR)
static GdkPixbuf* gdk_broadway_cursor_get_image (GdkCursor *cursor);
static void
gdk_broadway_cursor_finalize (GObject *object)
{
G_OBJECT_CLASS (gdk_broadway_cursor_parent_class)->finalize (object);
}
static void
gdk_broadway_cursor_class_init (GdkBroadwayCursorClass *xcursor_class)
{
GdkCursorClass *cursor_class = GDK_CURSOR_CLASS (xcursor_class);
GObjectClass *object_class = G_OBJECT_CLASS (xcursor_class);
object_class->finalize = gdk_broadway_cursor_finalize;
cursor_class->get_image = gdk_broadway_cursor_get_image;
}
static void
gdk_broadway_cursor_init (GdkBroadwayCursor *cursor)
{
}
/* Called by gdk_display_broadway_finalize to flush any cached cursors
* for a dead display.
*/
void
_gdk_broadway_cursor_display_finalize (GdkDisplay *display)
{
}
GdkCursor*
_gdk_broadway_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type)
{
GdkBroadwayCursor *private;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
private = g_object_new (GDK_TYPE_BROADWAY_CURSOR,
"cursor-type", cursor_type,
"display", display,
NULL);
return GDK_CURSOR (private);
}
static GdkPixbuf*
gdk_broadway_cursor_get_image (GdkCursor *cursor)
{
g_return_val_if_fail (cursor != NULL, NULL);
return NULL;
}
void
_gdk_broadway_cursor_update_theme (GdkCursor *cursor)
{
g_return_if_fail (cursor != NULL);
}
GdkCursor *
_gdk_broadway_display_get_cursor_for_pixbuf (GdkDisplay *display,
GdkPixbuf *pixbuf,
gint x,
gint y)
{
GdkBroadwayCursor *private;
GdkCursor *cursor;
private = g_object_new (GDK_TYPE_BROADWAY_CURSOR,
"cursor-type", GDK_CURSOR_IS_PIXMAP,
"display", display,
NULL);
cursor = (GdkCursor *) private;
return cursor;
}
GdkCursor*
_gdk_broadway_display_get_cursor_for_name (GdkDisplay *display,
const gchar *name)
{
GdkBroadwayCursor *private;
private = g_object_new (GDK_TYPE_BROADWAY_CURSOR,
"cursor-type", GDK_CURSOR_IS_PIXMAP,
"display", display,
NULL);
return GDK_CURSOR (private);
}
gboolean
_gdk_broadway_display_supports_cursor_alpha (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
return TRUE;
}
gboolean
_gdk_broadway_display_supports_cursor_color (GdkDisplay *display)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
return TRUE;
}
void
_gdk_broadway_display_get_default_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
*width = *height = 20;
}
void
_gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
*width = 128;
*height = 128;
}

View File

@ -0,0 +1,385 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include "gdkdevice-broadway.h"
#include "gdkwindow.h"
#include "gdkprivate-broadway.h"
static gboolean gdk_broadway_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events);
static void gdk_broadway_device_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask);
static void gdk_broadway_device_set_window_cursor (GdkDevice *device,
GdkWindow *window,
GdkCursor *cursor);
static void gdk_broadway_device_warp (GdkDevice *device,
GdkScreen *screen,
gint x,
gint y);
static gboolean gdk_broadway_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gint *root_x,
gint *root_y,
gint *win_x,
gint *win_y,
GdkModifierType *mask);
static GdkGrabStatus gdk_broadway_device_grab (GdkDevice *device,
GdkWindow *window,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
GdkCursor *cursor,
guint32 time_);
static void gdk_broadway_device_ungrab (GdkDevice *device,
guint32 time_);
static GdkWindow * gdk_broadway_device_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y,
GdkModifierType *mask,
gboolean get_toplevel);
static void gdk_broadway_device_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkEventMask event_mask);
G_DEFINE_TYPE (GdkBroadwayDevice, gdk_broadway_device, GDK_TYPE_DEVICE)
static void
gdk_broadway_device_class_init (GdkBroadwayDeviceClass *klass)
{
GdkDeviceClass *device_class = GDK_DEVICE_CLASS (klass);
device_class->get_history = gdk_broadway_device_get_history;
device_class->get_state = gdk_broadway_device_get_state;
device_class->set_window_cursor = gdk_broadway_device_set_window_cursor;
device_class->warp = gdk_broadway_device_warp;
device_class->query_state = gdk_broadway_device_query_state;
device_class->grab = gdk_broadway_device_grab;
device_class->ungrab = gdk_broadway_device_ungrab;
device_class->window_at_position = gdk_broadway_device_window_at_position;
device_class->select_window_events = gdk_broadway_device_select_window_events;
}
static void
gdk_broadway_device_init (GdkBroadwayDevice *device_core)
{
GdkDevice *device;
device = GDK_DEVICE (device_core);
_gdk_device_add_axis (device, GDK_NONE, GDK_AXIS_X, 0, 0, 1);
_gdk_device_add_axis (device, GDK_NONE, GDK_AXIS_Y, 0, 0, 1);
}
static gboolean
gdk_broadway_device_get_history (GdkDevice *device,
GdkWindow *window,
guint32 start,
guint32 stop,
GdkTimeCoord ***events,
gint *n_events)
{
return FALSE;
}
static void
gdk_broadway_device_get_state (GdkDevice *device,
GdkWindow *window,
gdouble *axes,
GdkModifierType *mask)
{
gint x_int, y_int;
gdk_window_get_pointer (window, &x_int, &y_int, mask);
if (axes)
{
axes[0] = x_int;
axes[1] = y_int;
}
}
static void
gdk_broadway_device_set_window_cursor (GdkDevice *device,
GdkWindow *window,
GdkCursor *cursor)
{
}
static void
gdk_broadway_device_warp (GdkDevice *device,
GdkScreen *screen,
gint x,
gint y)
{
}
static gboolean
gdk_broadway_device_query_state (GdkDevice *device,
GdkWindow *window,
GdkWindow **root_window,
GdkWindow **child_window,
gint *root_x,
gint *root_y,
gint *win_x,
gint *win_y,
GdkModifierType *mask)
{
GdkDisplay *display;
GdkBroadwayDisplay *broadway_display;
GdkWindowImplBroadway *impl;
guint32 serial;
GdkScreen *screen;
char *reply;
gint device_root_x, device_root_y, device_win_x, device_win_y, id;
if (gdk_device_get_source (device) != GDK_SOURCE_MOUSE)
return FALSE;
display = gdk_device_get_display (device);
broadway_display = GDK_BROADWAY_DISPLAY (display);
if (root_window)
{
screen = gdk_window_get_screen (window);
*root_window = gdk_screen_get_root_window (screen);
}
if (mask)
*mask = 0; /* TODO */
if (broadway_display->output)
{
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
serial = broadway_output_query_pointer (broadway_display->output, impl->id);
reply = _gdk_broadway_display_block_for_input (display, 'q', serial, TRUE);
if (reply != NULL)
{
char *p;
char cmd;
guint32 reply_serial;
p = reply;
cmd = *p++;
reply_serial = (guint32)strtol(p, &p, 10);
p++; /* Skip , */
device_root_x = strtol(p, &p, 10);
p++; /* Skip , */
device_root_y = strtol(p, &p, 10);
p++; /* Skip , */
device_win_x = strtol(p, &p, 10);
p++; /* Skip , */
device_win_y = strtol(p, &p, 10);
p++; /* Skip , */
id = strtol(p, &p, 10);
if (root_x)
*root_x = device_root_x;
if (root_y)
*root_y = device_root_y;
if (win_x)
*win_x = device_win_x;
if (win_y)
*win_y = device_win_y;
if (child_window)
{
if (gdk_window_get_window_type (window) == GDK_WINDOW_ROOT)
*child_window = g_hash_table_lookup (broadway_display->id_ht, GINT_TO_POINTER (id));
else
*child_window = window; /* No native children */
}
g_free (reply);
return TRUE;
}
}
/* Fallback when unconnected */
device_root_x = broadway_display->last_x;
device_root_y = broadway_display->last_y;
if (root_x)
*root_x = device_root_x;
if (root_y)
*root_y = device_root_y;
if (win_x)
*win_x = device_root_y - window->x;
if (win_y)
*win_y = device_root_y - window->y;
if (child_window)
{
if (gdk_window_get_window_type (window) == GDK_WINDOW_ROOT)
{
*child_window = broadway_display->mouse_in_toplevel;
if (*child_window == NULL)
*child_window = window;
}
else
{
/* No native children */
*child_window = window;
}
}
return TRUE;
}
static GdkGrabStatus
gdk_broadway_device_grab (GdkDevice *device,
GdkWindow *window,
gboolean owner_events,
GdkEventMask event_mask,
GdkWindow *confine_to,
GdkCursor *cursor,
guint32 time_)
{
GdkDisplay *display;
GdkBroadwayDisplay *broadway_display;
GdkWindowImplBroadway *impl;
guint32 serial;
char *reply;
display = gdk_device_get_display (device);
broadway_display = GDK_BROADWAY_DISPLAY (display);
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
/* Device is a keyboard */
return GDK_GRAB_SUCCESS;
}
else
{
/* Device is a pointer */
if (broadway_display->output)
{
impl = GDK_WINDOW_IMPL_BROADWAY (window->impl);
serial = broadway_output_grab_pointer (broadway_display->output,
impl->id, owner_events, time_);
reply = _gdk_broadway_display_block_for_input (display, 'g', serial, FALSE);
if (reply != NULL)
{
char *p;
char cmd;
guint32 reply_serial;
int res;
p = reply;
cmd = *p++;
reply_serial = (guint32)strtol(p, &p, 10);
p++; /* Skip , */
res = strtol(p, &p, 10);
return res;
}
}
return GDK_GRAB_NOT_VIEWABLE;
}
}
#define TIME_IS_LATER(time1, time2) \
( (( time1 > time2 ) && ( time1 - time2 < ((guint32)-1)/2 )) || \
(( time1 < time2 ) && ( time2 - time1 > ((guint32)-1)/2 )) \
)
static void
gdk_broadway_device_ungrab (GdkDevice *device,
guint32 time_)
{
GdkDisplay *display;
GdkBroadwayDisplay *broadway_display;
GdkDeviceGrabInfo *grab;
guint32 serial;
display = gdk_device_get_display (device);
broadway_display = GDK_BROADWAY_DISPLAY (display);
if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
/* Device is a keyboard */
}
else
{
/* Device is a pointer */
if (broadway_display->output)
{
serial = broadway_output_ungrab_pointer (broadway_display->output, time_);
gdk_display_flush (display);
grab = _gdk_display_get_last_device_grab (display, device);
if (grab &&
(time_ == GDK_CURRENT_TIME ||
grab->time == GDK_CURRENT_TIME ||
!TIME_IS_LATER (grab->time, time_)))
grab->serial_end = serial;
}
}
}
static GdkWindow *
gdk_broadway_device_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y,
GdkModifierType *mask,
gboolean get_toplevel)
{
gboolean res;
GdkScreen *screen;
GdkWindow *root_window;
GdkWindow *window;
screen = gdk_screen_get_default ();
root_window = gdk_screen_get_root_window (screen);
res = gdk_broadway_device_query_state (device, root_window, NULL, &window, NULL, NULL, win_x, win_y, mask);
if (res)
return window;
return NULL;
}
static void
gdk_broadway_device_select_window_events (GdkDevice *device,
GdkWindow *window,
GdkEventMask event_mask)
{
}

View File

@ -0,0 +1,52 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_BROADWAY_H__
#define __GDK_DEVICE_BROADWAY_H__
#include <gdk/gdkdeviceprivate.h>
G_BEGIN_DECLS
#define GDK_TYPE_BROADWAY_DEVICE (gdk_broadway_device_get_type ())
#define GDK_BROADWAY_DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_BROADWAY_DEVICE, GdkBroadwayDevice))
#define GDK_BROADWAY_DEVICE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_BROADWAY_DEVICE, GdkBroadwayDeviceClass))
#define GDK_IS_BROADWAY_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_BROADWAY_DEVICE))
#define GDK_IS_BROADWAY_DEVICE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_BROADWAY_DEVICE))
#define GDK_BROADWAY_DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_BROADWAY_DEVICE, GdkBroadwayDeviceClass))
typedef struct _GdkBroadwayDevice GdkBroadwayDevice;
typedef struct _GdkBroadwayDeviceClass GdkBroadwayDeviceClass;
struct _GdkBroadwayDevice
{
GdkDevice parent_instance;
};
struct _GdkBroadwayDeviceClass
{
GdkDeviceClass parent_class;
};
G_GNUC_INTERNAL
GType gdk_broadway_device_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GDK_DEVICE_BROADWAY_H__ */

View File

@ -0,0 +1,148 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkdevicemanager-broadway.h"
#include "gdktypes.h"
#include "gdkdevicemanager.h"
#include "gdkdevice-broadway.h"
#include "gdkkeysyms.h"
#include "gdkprivate-broadway.h"
#define HAS_FOCUS(toplevel) \
((toplevel)->has_focus || (toplevel)->has_pointer_focus)
static void gdk_broadway_device_manager_finalize (GObject *object);
static void gdk_broadway_device_manager_constructed (GObject *object);
static GList * gdk_broadway_device_manager_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type);
static GdkDevice * gdk_broadway_device_manager_get_client_pointer (GdkDeviceManager *device_manager);
G_DEFINE_TYPE (GdkBroadwayDeviceManager, gdk_broadway_device_manager, GDK_TYPE_DEVICE_MANAGER)
static void
gdk_broadway_device_manager_class_init (GdkBroadwayDeviceManagerClass *klass)
{
GdkDeviceManagerClass *device_manager_class = GDK_DEVICE_MANAGER_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gdk_broadway_device_manager_finalize;
object_class->constructed = gdk_broadway_device_manager_constructed;
device_manager_class->list_devices = gdk_broadway_device_manager_list_devices;
device_manager_class->get_client_pointer = gdk_broadway_device_manager_get_client_pointer;
}
static GdkDevice *
create_core_pointer (GdkDeviceManager *device_manager,
GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Core Pointer",
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_MOUSE,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", TRUE,
"display", display,
"device-manager", device_manager,
NULL);
}
static GdkDevice *
create_core_keyboard (GdkDeviceManager *device_manager,
GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE,
"name", "Core Keyboard",
"type", GDK_DEVICE_TYPE_MASTER,
"input-source", GDK_SOURCE_KEYBOARD,
"input-mode", GDK_MODE_SCREEN,
"has-cursor", FALSE,
"display", display,
"device-manager", device_manager,
NULL);
}
static void
gdk_broadway_device_manager_init (GdkBroadwayDeviceManager *device_manager)
{
}
static void
gdk_broadway_device_manager_finalize (GObject *object)
{
GdkBroadwayDeviceManager *device_manager;
device_manager = GDK_BROADWAY_DEVICE_MANAGER (object);
g_object_unref (device_manager->core_pointer);
g_object_unref (device_manager->core_keyboard);
G_OBJECT_CLASS (gdk_broadway_device_manager_parent_class)->finalize (object);
}
static void
gdk_broadway_device_manager_constructed (GObject *object)
{
GdkBroadwayDeviceManager *device_manager;
GdkDisplay *display;
device_manager = GDK_BROADWAY_DEVICE_MANAGER (object);
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object));
device_manager->core_pointer = create_core_pointer (GDK_DEVICE_MANAGER (device_manager), display);
device_manager->core_keyboard = create_core_keyboard (GDK_DEVICE_MANAGER (device_manager), display);
_gdk_device_set_associated_device (device_manager->core_pointer, device_manager->core_keyboard);
_gdk_device_set_associated_device (device_manager->core_keyboard, device_manager->core_pointer);
}
static GList *
gdk_broadway_device_manager_list_devices (GdkDeviceManager *device_manager,
GdkDeviceType type)
{
GdkBroadwayDeviceManager *broadway_device_manager = (GdkBroadwayDeviceManager *) device_manager;
GList *devices = NULL;
if (type == GDK_DEVICE_TYPE_MASTER)
{
devices = g_list_prepend (devices, broadway_device_manager->core_keyboard);
devices = g_list_prepend (devices, broadway_device_manager->core_pointer);
}
return devices;
}
static GdkDevice *
gdk_broadway_device_manager_get_client_pointer (GdkDeviceManager *device_manager)
{
GdkBroadwayDeviceManager *broadway_device_manager = (GdkBroadwayDeviceManager *) device_manager;
return broadway_device_manager->core_pointer;
}
GdkDeviceManager *
_gdk_broadway_device_manager_new (GdkDisplay *display)
{
return g_object_new (GDK_TYPE_BROADWAY_DEVICE_MANAGER,
"display", display,
NULL);
}

View File

@ -0,0 +1,54 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_DEVICE_MANAGER_BROADWAY_H__
#define __GDK_DEVICE_MANAGER_BROADWAY_H__
#include <gdk/gdkdevicemanagerprivate.h>
G_BEGIN_DECLS
#define GDK_TYPE_BROADWAY_DEVICE_MANAGER (gdk_broadway_device_manager_get_type ())
#define GDK_BROADWAY_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_BROADWAY_DEVICE_MANAGER, GdkBroadwayDeviceManager))
#define GDK_BROADWAY_DEVICE_MANAGER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GDK_TYPE_BROADWAY_DEVICE_MANAGER, GdkBroadwayDeviceManagerClass))
#define GDK_IS_BROADWAY_DEVICE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_BROADWAY_DEVICE_MANAGER))
#define GDK_IS_BROADWAY_DEVICE_MANAGER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GDK_TYPE_BROADWAY_DEVICE_MANAGER))
#define GDK_BROADWAY_DEVICE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDK_TYPE_BROADWAY_DEVICE_MANAGER, GdkBroadwayDeviceManagerClass))
typedef struct _GdkBroadwayDeviceManager GdkBroadwayDeviceManager;
typedef struct _GdkBroadwayDeviceManagerClass GdkBroadwayDeviceManagerClass;
struct _GdkBroadwayDeviceManager
{
GdkDeviceManager parent_object;
GdkDevice *core_pointer;
GdkDevice *core_keyboard;
};
struct _GdkBroadwayDeviceManagerClass
{
GdkDeviceManagerClass parent_class;
};
GType gdk_broadway_device_manager_get_type (void) G_GNUC_CONST;
GdkDeviceManager *_gdk_broadway_device_manager_new (GdkDisplay *display);
G_END_DECLS
#endif /* __GDK_DEVICE_MANAGER_BROADWAY_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,98 @@
/*
* gdkdisplay-broadway.h
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_BROADWAY_DISPLAY__
#define __GDK_BROADWAY_DISPLAY__
#include "gdkdisplayprivate.h"
#include "gdkkeys.h"
#include "gdkwindow.h"
#include "gdkinternals.h"
#include "gdkmain.h"
#include "broadway.h"
G_BEGIN_DECLS
typedef struct _GdkBroadwayDisplay GdkBroadwayDisplay;
typedef struct _GdkBroadwayDisplayClass GdkBroadwayDisplayClass;
typedef struct BroadwayInput BroadwayInput;
#define GDK_TYPE_BROADWAY_DISPLAY (gdk_broadway_display_get_type())
#define GDK_BROADWAY_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DISPLAY, GdkBroadwayDisplay))
#define GDK_BROADWAY_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DISPLAY, GdkBroadwayDisplayClass))
#define GDK_IS_BROADWAY_DISPLAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DISPLAY))
#define GDK_IS_BROADWAY_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DISPLAY))
#define GDK_BROADWAY_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DISPLAY, GdkBroadwayDisplayClass))
struct _GdkBroadwayDisplay
{
GdkDisplay parent_instance;
GdkScreen *default_screen;
GdkScreen **screens;
GHashTable *id_ht;
GList *toplevels;
GSource *event_source;
GdkWindow *mouse_in_toplevel;
int last_x, last_y; /* in root coords */
/* Keyboard related information */
GdkKeymap *keymap;
/* drag and drop information */
GdkDragContext *current_dest_drag;
/* Mapping to/from virtual atoms */
GHashTable *atom_from_virtual;
GHashTable *atom_to_virtual;
/* Input device */
/* input GdkDevice list */
GList *input_devices;
/* Time of most recent user interaction. */
gulong user_time;
/* The offscreen window that has the pointer in it (if any) */
GdkWindow *active_offscreen_window;
GSocketService *service;
BroadwayOutput *output;
guint32 saved_serial;
BroadwayInput *input;
GList *input_messages;
};
struct _GdkBroadwayDisplayClass
{
GdkDisplayClass parent_class;
};
GType gdk_broadway_display_get_type (void);
G_END_DECLS
#endif /* __GDK_BROADWAY_DISPLAY__ */

View File

@ -0,0 +1,162 @@
/* GDK - The GIMP Drawing Kit
* gdkdisplaymanager-broadway.c
*
* Copyright (C) 2005 Imendio AB
* Copyright 2010 Red Hat, Inc.
*
* Author: Matthias clasen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkdisplay-broadway.h"
#include "gdkbroadwaydisplaymanager.h"
#include "gdkprivate-broadway.h"
#include "gdkdisplaymanagerprivate.h"
#include "gdkinternals.h"
struct _GdkBroadwayDisplayManager
{
GdkDisplayManager parent;
GdkDisplay *default_display;
GSList *displays;
};
G_DEFINE_TYPE (GdkBroadwayDisplayManager, gdk_broadway_display_manager, GDK_TYPE_DISPLAY_MANAGER)
static GdkDisplay *
gdk_broadway_display_manager_open_display (GdkDisplayManager *manager,
const gchar *name)
{
return _gdk_broadway_display_open (name);
}
static GSList *
gdk_broadway_display_manager_list_displays (GdkDisplayManager *manager)
{
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
return g_slist_copy (manager_broadway->displays);
}
static GdkDisplay *
gdk_broadway_display_manager_get_default_display (GdkDisplayManager *manager)
{
return GDK_BROADWAY_DISPLAY_MANAGER (manager)->default_display;
}
static void
gdk_broadway_display_manager_set_default_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
manager_broadway->default_display = display;
}
#include "../gdkkeynames.c"
static gchar *
gdk_broadway_display_manager_get_keyval_name (GdkDisplayManager *manager,
guint keyval)
{
return _gdk_keyval_name (keyval);
}
static guint
gdk_broadway_display_manager_lookup_keyval (GdkDisplayManager *manager,
const gchar *name)
{
return _gdk_keyval_from_name (name);
}
static void
gdk_broadway_display_manager_keyval_convert_case (GdkDisplayManager *manager,
guint symbol,
guint *lower,
guint *upper)
{
/* FIXME implement this */
if (lower)
*lower = symbol;
if (upper)
*upper = symbol;
}
static void
gdk_broadway_display_manager_init (GdkBroadwayDisplayManager *manager)
{
_gdk_broadway_windowing_init ();
}
static void
gdk_broadway_display_manager_finalize (GObject *object)
{
g_error ("A GdkBroadwayDisplayManager object was finalized. This should not happen");
G_OBJECT_CLASS (gdk_broadway_display_manager_parent_class)->finalize (object);
}
static void
gdk_broadway_display_manager_class_init (GdkBroadwayDisplayManagerClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GdkDisplayManagerClass *manager_class = GDK_DISPLAY_MANAGER_CLASS (class);
object_class->finalize = gdk_broadway_display_manager_finalize;
manager_class->open_display = gdk_broadway_display_manager_open_display;
manager_class->list_displays = gdk_broadway_display_manager_list_displays;
manager_class->set_default_display = gdk_broadway_display_manager_set_default_display;
manager_class->get_default_display = gdk_broadway_display_manager_get_default_display;
manager_class->atom_intern = _gdk_broadway_display_manager_atom_intern;
manager_class->get_atom_name = _gdk_broadway_display_manager_get_atom_name;
manager_class->lookup_keyval = gdk_broadway_display_manager_lookup_keyval;
manager_class->get_keyval_name = gdk_broadway_display_manager_get_keyval_name;
manager_class->keyval_convert_case = gdk_broadway_display_manager_keyval_convert_case;
}
void
_gdk_broadway_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
if (manager_broadway->displays == NULL)
gdk_display_manager_set_default_display (manager, display);
manager_broadway->displays = g_slist_prepend (manager_broadway->displays, display);
}
void
_gdk_broadway_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display)
{
GdkBroadwayDisplayManager *manager_broadway = GDK_BROADWAY_DISPLAY_MANAGER (manager);
manager_broadway->displays = g_slist_remove (manager_broadway->displays, display);
if (manager_broadway->default_display == display)
{
if (manager_broadway->displays)
gdk_display_manager_set_default_display (manager, manager_broadway->displays->data);
else
gdk_display_manager_set_default_display (manager, NULL);
}
}

View File

@ -0,0 +1,223 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkdndprivate.h"
#include "gdkinternals.h"
#include "gdkproperty.h"
#include "gdkprivate-broadway.h"
#include "gdkinternals.h"
#include "gdkscreen-broadway.h"
#include "gdkdisplay-broadway.h"
#include <string.h>
#define GDK_TYPE_BROADWAY_DRAG_CONTEXT (gdk_broadway_drag_context_get_type ())
#define GDK_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContext))
#define GDK_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
#define GDK_IS_BROADWAY_DRAG_CONTEXT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
#define GDK_IS_BROADWAY_DRAG_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_DRAG_CONTEXT))
#define GDK_BROADWAY_DRAG_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_DRAG_CONTEXT, GdkBroadwayDragContextClass))
#ifdef GDK_COMPILATION
typedef struct _GdkBroadwayDragContext GdkBroadwayDragContext;
#else
typedef GdkDragContext GdkBroadwayDragContext;
#endif
typedef struct _GdkBroadwayDragContextClass GdkBroadwayDragContextClass;
GType gdk_broadway_drag_context_get_type (void);
struct _GdkBroadwayDragContext {
GdkDragContext context;
};
struct _GdkBroadwayDragContextClass
{
GdkDragContextClass parent_class;
};
static void gdk_broadway_drag_context_finalize (GObject *object);
static GList *contexts;
G_DEFINE_TYPE (GdkBroadwayDragContext, gdk_broadway_drag_context, GDK_TYPE_DRAG_CONTEXT)
static void
gdk_broadway_drag_context_init (GdkBroadwayDragContext *dragcontext)
{
contexts = g_list_prepend (contexts, dragcontext);
}
static void
gdk_broadway_drag_context_finalize (GObject *object)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (object);
contexts = g_list_remove (contexts, context);
G_OBJECT_CLASS (gdk_broadway_drag_context_parent_class)->finalize (object);
}
/* Drag Contexts */
GdkDragContext *
_gdk_broadway_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GList *targets)
{
GdkDragContext *new_context;
g_return_val_if_fail (window != NULL, NULL);
g_return_val_if_fail (GDK_WINDOW_IS_BROADWAY (window), NULL);
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
NULL);
return new_context;
}
GdkDragProtocol
_gdk_broadway_window_get_drag_protocol (GdkWindow *window,
GdkWindow **target)
{
return GDK_DRAG_PROTO_NONE;
}
static GdkWindow *
gdk_broadway_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol)
{
g_return_val_if_fail (context != NULL, NULL);
return NULL;
}
static gboolean
gdk_broadway_drag_context_drag_motion (GdkDragContext *context,
GdkWindow *dest_window,
GdkDragProtocol protocol,
gint x_root,
gint y_root,
GdkDragAction suggested_action,
GdkDragAction possible_actions,
guint32 time)
{
g_return_val_if_fail (context != NULL, FALSE);
g_return_val_if_fail (dest_window == NULL || GDK_WINDOW_IS_BROADWAY (dest_window), FALSE);
return FALSE;
}
static void
gdk_broadway_drag_context_drag_drop (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
}
static void
gdk_broadway_drag_context_drag_abort (GdkDragContext *context,
guint32 time)
{
g_return_if_fail (context != NULL);
}
/* Destination side */
static void
gdk_broadway_drag_context_drag_status (GdkDragContext *context,
GdkDragAction action,
guint32 time)
{
g_return_if_fail (context != NULL);
}
static void
gdk_broadway_drag_context_drop_reply (GdkDragContext *context,
gboolean ok,
guint32 time)
{
g_return_if_fail (context != NULL);
}
static void
gdk_broadway_drag_context_drop_finish (GdkDragContext *context,
gboolean success,
guint32 time)
{
g_return_if_fail (context != NULL);
}
void
_gdk_broadway_window_register_dnd (GdkWindow *window)
{
}
static GdkAtom
gdk_broadway_drag_context_get_selection (GdkDragContext *context)
{
g_return_val_if_fail (context != NULL, GDK_NONE);
return GDK_NONE;
}
static gboolean
gdk_broadway_drag_context_drop_status (GdkDragContext *context)
{
g_return_val_if_fail (context != NULL, FALSE);
return FALSE;
}
void
_gdk_broadway_display_init_dnd (GdkDisplay *display)
{
}
static void
gdk_broadway_drag_context_class_init (GdkBroadwayDragContextClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkDragContextClass *context_class = GDK_DRAG_CONTEXT_CLASS (klass);
object_class->finalize = gdk_broadway_drag_context_finalize;
context_class->find_window = gdk_broadway_drag_context_find_window;
context_class->drag_status = gdk_broadway_drag_context_drag_status;
context_class->drag_motion = gdk_broadway_drag_context_drag_motion;
context_class->drag_abort = gdk_broadway_drag_context_drag_abort;
context_class->drag_drop = gdk_broadway_drag_context_drag_drop;
context_class->drop_reply = gdk_broadway_drag_context_drop_reply;
context_class->drop_finish = gdk_broadway_drag_context_drop_finish;
context_class->drop_status = gdk_broadway_drag_context_drop_status;
context_class->get_selection = gdk_broadway_drag_context_get_selection;
}

View File

@ -0,0 +1,396 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkeventsource.h"
#include "gdkinternals.h"
#include <stdlib.h>
static gboolean gdk_event_source_prepare (GSource *source,
gint *timeout);
static gboolean gdk_event_source_check (GSource *source);
static gboolean gdk_event_source_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data);
static void gdk_event_source_finalize (GSource *source);
#define HAS_FOCUS(toplevel) \
((toplevel)->has_focus || (toplevel)->has_pointer_focus)
struct _GdkEventSource
{
GSource source;
GdkDisplay *display;
GPollFD event_poll_fd;
};
static GSourceFuncs event_funcs = {
gdk_event_source_prepare,
gdk_event_source_check,
gdk_event_source_dispatch,
gdk_event_source_finalize
};
static GList *event_sources = NULL;
static gboolean
gdk_event_source_prepare (GSource *source,
gint *timeout)
{
GdkDisplay *display = ((GdkEventSource*) source)->display;
gboolean retval;
GDK_THREADS_ENTER ();
*timeout = -1;
retval = (_gdk_event_queue_find_first (display) != NULL);
GDK_THREADS_LEAVE ();
return retval;
}
static gboolean
gdk_event_source_check (GSource *source)
{
GdkEventSource *event_source = (GdkEventSource*) source;
gboolean retval;
GDK_THREADS_ENTER ();
if (event_source->event_poll_fd.revents & G_IO_IN)
retval = (_gdk_event_queue_find_first (event_source->display) != NULL);
else
retval = FALSE;
GDK_THREADS_LEAVE ();
return retval;
}
typedef struct {
int id;
int root_x;
int root_y;
int win_x;
int win_y;
guint32 state;
guint64 time;
} PointerData;
static char *
parse_pointer_data (char *p, PointerData *data)
{
data->id = strtol (p, &p, 10);
p++; /* Skip , */
data->root_x = strtol (p, &p, 10);
p++; /* Skip , */
data->root_y = strtol (p, &p, 10);
p++; /* Skip , */
data->win_x = strtol (p, &p, 10);
p++; /* Skip , */
data->win_y = strtol (p, &p, 10);
p++; /* Skip , */
data->state = strtol (p, &p, 10);
p++; /* Skip , */
data->time = strtol(p, &p, 10);
return p;
}
void
_gdk_broadway_events_got_input (GdkDisplay *display,
const char *message)
{
GdkBroadwayDisplay *display_broadway = GDK_BROADWAY_DISPLAY (display);
GdkScreen *screen;
GdkWindow *root, *window;
char *p;
int button, dir, key, mode;
guint32 serial;
guint64 time;
GdkEvent *event = NULL;
char cmd;
GList *node;
PointerData data;
screen = gdk_display_get_default_screen (display);
root = gdk_screen_get_root_window (screen);
p = (char *)message;
cmd = *p++;
serial = (guint32)strtol (p, &p, 10);
p++; /* Skip , */
switch (cmd) {
case 'e': /* Enter */
p = parse_pointer_data (p, &data);
p++; /* Skip , */
mode = strtol(p, &p, 10);
display_broadway->last_x = data.root_x;
display_broadway->last_y = data.root_y;
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (data.id));
/* TODO: Unset when it dies */
display_broadway->mouse_in_toplevel = window;
if (window)
{
event = gdk_event_new (GDK_ENTER_NOTIFY);
event->crossing.window = g_object_ref (window);
event->crossing.time = data.time;
event->crossing.x = data.win_x;
event->crossing.y = data.win_y;
event->crossing.x_root = data.root_x;
event->crossing.y_root = data.root_y;
event->crossing.state = data.state;
event->crossing.mode = mode;
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.window = g_object_ref (window);
event->focus_change.in = TRUE;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
}
break;
case 'l': /* Leave */
p = parse_pointer_data (p, &data);
p++; /* Skip , */
mode = strtol(p, &p, 10);
display_broadway->last_x = data.root_x;
display_broadway->last_y = data.root_y;
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (data.id));
display_broadway->mouse_in_toplevel = NULL;
if (window)
{
event = gdk_event_new (GDK_LEAVE_NOTIFY);
event->crossing.window = g_object_ref (window);
event->crossing.time = data.time;
event->crossing.x = data.win_x;
event->crossing.y = data.win_y;
event->crossing.x_root = data.root_x;
event->crossing.y_root = data.root_y;
event->crossing.state = data.state;
event->crossing.mode = mode;
event->crossing.detail = GDK_NOTIFY_ANCESTOR;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
event = gdk_event_new (GDK_FOCUS_CHANGE);
event->focus_change.window = g_object_ref (window);
event->focus_change.in = FALSE;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
}
break;
case 'm': /* Mouse move */
p = parse_pointer_data (p, &data);
display_broadway->last_x = data.root_x;
display_broadway->last_y = data.root_y;
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (data.id));
if (window)
{
event = gdk_event_new (GDK_MOTION_NOTIFY);
event->motion.window = g_object_ref (window);
event->motion.time = data.time;
event->motion.x = data.win_x;
event->motion.y = data.win_y;
event->motion.x_root = data.root_x;
event->motion.y_root = data.root_y;
event->motion.state = data.state;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
}
break;
case 'b':
case 'B':
p = parse_pointer_data (p, &data);
p++; /* Skip , */
button = strtol(p, &p, 10);
display_broadway->last_x = data.root_x;
display_broadway->last_y = data.root_y;
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (data.id));
if (window)
{
event = gdk_event_new (cmd == 'b' ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE);
event->button.window = g_object_ref (window);
event->button.time = data.time;
event->button.x = data.win_x;
event->button.y = data.win_y;
event->button.x_root = data.root_x;
event->button.y_root = data.root_y;
event->button.button = button;
event->button.state = data.state;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
}
break;
case 's':
p = parse_pointer_data (p, &data);
p++; /* Skip , */
dir = strtol(p, &p, 10);
display_broadway->last_x = data.root_x;
display_broadway->last_y = data.root_y;
window = g_hash_table_lookup (display_broadway->id_ht, GINT_TO_POINTER (data.id));
if (window)
{
event = gdk_event_new (GDK_SCROLL);
event->scroll.window = g_object_ref (window);
event->scroll.time = data.time;
event->scroll.x = data.win_x;
event->scroll.y = data.win_y;
event->scroll.x_root = data.root_x;
event->scroll.y_root = data.root_y;
event->scroll.direction = dir == 0 ? GDK_SCROLL_UP : GDK_SCROLL_DOWN;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
}
break;
case 'k':
case 'K':
key = strtol(p, &p, 10);
p++; /* Skip , */
time = strtol(p, &p, 10);
window = display_broadway->mouse_in_toplevel;
if (window)
{
event = gdk_event_new (cmd == 'k' ? GDK_KEY_PRESS : GDK_KEY_RELEASE);
event->key.window = g_object_ref (window);
event->key.time = time;
event->key.keyval = key;
event->key.length = 0;
gdk_event_set_device (event, display->core_pointer);
node = _gdk_event_queue_append (display, event);
_gdk_windowing_got_event (display, node, event, serial);
}
break;
case 'g':
case 'u':
_gdk_display_device_grab_update (display, display->core_pointer, NULL, serial);
break;
case 'q':
g_printerr ("Got unexpected query pointer reply w serial %d\n", serial);
break;
default:
g_printerr ("Unknown input command %s\n", message);
break;
}
}
void
_gdk_broadway_display_queue_events (GdkDisplay *display)
{
}
static gboolean
gdk_event_source_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
GdkDisplay *display = ((GdkEventSource*) source)->display;
GdkEvent *event;
GDK_THREADS_ENTER ();
event = gdk_display_get_event (display);
if (event)
{
_gdk_event_emit (event);
gdk_event_free (event);
}
GDK_THREADS_LEAVE ();
return TRUE;
}
static void
gdk_event_source_finalize (GSource *source)
{
GdkEventSource *event_source = (GdkEventSource *)source;
event_sources = g_list_remove (event_sources, event_source);
}
GSource *
_gdk_broadway_event_source_new (GdkDisplay *display)
{
GSource *source;
GdkEventSource *event_source;
char *name;
source = g_source_new (&event_funcs, sizeof (GdkEventSource));
name = g_strdup_printf ("GDK Broadway Event source (%s)",
gdk_display_get_name (display));
g_source_set_name (source, name);
g_free (name);
event_source = (GdkEventSource *) source;
event_source->display = display;
g_source_set_priority (source, GDK_PRIORITY_EVENTS);
g_source_set_can_recurse (source, TRUE);
g_source_attach (source, NULL);
event_sources = g_list_prepend (event_sources, source);
return source;
}

View File

@ -0,0 +1,34 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2009 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_EVENT_SOURCE_H__
#define __GDK_EVENT_SOURCE_H__
#include "gdkprivate-broadway.h"
G_BEGIN_DECLS
typedef struct _GdkEventSource GdkEventSource;
G_GNUC_INTERNAL
GSource * _gdk_broadway_event_source_new (GdkDisplay *display);
G_END_DECLS
#endif /* __GDK_EVENT_SOURCE_H__ */

View File

@ -0,0 +1,33 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdktypes.h"
#include "gdkprivate-broadway.h"
#include <stdio.h>

View File

@ -0,0 +1,40 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkmain.h"
#include "gdkinternals.h"
#include "gdkdisplay-broadway.h"
#include <locale.h>
#include <stdlib.h>
#include <string.h>
void
_gdk_broadway_initialize_locale (void)
{
}

View File

@ -0,0 +1,190 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 2000 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkprivate-broadway.h"
#include "gdkinternals.h"
#include "gdkdisplay-broadway.h"
#include "gdkkeysprivate.h"
#include "gdkkeysyms.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
typedef struct _GdkBroadwayKeymap GdkBroadwayKeymap;
typedef struct _GdkKeymapClass GdkBroadwayKeymapClass;
#define GDK_TYPE_BROADWAY_KEYMAP (gdk_broadway_keymap_get_type ())
#define GDK_BROADWAY_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_KEYMAP, GdkBroadwayKeymap))
#define GDK_IS_BROADWAY_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_KEYMAP))
typedef struct _DirectionCacheEntry DirectionCacheEntry;
struct _GdkBroadwayKeymap
{
GdkKeymap parent_instance;
};
struct _GdkBroadwayKeymapClass
{
GdkKeymapClass keymap_class;
};
G_DEFINE_TYPE (GdkBroadwayKeymap, gdk_broadway_keymap, GDK_TYPE_KEYMAP)
static void gdk_broadway_keymap_finalize (GObject *object);
static void
gdk_broadway_keymap_init (GdkBroadwayKeymap *keymap)
{
}
static void
gdk_broadway_keymap_finalize (GObject *object)
{
G_OBJECT_CLASS (gdk_broadway_keymap_parent_class)->finalize (object);
}
GdkKeymap*
_gdk_broadway_display_get_keymap (GdkDisplay *display)
{
GdkBroadwayDisplay *broadway_display;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
broadway_display = GDK_BROADWAY_DISPLAY (display);
if (!broadway_display->keymap)
broadway_display->keymap = g_object_new (gdk_broadway_keymap_get_type (), NULL);
broadway_display->keymap->display = display;
return broadway_display->keymap;
}
static PangoDirection
gdk_broadway_keymap_get_direction (GdkKeymap *keymap)
{
return PANGO_DIRECTION_NEUTRAL;
}
static gboolean
gdk_broadway_keymap_have_bidi_layouts (GdkKeymap *keymap)
{
return FALSE;
}
static gboolean
gdk_broadway_keymap_get_caps_lock_state (GdkKeymap *keymap)
{
return FALSE;
}
static gboolean
gdk_broadway_keymap_get_num_lock_state (GdkKeymap *keymap)
{
return FALSE;
}
static gboolean
gdk_broadway_keymap_get_entries_for_keyval (GdkKeymap *keymap,
guint keyval,
GdkKeymapKey **keys,
gint *n_keys)
{
*n_keys = 0;
return FALSE;
}
static gboolean
gdk_broadway_keymap_get_entries_for_keycode (GdkKeymap *keymap,
guint hardware_keycode,
GdkKeymapKey **keys,
guint **keyvals,
gint *n_entries)
{
*n_entries = 0;
return FALSE;
}
static guint
gdk_broadway_keymap_lookup_key (GdkKeymap *keymap,
const GdkKeymapKey *key)
{
return 0;
}
static gboolean
gdk_broadway_keymap_translate_keyboard_state (GdkKeymap *keymap,
guint hardware_keycode,
GdkModifierType state,
gint group,
guint *keyval,
gint *effective_group,
gint *level,
GdkModifierType *consumed_modifiers)
{
return FALSE;
}
static void
gdk_broadway_keymap_add_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
}
static gboolean
gdk_broadway_keymap_map_virtual_modifiers (GdkKeymap *keymap,
GdkModifierType *state)
{
return FALSE;
}
static void
gdk_broadway_keymap_class_init (GdkBroadwayKeymapClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkKeymapClass *keymap_class = GDK_KEYMAP_CLASS (klass);
object_class->finalize = gdk_broadway_keymap_finalize;
keymap_class->get_direction = gdk_broadway_keymap_get_direction;
keymap_class->have_bidi_layouts = gdk_broadway_keymap_have_bidi_layouts;
keymap_class->get_caps_lock_state = gdk_broadway_keymap_get_caps_lock_state;
keymap_class->get_num_lock_state = gdk_broadway_keymap_get_num_lock_state;
keymap_class->get_entries_for_keyval = gdk_broadway_keymap_get_entries_for_keyval;
keymap_class->get_entries_for_keycode = gdk_broadway_keymap_get_entries_for_keycode;
keymap_class->lookup_key = gdk_broadway_keymap_lookup_key;
keymap_class->translate_keyboard_state = gdk_broadway_keymap_translate_keyboard_state;
keymap_class->add_virtual_modifiers = gdk_broadway_keymap_add_virtual_modifiers;
keymap_class->map_virtual_modifiers = gdk_broadway_keymap_map_virtual_modifiers;
}

View File

@ -0,0 +1,46 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkdisplay-broadway.h"
#include "gdkinternals.h"
#include "gdkprivate-broadway.h"
#include "gdkintl.h"
#include "gdkdeviceprivate.h"
#include <glib/gprintf.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
void
_gdk_broadway_windowing_init (void)
{
_gdk_broadway_initialize_locale ();
}

View File

@ -0,0 +1,218 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
/*
* Private uninstalled header defining things local to X windowing code
*/
#ifndef __GDK_PRIVATE_BROADWAY_H__
#define __GDK_PRIVATE_BROADWAY_H__
#include <gdk/gdkcursor.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdkinternals.h>
#include "gdkwindow-broadway.h"
#include "gdkdisplay-broadway.h"
#include "gdkbroadwaycursor.h"
#include "gdkbroadwayvisual.h"
#include "gdkbroadwaywindow.h"
void _gdk_broadway_resync_windows (void);
void _gdk_broadway_windowing_init (void);
gchar * _gdk_broadway_display_manager_get_atom_name (GdkDisplayManager *manager,
GdkAtom atom);
void _gdk_broadway_display_manager_add_display (GdkDisplayManager *manager,
GdkDisplay *display);
void _gdk_broadway_display_manager_remove_display (GdkDisplayManager *manager,
GdkDisplay *display);
GdkAtom _gdk_broadway_display_manager_atom_intern_static_string (GdkDisplayManager *manager,
const gchar *atom_name);
GdkAtom _gdk_broadway_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name,
gboolean only_if_exists);
void _gdk_broadway_window_register_dnd (GdkWindow *window);
GdkDragContext * _gdk_broadway_window_drag_begin (GdkWindow *window,
GdkDevice *device,
GList *targets);
gboolean _gdk_broadway_window_queue_antiexpose (GdkWindow *window,
cairo_region_t *area);
void _gdk_broadway_window_translate (GdkWindow *window,
cairo_region_t *area,
gint dx,
gint dy);
gboolean _gdk_broadway_window_get_property (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gulong offset,
gulong length,
gint pdelete,
GdkAtom *actual_property_type,
gint *actual_format_type,
gint *actual_length,
guchar **data);
void _gdk_broadway_window_change_property (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gint format,
GdkPropMode mode,
const guchar *data,
gint nelements);
void _gdk_broadway_window_delete_property (GdkWindow *window,
GdkAtom property);
void _gdk_broadway_selection_window_destroyed (GdkWindow *window);
void _gdk_keymap_keys_changed (GdkDisplay *display);
gint _gdk_broadway_get_group_for_state (GdkDisplay *display,
GdkModifierType state);
void _gdk_keymap_add_virtual_modifiers_compat (GdkKeymap *keymap,
GdkModifierType *modifiers);
gboolean _gdk_keymap_key_is_modifier (GdkKeymap *keymap,
guint keycode);
void _gdk_broadway_initialize_locale (void);
void _gdk_broadway_screen_events_init (GdkScreen *screen);
GdkVisual *_gdk_broadway_screen_get_system_visual (GdkScreen * screen);
gint _gdk_broadway_screen_visual_get_best_depth (GdkScreen * screen);
GdkVisualType _gdk_broadway_screen_visual_get_best_type (GdkScreen * screen);
GdkVisual *_gdk_broadway_screen_get_system_visual (GdkScreen * screen);
GdkVisual*_gdk_broadway_screen_visual_get_best (GdkScreen * screen);
GdkVisual*_gdk_broadway_screen_visual_get_best_with_depth (GdkScreen * screen,
gint depth);
GdkVisual*_gdk_broadway_screen_visual_get_best_with_type (GdkScreen * screen,
GdkVisualType visual_type);
GdkVisual*_gdk_broadway_screen_visual_get_best_with_both (GdkScreen * screen,
gint depth,
GdkVisualType visual_type);
void _gdk_broadway_screen_query_depths (GdkScreen * screen,
gint **depths,
gint *count);
void _gdk_broadway_screen_query_visual_types (GdkScreen * screen,
GdkVisualType **visual_types,
gint *count);
GList *_gdk_broadway_screen_list_visuals (GdkScreen *screen);
void _gdk_broadway_events_got_input (GdkDisplay *display,
const char *message);
void _gdk_broadway_screen_init_root_window (GdkScreen *screen);
void _gdk_broadway_screen_init_visuals (GdkScreen *screen);
void _gdk_broadway_display_init_dnd (GdkDisplay *display);
GdkDisplay * _gdk_broadway_display_open (const gchar *display_name);
void _gdk_broadway_display_queue_events (GdkDisplay *display);
GdkDragProtocol _gdk_broadway_window_get_drag_protocol (GdkWindow *window,
GdkWindow **target);
GdkCursor*_gdk_broadway_display_get_cursor_for_type (GdkDisplay *display,
GdkCursorType cursor_type);
GdkCursor*_gdk_broadway_display_get_cursor_for_name (GdkDisplay *display,
const gchar *name);
GdkCursor *_gdk_broadway_display_get_cursor_for_pixbuf (GdkDisplay *display,
GdkPixbuf *pixbuf,
gint x,
gint y);
gboolean _gdk_broadway_display_supports_cursor_alpha (GdkDisplay *display);
gboolean _gdk_broadway_display_supports_cursor_color (GdkDisplay *display);
void _gdk_broadway_display_get_default_cursor_size (GdkDisplay *display,
guint *width,
guint *height);
void _gdk_broadway_display_get_maximal_cursor_size (GdkDisplay *display,
guint *width,
guint *height);
void _gdk_broadway_display_before_process_all_updates (GdkDisplay *display);
void _gdk_broadway_display_after_process_all_updates (GdkDisplay *display);
void _gdk_broadway_display_create_window_impl (GdkDisplay *display,
GdkWindow *window,
GdkWindow *real_parent,
GdkScreen *screen,
GdkEventMask event_mask,
GdkWindowAttr *attributes,
gint attributes_mask);
gboolean _gdk_broadway_display_set_selection_owner (GdkDisplay *display,
GdkWindow *owner,
GdkAtom selection,
guint32 time,
gboolean send_event);
GdkWindow * _gdk_broadway_display_get_selection_owner (GdkDisplay *display,
GdkAtom selection);
gint _gdk_broadway_display_get_selection_property (GdkDisplay *display,
GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format);
void _gdk_broadway_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time);
void _gdk_broadway_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time);
gint _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list);
gchar *_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display,
const gchar *str);
GdkKeymap* _gdk_broadway_display_get_keymap (GdkDisplay *display);
char * _gdk_broadway_display_block_for_input (GdkDisplay *display,
char op,
guint32 serial,
gboolean remove);
/* Window methods - testing */
void _gdk_broadway_window_sync_rendering (GdkWindow *window);
gboolean _gdk_broadway_window_simulate_key (GdkWindow *window,
gint x,
gint y,
guint keyval,
GdkModifierType modifiers,
GdkEventType key_pressrelease);
gboolean _gdk_broadway_window_simulate_button (GdkWindow *window,
gint x,
gint y,
guint button,
GdkModifierType modifiers,
GdkEventType button_pressrelease);
void _gdk_broadway_cursor_update_theme (GdkCursor *cursor);
void _gdk_broadway_cursor_display_finalize (GdkDisplay *display);
#define GDK_SCREEN_DISPLAY(screen) (GDK_BROADWAY_SCREEN (screen)->display)
#define GDK_WINDOW_SCREEN(win) (GDK_WINDOW_IMPL_BROADWAY (((GdkWindow *)win)->impl)->screen)
#define GDK_WINDOW_DISPLAY(win) (GDK_BROADWAY_SCREEN (GDK_WINDOW_SCREEN (win))->display)
#define GDK_WINDOW_IS_BROADWAY(win) (GDK_IS_WINDOW_IMPL_BROADWAY (((GdkWindow *)win)->impl))
#endif /* __GDK_PRIVATE_BROADWAY_H__ */

View File

@ -0,0 +1,100 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkproperty.h"
#include "gdkmain.h"
#include "gdkprivate.h"
#include "gdkinternals.h"
#include "gdkdisplay-broadway.h"
#include "gdkscreen-broadway.h"
#include "gdkselection.h"
#include <string.h>
GdkAtom
_gdk_broadway_display_manager_atom_intern (GdkDisplayManager *manager,
const gchar *atom_name,
gboolean only_if_exists)
{
return _GDK_MAKE_ATOM (g_quark_from_string (atom_name));
}
GdkAtom
_gdk_broadway_display_manager_atom_intern_static_string (GdkDisplayManager *manager,
const gchar *atom_name)
{
return _GDK_MAKE_ATOM (g_quark_from_static_string (atom_name));
}
static G_CONST_RETURN char *
get_atom_name (GdkAtom atom)
{
return g_quark_to_string (GPOINTER_TO_UINT(atom));
}
gchar *
_gdk_broadway_display_manager_get_atom_name (GdkDisplayManager *manager,
GdkAtom atom)
{
return g_strdup (get_atom_name (atom));
}
gboolean
_gdk_broadway_window_get_property (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gulong offset,
gulong length,
gint pdelete,
GdkAtom *actual_property_type,
gint *actual_format_type,
gint *actual_length,
guchar **data)
{
return FALSE;
}
void
_gdk_broadway_window_change_property (GdkWindow *window,
GdkAtom property,
GdkAtom type,
gint format,
GdkPropMode mode,
const guchar *data,
gint nelements)
{
g_return_if_fail (!window || GDK_WINDOW_IS_BROADWAY (window));
}
void
_gdk_broadway_window_delete_property (GdkWindow *window,
GdkAtom property)
{
g_return_if_fail (!window || GDK_WINDOW_IS_BROADWAY (window));
}

View File

@ -0,0 +1,329 @@
/*
* gdkscreen-broadway.c
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdkscreen-broadway.h"
#include "gdkscreen.h"
#include "gdkdisplay.h"
#include "gdkdisplay-broadway.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
static void gdk_broadway_screen_dispose (GObject *object);
static void gdk_broadway_screen_finalize (GObject *object);
G_DEFINE_TYPE (GdkBroadwayScreen, gdk_broadway_screen, GDK_TYPE_SCREEN)
static void
gdk_broadway_screen_init (GdkBroadwayScreen *screen)
{
screen->width = 1024;
screen->height = 768;
}
static GdkDisplay *
gdk_broadway_screen_get_display (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return GDK_BROADWAY_SCREEN (screen)->display;
}
static gint
gdk_broadway_screen_get_width (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_BROADWAY_SCREEN (screen)->width;
}
static gint
gdk_broadway_screen_get_height (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return GDK_BROADWAY_SCREEN (screen)->height;
}
static gint
gdk_broadway_screen_get_width_mm (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return gdk_screen_get_width (screen) * 25.4 / 96;
}
static gint
gdk_broadway_screen_get_height_mm (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return gdk_screen_get_height (screen) * 25.4 / 96;
}
static gint
gdk_broadway_screen_get_number (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return 0;
}
static GdkWindow *
gdk_broadway_screen_get_root_window (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return GDK_BROADWAY_SCREEN (screen)->root_window;
}
static void
gdk_broadway_screen_dispose (GObject *object)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (object);
if (broadway_screen->root_window)
_gdk_window_destroy (broadway_screen->root_window, TRUE);
G_OBJECT_CLASS (gdk_broadway_screen_parent_class)->dispose (object);
}
static void
gdk_broadway_screen_finalize (GObject *object)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (object);
gint i;
if (broadway_screen->root_window)
g_object_unref (broadway_screen->root_window);
/* Visual Part */
for (i = 0; i < broadway_screen->nvisuals; i++)
g_object_unref (broadway_screen->visuals[i]);
g_free (broadway_screen->visuals);
G_OBJECT_CLASS (gdk_broadway_screen_parent_class)->finalize (object);
}
static gint
gdk_broadway_screen_get_n_monitors (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return 1;
}
static gint
gdk_broadway_screen_get_primary_monitor (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
return 0;
}
static gint
gdk_broadway_screen_get_monitor_width_mm (GdkScreen *screen,
gint monitor_num)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
g_return_val_if_fail (monitor_num == 0, -1);
return gdk_screen_get_width_mm (screen);
}
static gint
gdk_broadway_screen_get_monitor_height_mm (GdkScreen *screen,
gint monitor_num)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
g_return_val_if_fail (monitor_num == 0, -1);
return gdk_screen_get_height_mm (screen);
}
static gchar *
gdk_broadway_screen_get_monitor_plug_name (GdkScreen *screen,
gint monitor_num)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
g_return_val_if_fail (monitor_num == 0, NULL);
return g_strdup ("browser");
}
static void
gdk_broadway_screen_get_monitor_geometry (GdkScreen *screen,
gint monitor_num,
GdkRectangle *dest)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (monitor_num == 0);
if (dest)
{
dest->x = 0;
dest->y = 0;
dest->width = broadway_screen->width;
dest->height = broadway_screen->height;
}
}
static GdkVisual *
gdk_broadway_screen_get_rgba_visual (GdkScreen *screen)
{
GdkBroadwayScreen *broadway_screen;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
broadway_screen = GDK_BROADWAY_SCREEN (screen);
return broadway_screen->rgba_visual;
}
GdkScreen *
_gdk_broadway_screen_new (GdkDisplay *display,
gint screen_number)
{
GdkScreen *screen;
GdkBroadwayScreen *broadway_screen;
screen = g_object_new (GDK_TYPE_BROADWAY_SCREEN, NULL);
broadway_screen = GDK_BROADWAY_SCREEN (screen);
broadway_screen->display = display;
_gdk_broadway_screen_init_visuals (screen);
_gdk_broadway_screen_init_root_window (screen);
return screen;
}
/*
* It is important that we first request the selection
* notification, and then setup the initial state of
* is_composited to avoid a race condition here.
*/
void
_gdk_broadway_screen_setup (GdkScreen *screen)
{
}
static gboolean
gdk_broadway_screen_is_composited (GdkScreen *screen)
{
GdkBroadwayScreen *broadway_screen;
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
broadway_screen = GDK_BROADWAY_SCREEN (screen);
return FALSE;
}
static gchar *
gdk_broadway_screen_make_display_name (GdkScreen *screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return g_strdup ("browser");
}
static GdkWindow *
gdk_broadway_screen_get_active_window (GdkScreen *screen)
{
return NULL;
}
static GList *
gdk_broadway_screen_get_window_stack (GdkScreen *screen)
{
return NULL;
}
static void
gdk_broadway_screen_broadcast_client_message (GdkScreen *screen,
GdkEvent *event)
{
}
static gboolean
gdk_broadway_screen_get_setting (GdkScreen *screen,
const gchar *name,
GValue *value)
{
return FALSE;
}
void
_gdk_broadway_screen_events_init (GdkScreen *screen)
{
}
static void
gdk_broadway_screen_class_init (GdkBroadwayScreenClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GdkScreenClass *screen_class = GDK_SCREEN_CLASS (klass);
object_class->dispose = gdk_broadway_screen_dispose;
object_class->finalize = gdk_broadway_screen_finalize;
screen_class->get_display = gdk_broadway_screen_get_display;
screen_class->get_width = gdk_broadway_screen_get_width;
screen_class->get_height = gdk_broadway_screen_get_height;
screen_class->get_width_mm = gdk_broadway_screen_get_width_mm;
screen_class->get_height_mm = gdk_broadway_screen_get_height_mm;
screen_class->get_number = gdk_broadway_screen_get_number;
screen_class->get_root_window = gdk_broadway_screen_get_root_window;
screen_class->get_n_monitors = gdk_broadway_screen_get_n_monitors;
screen_class->get_primary_monitor = gdk_broadway_screen_get_primary_monitor;
screen_class->get_monitor_width_mm = gdk_broadway_screen_get_monitor_width_mm;
screen_class->get_monitor_height_mm = gdk_broadway_screen_get_monitor_height_mm;
screen_class->get_monitor_plug_name = gdk_broadway_screen_get_monitor_plug_name;
screen_class->get_monitor_geometry = gdk_broadway_screen_get_monitor_geometry;
screen_class->is_composited = gdk_broadway_screen_is_composited;
screen_class->make_display_name = gdk_broadway_screen_make_display_name;
screen_class->get_active_window = gdk_broadway_screen_get_active_window;
screen_class->get_window_stack = gdk_broadway_screen_get_window_stack;
screen_class->broadcast_client_message = gdk_broadway_screen_broadcast_client_message;
screen_class->get_setting = gdk_broadway_screen_get_setting;
screen_class->get_rgba_visual = gdk_broadway_screen_get_rgba_visual;
screen_class->get_system_visual = _gdk_broadway_screen_get_system_visual;
screen_class->visual_get_best_depth = _gdk_broadway_screen_visual_get_best_depth;
screen_class->visual_get_best_type = _gdk_broadway_screen_visual_get_best_type;
screen_class->visual_get_best = _gdk_broadway_screen_visual_get_best;
screen_class->visual_get_best_with_depth = _gdk_broadway_screen_visual_get_best_with_depth;
screen_class->visual_get_best_with_type = _gdk_broadway_screen_visual_get_best_with_type;
screen_class->visual_get_best_with_both = _gdk_broadway_screen_visual_get_best_with_both;
screen_class->query_depths = _gdk_broadway_screen_query_depths;
screen_class->query_visual_types = _gdk_broadway_screen_query_visual_types;
screen_class->list_visuals = _gdk_broadway_screen_list_visuals;
}

View File

@ -0,0 +1,80 @@
/*
* gdkscreen-broadway.h
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GDK_BROADWAY_SCREEN_H__
#define __GDK_BROADWAY_SCREEN_H__
#include <gdk/gdkscreenprivate.h>
#include <gdk/gdkvisual.h>
#include "gdkprivate-broadway.h"
G_BEGIN_DECLS
typedef struct _GdkBroadwayScreen GdkBroadwayScreen;
typedef struct _GdkBroadwayScreenClass GdkBroadwayScreenClass;
#define GDK_TYPE_BROADWAY_SCREEN (gdk_broadway_screen_get_type ())
#define GDK_BROADWAY_SCREEN(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_BROADWAY_SCREEN, GdkBroadwayScreen))
#define GDK_BROADWAY_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_BROADWAY_SCREEN, GdkBroadwayScreenClass))
#define GDK_IS_BROADWAY_SCREEN(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_BROADWAY_SCREEN))
#define GDK_IS_BROADWAY_SCREEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_BROADWAY_SCREEN))
#define GDK_BROADWAY_SCREEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_BROADWAY_SCREEN, GdkBroadwayScreenClass))
typedef struct _GdkBroadwayMonitor GdkBroadwayMonitor;
struct _GdkBroadwayScreen
{
GdkScreen parent_instance;
GdkDisplay *display;
GdkWindow *root_window;
int width;
int height;
/* Visual Part */
GdkVisual **visuals;
gint nvisuals;
GdkVisual *system_visual;
GdkVisual *rgba_visual;
gint available_depths[7];
gint navailable_depths;
GdkVisualType available_types[6];
gint navailable_types;
};
struct _GdkBroadwayScreenClass
{
GdkScreenClass parent_class;
void (* window_manager_changed) (GdkBroadwayScreen *screen);
};
GType gdk_broadway_screen_get_type (void);
GdkScreen * _gdk_broadway_screen_new (GdkDisplay *display,
gint screen_number);
void _gdk_broadway_screen_setup (GdkScreen *screen);
G_END_DECLS
#endif /* __GDK_BROADWAY_SCREEN_H__ */

View File

@ -0,0 +1,146 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkselection.h"
#include "gdkproperty.h"
#include "gdkprivate.h"
#include "gdkprivate-broadway.h"
#include "gdkdisplay-broadway.h"
#include <string.h>
typedef struct _OwnerInfo OwnerInfo;
struct _OwnerInfo
{
GdkAtom selection;
GdkWindow *owner;
gulong serial;
};
static GSList *owner_list;
/* When a window is destroyed we check if it is the owner
* of any selections. This is somewhat inefficient, but
* owner_list is typically short, and it is a low memory,
* low code solution
*/
void
_gdk_broadway_selection_window_destroyed (GdkWindow *window)
{
GSList *tmp_list = owner_list;
while (tmp_list)
{
OwnerInfo *info = tmp_list->data;
tmp_list = tmp_list->next;
if (info->owner == window)
{
owner_list = g_slist_remove (owner_list, info);
g_free (info);
}
}
}
gboolean
_gdk_broadway_display_set_selection_owner (GdkDisplay *display,
GdkWindow *owner,
GdkAtom selection,
guint32 time,
gboolean send_event)
{
return FALSE;
}
GdkWindow *
_gdk_broadway_display_get_selection_owner (GdkDisplay *display,
GdkAtom selection)
{
return NULL;
}
void
_gdk_broadway_display_convert_selection (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
guint32 time)
{
}
gint
_gdk_broadway_display_get_selection_property (GdkDisplay *display,
GdkWindow *requestor,
guchar **data,
GdkAtom *ret_type,
gint *ret_format)
{
if (ret_type)
*ret_type = GDK_NONE;
if (ret_format)
*ret_format = 0;
if (data)
*data = NULL;
return 0;
}
void
_gdk_broadway_display_send_selection_notify (GdkDisplay *display,
GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time)
{
g_return_if_fail (GDK_IS_DISPLAY (display));
}
gint
_gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display,
GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
{
g_return_val_if_fail (text != NULL, 0);
g_return_val_if_fail (length >= 0, 0);
g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
return 0;
}
gchar *
_gdk_broadway_display_utf8_to_string_target (GdkDisplay *display,
const gchar *str)
{
return g_strdup (str);
}

View File

@ -0,0 +1,67 @@
/* Gtk+ testing utilities
* Copyright (C) 2007 Imendio AB
* Authors: Tim Janik
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <gdk/gdktestutils.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkinternals.h>
void
_gdk_broadway_window_sync_rendering (GdkWindow *window)
{
/* FIXME: Find out if there is a way to implement this on broadway. */
}
gboolean
_gdk_broadway_window_simulate_key (GdkWindow *window,
gint x,
gint y,
guint keyval,
GdkModifierType modifiers,
GdkEventType key_pressrelease)
{
g_return_val_if_fail (key_pressrelease == GDK_KEY_PRESS || key_pressrelease == GDK_KEY_RELEASE, FALSE);
g_return_val_if_fail (window != NULL, FALSE);
if (!GDK_WINDOW_IS_MAPPED (window))
return FALSE;
/* FIXME: Implement. */
return FALSE;
}
gboolean
_gdk_broadway_window_simulate_button (GdkWindow *window,
gint x,
gint y,
guint button, /*1..3*/
GdkModifierType modifiers,
GdkEventType button_pressrelease)
{
g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE);
g_return_val_if_fail (window != NULL, FALSE);
if (!GDK_WINDOW_IS_MAPPED (window))
return FALSE;
/* FIXME: Implement. */
return FALSE;
}

View File

@ -0,0 +1,290 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkvisualprivate.h"
#include "gdkprivate-broadway.h"
#include "gdkscreen-broadway.h"
#include "gdkinternals.h"
struct _GdkBroadwayVisual
{
GdkVisual visual;
};
struct _GdkBroadwayVisualClass
{
GObjectClass parent_class;
};
static void gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec);
G_DEFINE_TYPE (GdkBroadwayVisual, gdk_broadway_visual, GDK_TYPE_VISUAL)
static void
gdk_broadway_visual_finalize (GObject *object)
{
G_OBJECT_CLASS (gdk_broadway_visual_parent_class)->finalize (object);
}
static void
gdk_broadway_visual_class_init (GdkBroadwayVisualClass *visual_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (visual_class);
object_class->finalize = gdk_broadway_visual_finalize;
}
static void
gdk_broadway_visual_init (GdkBroadwayVisual *visual)
{
}
void
_gdk_broadway_screen_init_visuals (GdkScreen *screen)
{
GdkBroadwayScreen *broadway_screen;
GdkVisual **visuals;
int nvisuals;
g_return_if_fail (GDK_IS_SCREEN (screen));
broadway_screen = GDK_BROADWAY_SCREEN (screen);
nvisuals = 2;
visuals = g_new (GdkVisual *, nvisuals);
visuals[0] = g_object_new (GDK_TYPE_BROADWAY_VISUAL, NULL);
visuals[0]->screen = screen;
visuals[0]->type = GDK_VISUAL_TRUE_COLOR;
visuals[0]->depth = 32;
visuals[0]->byte_order = (G_BYTE_ORDER == G_LITTLE_ENDIAN) ? GDK_LSB_FIRST : GDK_MSB_FIRST;
visuals[0]->red_mask = 0xff0000;
visuals[0]->green_mask = 0xff00;
visuals[0]->blue_mask = 0xff;
visuals[0]->colormap_size = 256;
visuals[0]->bits_per_rgb = 8;
gdk_visual_decompose_mask (visuals[0]->red_mask,
&visuals[0]->red_shift,
&visuals[0]->red_prec);
gdk_visual_decompose_mask (visuals[0]->green_mask,
&visuals[0]->green_shift,
&visuals[0]->green_prec);
gdk_visual_decompose_mask (visuals[0]->blue_mask,
&visuals[0]->blue_shift,
&visuals[0]->blue_prec);
visuals[1] = g_object_new (GDK_TYPE_BROADWAY_VISUAL, NULL);
visuals[1]->screen = screen;
visuals[1]->type = GDK_VISUAL_TRUE_COLOR;
visuals[1]->depth = 24;
visuals[1]->byte_order = (G_BYTE_ORDER == G_LITTLE_ENDIAN) ? GDK_LSB_FIRST : GDK_MSB_FIRST;
visuals[1]->red_mask = 0xff0000;
visuals[1]->green_mask = 0xff00;
visuals[1]->blue_mask = 0xff;
visuals[1]->colormap_size = 256;
visuals[1]->bits_per_rgb = 8;
gdk_visual_decompose_mask (visuals[1]->red_mask,
&visuals[1]->red_shift,
&visuals[1]->red_prec);
gdk_visual_decompose_mask (visuals[1]->green_mask,
&visuals[1]->green_shift,
&visuals[1]->green_prec);
gdk_visual_decompose_mask (visuals[1]->blue_mask,
&visuals[1]->blue_shift,
&visuals[1]->blue_prec);
broadway_screen->system_visual = visuals[1];
broadway_screen->rgba_visual = visuals[0];
broadway_screen->navailable_depths = 2;
broadway_screen->available_depths[0] = 32;
broadway_screen->available_depths[1] = 24;
broadway_screen->navailable_types = 1;
broadway_screen->available_types[0] = GDK_VISUAL_TRUE_COLOR;
broadway_screen->visuals = visuals;
broadway_screen->nvisuals = nvisuals;
}
gint
_gdk_broadway_screen_visual_get_best_depth (GdkScreen * screen)
{
return GDK_BROADWAY_SCREEN (screen)->available_depths[0];
}
GdkVisualType
_gdk_broadway_screen_visual_get_best_type (GdkScreen * screen)
{
return GDK_BROADWAY_SCREEN (screen)->available_types[0];
}
GdkVisual *
_gdk_broadway_screen_get_system_visual (GdkScreen * screen)
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
return ((GdkVisual *) GDK_BROADWAY_SCREEN (screen)->system_visual);
}
GdkVisual*
_gdk_broadway_screen_visual_get_best (GdkScreen * screen)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
return (GdkVisual *)broadway_screen->visuals[0];
}
GdkVisual*
_gdk_broadway_screen_visual_get_best_with_depth (GdkScreen * screen,
gint depth)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
GdkVisual *return_val;
int i;
return_val = NULL;
for (i = 0; i < broadway_screen->nvisuals; i++)
if (depth == broadway_screen->visuals[i]->depth)
{
return_val = (GdkVisual *) broadway_screen->visuals[i];
break;
}
return return_val;
}
GdkVisual*
_gdk_broadway_screen_visual_get_best_with_type (GdkScreen * screen,
GdkVisualType visual_type)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
GdkVisual *return_val;
int i;
return_val = NULL;
for (i = 0; i < broadway_screen->nvisuals; i++)
if (visual_type == broadway_screen->visuals[i]->type)
{
return_val = (GdkVisual *) broadway_screen->visuals[i];
break;
}
return return_val;
}
GdkVisual*
_gdk_broadway_screen_visual_get_best_with_both (GdkScreen * screen,
gint depth,
GdkVisualType visual_type)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
GdkVisual *return_val;
int i;
return_val = NULL;
for (i = 0; i < broadway_screen->nvisuals; i++)
if ((depth == broadway_screen->visuals[i]->depth) &&
(visual_type == broadway_screen->visuals[i]->type))
{
return_val = (GdkVisual *) broadway_screen->visuals[i];
break;
}
return return_val;
}
void
_gdk_broadway_screen_query_depths (GdkScreen * screen,
gint **depths,
gint *count)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
*count = broadway_screen->navailable_depths;
*depths = broadway_screen->available_depths;
}
void
_gdk_broadway_screen_query_visual_types (GdkScreen * screen,
GdkVisualType **visual_types,
gint *count)
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
*count = broadway_screen->navailable_types;
*visual_types = broadway_screen->available_types;
}
GList *
_gdk_broadway_screen_list_visuals (GdkScreen *screen)
{
GList *list;
GdkBroadwayScreen *broadway_screen;
guint i;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
broadway_screen = GDK_BROADWAY_SCREEN (screen);
list = NULL;
for (i = 0; i < broadway_screen->nvisuals; ++i)
list = g_list_append (list, broadway_screen->visuals[i]);
return list;
}
static void
gdk_visual_decompose_mask (gulong mask,
gint *shift,
gint *prec)
{
*shift = 0;
*prec = 0;
if (mask == 0)
{
g_warning ("Mask is 0 in visual. Server bug ?");
return;
}
while (!(mask & 0x1))
{
(*shift)++;
mask >>= 1;
}
while (mask & 0x1)
{
(*prec)++;
mask >>= 1;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,77 @@
/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GDK_WINDOW_BROADWAY_H__
#define __GDK_WINDOW_BROADWAY_H__
#include <gdk/gdkwindowimpl.h>
G_BEGIN_DECLS
typedef struct _GdkWindowImplBroadway GdkWindowImplBroadway;
typedef struct _GdkWindowImplBroadwayClass GdkWindowImplBroadwayClass;
/* Window implementation for Broadway
*/
#define GDK_TYPE_WINDOW_IMPL_BROADWAY (gdk_window_impl_broadway_get_type ())
#define GDK_WINDOW_IMPL_BROADWAY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_WINDOW_IMPL_BROADWAY, GdkWindowImplBroadway))
#define GDK_WINDOW_IMPL_BROADWAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_WINDOW_IMPL_BROADWAY, GdkWindowImplBroadwayClass))
#define GDK_IS_WINDOW_IMPL_BROADWAY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_WINDOW_IMPL_BROADWAY))
#define GDK_IS_WINDOW_IMPL_BROADWAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_WINDOW_IMPL_BROADWAY))
#define GDK_WINDOW_IMPL_BROADWAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_WINDOW_IMPL_BROADWAY, GdkWindowImplBroadwayClass))
struct _GdkWindowImplBroadway
{
GdkWindowImpl parent_instance;
GdkWindow *wrapper;
GdkScreen *screen;
cairo_surface_t *surface;
cairo_surface_t *last_surface;
cairo_surface_t *ref_surface;
GdkCursor *cursor;
GHashTable *device_cursor;
int id;
gint8 toplevel_window_type;
gboolean dirty;
gboolean last_synced;
};
struct _GdkWindowImplBroadwayClass
{
GdkWindowImplClass parent_class;
};
GType gdk_window_impl_broadway_get_type (void);
G_END_DECLS
#endif /* __GDK_WINDOW_BROADWAY_H__ */

15
gdk/broadway/toarray.pl Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/perl -w
my $FILENAME = $ARGV[0];
open FILE, $FILENAME or die "Cannot open $FILENAME";
my $ARRAYNAME = $ARGV[1];
print "static const char $ARRAYNAME\[\] =";
while (<FILE>) {
s@\\@\\\\@g;
s@"@\\"@g;
chomp ($_);
print "\n \"$_\\n\"";
}
print ";\n";

View File

@ -44,6 +44,10 @@
#include "quartz/gdkquartzdisplaymanager.h"
#endif
#ifdef GDK_WINDOWING_BROADWAY
#include "broadway/gdkbroadwaydisplaymanager.h"
#endif
#ifdef GDK_WINDOWING_WIN32
#include "win32/gdkwin32.h"
#endif
@ -239,6 +243,11 @@ gdk_display_manager_get (void)
if (backend == NULL || strcmp (backend, "x11") == 0)
manager = g_object_new (gdk_x11_display_manager_get_type (), NULL);
else
#endif
#ifdef GDK_WINDOWING_BROADWAY
if (backend == NULL || strcmp (backend, "broadway") == 0)
manager = g_object_new (gdk_broadway_display_manager_get_type (), NULL);
else
#endif
if (backend != NULL)
g_error ("Unsupported GDK backend: %s", backend);

View File

@ -280,6 +280,8 @@ create_child_plug (guint32 xid,
return GDK_WINDOW_XID (gtk_widget_get_window (window));
#elif defined (GDK_WINDOWING_WIN32)
return (guint32) GDK_WINDOW_HWND (gtk_widget_get_window (window));
#elif defined (GDK_WINDOWING_BROADWAY)
return (guint32) 0; /* Child windows not supported */
#endif
else
return 0;