Update of /cvsroot/xine/xine-plugin/src
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28032
Modified Files:
plugin.c
Log Message:
Translate window to video coordinates before sending mouse events.
Periodically query window position (because the plugin doesn't receive
ConfigureNotify events).
Do not reallocate the video window when the parent window size changes, simply
resize it.
Index: plugin.c
===================================================================
RCS file: /cvsroot/xine/xine-plugin/src/plugin.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- plugin.c 23 Nov 2006 16:38:42 -0000 1.41
+++ plugin.c 24 Nov 2006 20:59:05 -0000 1.42
@@ -55,8 +55,7 @@
#ifdef LOG
# define log(x, ...) \
do {\
- fprintf (stderr, "Xine Plugin (%d): ", getpid());\
- fprintf (stderr, x "\n", ##__VA_ARGS__);\
+ fprintf (stderr, "xine-plugin (%d): " x "\n", getpid(), ##__VA_ARGS__);\
fflush (stderr);\
} while (0)
#else
@@ -77,6 +76,7 @@
Display *display;
int screen;
+ Window parent;
Window window;
int x, y;
int w, h;
@@ -283,7 +283,22 @@
pthread_mutex_unlock (&this->mutex);
if (!got) {
- xine_usec_sleep (5000);
+ pthread_mutex_lock (&this->mutex);
+ if (this->window) {
+ Window tmp;
+ /* We don't receive ConfigureNotify events,
+ * so we have to query the window position periodically.
+ */
+ XLockDisplay (this->display);
+ XTranslateCoordinates (this->display, this->window,
+ DefaultRootWindow (this->display),
+ 0, 0, &this->x, &this->y, &tmp);
+ XUnlockDisplay (this->display);
+ }
+ pthread_mutex_unlock (&this->mutex);
+
+ if (this->playing)
+ xine_usec_sleep (5000);
continue;
}
@@ -417,28 +432,47 @@
case ButtonPress:{
xine_input_data_t input;
+ x11_rectangle_t rect;
+
+ rect.x = evt.xbutton.x;
+ rect.y = evt.xbutton.y;
+ rect.w = 0;
+ rect.h = 0;
+ xine_port_send_gui_data (this->vo_driver,
+ XINE_GUI_SEND_TRANSLATE_GUI_TO_VIDEO,
+ (void *) &rect);
input.event.type = XINE_EVENT_INPUT_MOUSE_BUTTON;
input.event.stream = this->stream;
input.event.data = &input;
input.event.data_length = sizeof(xine_input_data_t);
input.button = evt.xbutton.button;
- input.x = evt.xbutton.x;
- input.y = evt.xbutton.y;
+ input.x = rect.x;
+ input.y = rect.y;
gettimeofday (&input.event.tv, NULL);
xine_event_send (this->stream, &input.event);
}
break;
+
case MotionNotify:{
xine_input_data_t input;
+ x11_rectangle_t rect;
+
+ rect.x = evt.xmotion.x;
+ rect.y = evt.xmotion.y;
+ rect.w = 0;
+ rect.h = 0;
+ xine_port_send_gui_data (this->vo_driver,
+ XINE_GUI_SEND_TRANSLATE_GUI_TO_VIDEO,
+ (void *) &rect);
input.event.type = XINE_EVENT_INPUT_MOUSE_MOVE;
input.event.stream = this->stream;
input.event.data = &input;
input.event.data_length = sizeof(xine_input_data_t);
- input.x = evt.xmotion.x;
- input.y = evt.xmotion.y;
+ input.x = rect.x;
+ input.y = rect.y;
gettimeofday (&input.event.tv, NULL);
xine_event_send (this->stream, &input.event);
@@ -446,29 +480,9 @@
break;
case Expose:
- if (evt.xexpose.count != 0)
- break;
- xine_gui_send_vo_data (this->stream,
- XINE_GUI_SEND_EXPOSE_EVENT, &evt);
- break;
-
- case ConfigureNotify:{
- XConfigureEvent *cev = (XConfigureEvent *) &evt;
- Window tmp;
-
- if (cev->x == 0 && cev->y == 0) {
- pthread_mutex_lock (&this->mutex);
- XLockDisplay (cev->display);
- XTranslateCoordinates (this->display, cev->window,
- DefaultRootWindow (cev->display),
- 0, 0, &this->x, &this->y, &tmp);
- XUnlockDisplay (cev->display);
- pthread_mutex_unlock (&this->mutex);
- } else {
- this->x = cev->x;
- this->y = cev->y;
- }
- }
+ if (evt.xexpose.count == 0)
+ xine_gui_send_vo_data (this->stream,
+ XINE_GUI_SEND_EXPOSE_EVENT, &evt);
break;
default:
@@ -487,11 +501,10 @@
}
static void playback_stop (xine_plugin_t *this) {
- if (this->thread) {
+ if (this->playing) {
log ("stopping player...");
this->playing = 0;
pthread_join (this->thread, NULL);
- this->thread = 0;
log ("...player stopped.");
}
}
@@ -839,7 +852,7 @@
xine_plugin_t *this;
log ("NPP_SetWindow( instance=%p, window=%p )", instance, window);
-
+
if (!instance || !instance->pdata)
return NPERR_INVALID_INSTANCE_ERROR;
@@ -858,44 +871,44 @@
XDestroyWindow (this->display, this->window);
XUnlockDisplay (this->display);
this->window = 0;
+ this->parent = 0;
pthread_mutex_unlock (&this->mutex);
}
}
else {
- if (this->window == 0 ||
- this->w != window->width || this->h != window->height) {
- XWindowAttributes attr;
- unsigned int blackpix;
+ if (this->window == 0 || this->parent != (Window) window->window) {
+ unsigned int blackpix;
+ Window tmp;
pthread_mutex_lock (&this->mutex);
XLockDisplay (this->display);
if (this->window) {
- log ("window resized: %dx%d -> %dx%d.",
- this->w, this->h, (int) window->width, (int) window->height);
+ log ("window changed.");
XUnmapWindow (this->display, this->window);
XDestroyWindow (this->display, this->window);
}
- XGetWindowAttributes (this->display, (Window) window->window, &attr);
- this->x = attr.x;
- this->y = attr.y;
- this->w = attr.width;
- this->h = attr.height;
-
blackpix = BlackPixel (this->display, this->screen);
- this->window = XCreateSimpleWindow (this->display,
(Window)window->window,
- this->x, this->y, this->w, this->h,
0,
- blackpix, blackpix);
+ this->parent = (Window) window->window;
+ this->window = XCreateSimpleWindow (this->display, this->parent,
+ 0, 0, window->width, window->height,
+ 0, blackpix, blackpix);
XSelectInput (this->display, this->window,
- ExposureMask | KeyPressMask |
- ButtonPressMask | PointerMotionMask |
+ ExposureMask | KeyPressMask |
+ ButtonPressMask | PointerMotionMask |
StructureNotifyMask | PropertyChangeMask );
XRaiseWindow (this->display, this->window);
XMapWindow (this->display, this->window);
+
+ XTranslateCoordinates (this->display, this->window,
+ DefaultRootWindow (this->display),
+ 0, 0, &this->x, &this->y, &tmp);
+ this->w = window->width;
+ this->h = window->height;
XUnlockDisplay (this->display);
@@ -903,10 +916,26 @@
if (this->stream) {
xine_gui_send_vo_data (this->stream,
- XINE_GUI_SEND_DRAWABLE_CHANGED,
+ XINE_GUI_SEND_DRAWABLE_CHANGED,
(void *) this->window);
}
}
+ else if (this->w != window->width || this->h != window->height) {
+ log ("window resized: %dx%d -> %dx%d.",
+ this->w, this->h, (int) window->width, (int) window->height);
+
+ pthread_mutex_lock (&this->mutex);
+
+ XLockDisplay (this->display);
+ XResizeWindow (this->display, this->window,
+ window->width, window->height);
+ XUnlockDisplay (this->display);
+
+ this->w = window->width;
+ this->h = window->height;
+
+ pthread_mutex_unlock (&this->mutex);
+ }
if (this->stream)
xine_set_param (this->stream, XINE_PARAM_IGNORE_VIDEO, 0);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog