1 /*****************************************************************************
2 * JVLC.java: JNI interface for vlc Java Bindings
3 *****************************************************************************
4 * Copyright (C) 1998-2005 the VideoLAN team
6 * Authors: Filippo Carone <filippo@carone.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 *****************************************************************************/
30 #include <X11/Xlib.h> // for Xlibs graphics functions
33 #include <stdio.h> // for printf
35 /* JVLC internal imports, generated by gcjh */
36 #include "org_videolan_jvlc_JVLCCanvas.h"
39 * This will only work on X11 at the moment
42 JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLCCanvas_paint (JNIEnv *env, jobject canvas, jobject graphics) {
45 JAWT_DrawingSurface* ds;
46 JAWT_DrawingSurfaceInfo* dsi;
49 JAWT_Win32DrawingSurfaceInfo* dsi_win;
51 JAWT_X11DrawingSurfaceInfo* dsi_x11;
61 awt.version = JAWT_VERSION_1_3;
62 if (JAWT_GetAWT(env, &awt) == JNI_FALSE) {
63 printf("AWT Not found\n");
67 /* Get the drawing surface */
68 ds = awt.GetDrawingSurface(env, canvas);
70 printf("NULL drawing surface\n");
74 /* Lock the drawing surface */
76 if((lock & JAWT_LOCK_ERROR) != 0) {
77 printf("Error locking surface\n");
78 awt.FreeDrawingSurface(ds);
82 /* Get the drawing surface info */
83 dsi = ds->GetDrawingSurfaceInfo(ds);
85 printf("Error getting surface info\n");
87 awt.FreeDrawingSurface(ds);
93 /* Get the platform-specific drawing info */
94 dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
97 value.i_int = reinterpret_cast<int>(dsi_win->hwnd);
98 VLC_VariableSet( 1, "drawable", value );
101 /* Get the platform-specific drawing info */
102 dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
105 gc = XCreateGC(dsi_x11->display, dsi_x11->drawable, 0, 0);
106 XSetBackground(dsi_x11->display, gc, 0);
108 value.i_int = dsi_x11->drawable;
109 VLC_VariableSet( 0, "drawable", value );
110 XFreeGC(dsi_x11->display, gc);
114 /* Free the drawing surface info */
115 ds->FreeDrawingSurfaceInfo(dsi);
117 /* Unlock the drawing surface */
120 /* Free the drawing surface */
121 awt.FreeDrawingSurface(ds);