~ubuntu-branches/ubuntu/trusty/vdr-plugin-xineliboutput/trusty-proposed

« back to all changes in this revision

Viewing changes to xine_sxfe_frontend.c

  • Committer: Bazaar Package Importer
  • Author(s): Tobias Grimm
  • Date: 2010-05-02 15:19:11 UTC
  • mfrom: (1.2.1 upstream) (3.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100502151911-76o36blrqp5jjsgb
Tags: 1.0.6~cvs20100502.0851-1
* New Upstream Snapshot
* source/format 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * See the main source file 'xineliboutput.c' for copyright information and
5
5
 * how to reach the author.
6
6
 *
7
 
 * $Id: xine_sxfe_frontend.c,v 1.114 2009/08/19 16:58:58 phintuka Exp $
 
7
 * $Id: xine_sxfe_frontend.c,v 1.41.2.24 2009/10/08 12:13:11 phintuka Exp $
8
8
 *
9
9
 */
10
10
 
11
11
/*#define HAVE_XF86VIDMODE*/
12
 
#include "features.h"
13
12
 
 
13
#include <errno.h>
 
14
#include <inttypes.h>
 
15
#include <sys/types.h>
 
16
#include <sys/stat.h>
 
17
#include <dlfcn.h>
 
18
#include <stdlib.h>
 
19
#include <string.h>
 
20
#include <stdio.h>
 
21
#include <sys/types.h>
 
22
#include <unistd.h>
 
23
#include <time.h>
 
24
#include <pthread.h>
 
25
#include <sched.h>
14
26
#include <poll.h>
15
27
#include <sys/ipc.h>
16
28
#include <sys/shm.h>
21
33
#include <X11/Xatom.h>
22
34
#include <X11/keysym.h>
23
35
#include <X11/Xutil.h>
24
 
#ifdef HAVE_XSHM
25
 
# include <X11/extensions/XShm.h>
26
 
#endif
 
36
#include <X11/extensions/XShm.h>
27
37
#ifdef HAVE_XRENDER
28
38
#  include <X11/extensions/Xrender.h>
29
39
#endif
37
47
#  include <X11/extensions/Xinerama.h>
38
48
#endif
39
49
 
 
50
#ifdef boolean
 
51
#  define HAVE_BOOLEAN
 
52
#endif
 
53
#include <jpeglib.h>
 
54
#undef boolean
 
55
 
 
56
/* framegrab ports */
 
57
#define XINE_ENABLE_EXPERIMENTAL_FEATURES
 
58
 
40
59
#include <xine.h>
41
 
 
42
 
#define LOG_MODULENAME "[vdr-sxfe]  "
43
 
#include "logdefs.h"
44
 
 
 
60
#ifndef XINE_ENGINE_INTERNAL
 
61
#  define XINE_ENGINE_INTERNAL
 
62
#  include <xine/xine_internal.h>
 
63
#  undef XINE_ENGINE_INTERNAL
 
64
#else
 
65
#  include <xine/xine_internal.h>
 
66
#endif
 
67
#include <xine/xineutils.h>
 
68
#include <xine/input_plugin.h>
 
69
#include <xine/plugin_catalog.h>
 
70
 
 
71
#include "xine_input_vdr.h"
45
72
#include "xine_osd_command.h"
46
 
#include "xine_frontend_internal.h"
 
73
 
 
74
#include "xine_frontend.h"
 
75
#include "xine/post.h"
47
76
 
48
77
#ifdef HAVE_DBUS_GLIB_1
49
78
#  include "tools/gnome_screensaver.h"
88
117
  /* function pointers / base class */
89
118
  union {
90
119
    frontend_t fe;  /* generic frontend */
91
 
    fe_t       x;   /* xine frontend */
92
120
  };
93
121
 
 
122
  void   (*update_display_size_cb)(frontend_t*);
 
123
  void   (*toggle_fullscreen_cb)  (frontend_t*);
 
124
 
 
125
  /* from xine_frontend.c */
 
126
  double (*dest_pixel_aspect)   (const frontend_t *,
 
127
                                 double video_pixel_aspect,
 
128
                                 int video_width, int video_height);
 
129
  void   (*frame_output_handler)(void *data,
 
130
                                 int video_width, int video_height,
 
131
                                 double video_pixel_aspect,
 
132
                                 int *dest_x, int *dest_y,
 
133
                                 int *dest_width, int *dest_height,
 
134
                                 double *dest_pixel_aspect,
 
135
                                 int *win_x, int *win_y);
 
136
 
 
137
  /* vdr */
 
138
  fe_keypress_f        keypress;
 
139
 
94
140
  /* stored original handlers */
95
141
  int (*fe_xine_open)(frontend_t *this_gen, const char *mrl);
96
142
  int (*fe_xine_play)(frontend_t *this_gen);
147
193
  uint8_t  gui_hotkeys : 1;
148
194
  uint8_t  no_x_kbd : 1;
149
195
 
 
196
  /* xine stuff */
 
197
  xine_t              *xine;
 
198
  xine_stream_t       *stream;
 
199
  xine_stream_t       *slave_stream;
 
200
  vdr_input_plugin_if_t *input_plugin;
 
201
  xine_video_port_t   *video_port;
 
202
  xine_video_port_t   *video_port_none;
 
203
  xine_audio_port_t   *audio_port;
 
204
  xine_audio_port_t   *audio_port_none;
 
205
  xine_event_queue_t  *event_queue;
 
206
 
 
207
  post_plugins_t      *postplugins;
 
208
 
 
209
  x11_visual_t         vis;
 
210
  int                  xine_visual_type;
 
211
 
 
212
  uint16_t             pes_buffers;
 
213
 
 
214
  /* frontend */
 
215
  double    display_ratio;
 
216
  double    video_aspect;
 
217
  char     *aspect_controller;
 
218
  char     *video_port_name;
 
219
  int       xpos, ypos;
 
220
  uint16_t  video_width, video_height;
 
221
  uint16_t  width, height;
 
222
  uint8_t   aspect;
 
223
  uint8_t   cropping;
 
224
  uint8_t   scale_video;
 
225
  uint8_t   overscan;
 
226
  uint8_t   terminate_key_pressed;
 
227
  uint8_t   playback_finished;
 
228
  uint8_t   slave_playback_finished;
 
229
  uint8_t   field_order;
 
230
 
 
231
  /* strings */
 
232
  char    *configfile;
 
233
 
150
234
  /* HUD stuff */
151
235
#ifdef HAVE_XRENDER
152
236
  XImage         *hud_img;
156
240
  uint32_t       *hud_img_mem;
157
241
  GC              gc;
158
242
  Window          hud_window;
159
 
# ifdef HAVE_XSHM
160
243
  XShmSegmentInfo hud_shminfo;
161
 
# endif
162
244
 
163
245
  uint16_t      osd_width;
164
246
  uint16_t      osd_height;
165
247
#endif /* HAVE_XRENDER */
166
248
 
167
 
} sxfe_t;
168
 
 
 
249
} fe_t, sxfe_t;
 
250
 
 
251
 
 
252
/* Common (non-X11/FB) frontend functions */
 
253
#include "xine_frontend.c"
169
254
 
170
255
#define DOUBLECLICK_TIME   500  // ms
171
256
 
186
271
  *dest_width  = this->width;
187
272
  *dest_height = this->height;
188
273
 
189
 
  *dest_pixel_aspect = this->dest_pixel_aspect(this, video_pixel_aspect,
 
274
  *dest_pixel_aspect = this->dest_pixel_aspect((frontend_t*)this, video_pixel_aspect,
190
275
                                               video_width, video_height);
191
276
}
192
277
 
215
300
  hint.flags  = USSize | USPosition | PPosition | PSize;
216
301
  hint.x      = this->xinerama_x;
217
302
  hint.y      = this->xinerama_y;
218
 
  hint.width  = this->x.width;
219
 
  hint.height = this->x.height;
 
303
  hint.width  = this->width;
 
304
  hint.height = this->height;
220
305
  XLockDisplay(this->display);
221
306
  XSetNormalHints(this->display, this->window[1], &hint);
222
307
  XUnlockDisplay(this->display);
265
350
  ev.xclient.window       = this->window[1];
266
351
  ev.xclient.format       = 32;
267
352
  ev.xclient.data.l[0]    = 1;
268
 
  /*ev.xclient.data.l[0]    = this->atom_state_add;*/
269
353
 
270
354
  /* _NET_WM_STATE_FULLSCREEN */
271
355
  XLockDisplay(this->display);
302
386
{
303
387
  XLockDisplay(this->display);
304
388
 
305
 
  if (!this->x.keypress) { /* handler is set only in local mode */
 
389
  if (!this->keypress) { /* handler is set only in local mode */
306
390
    char *name = NULL;
307
391
    if (XFetchName(this->display, this->window[0], &name) && name) {
308
392
      char *newname = NULL;
323
407
    XStoreName(this->display, this->window[0], this->stay_above ? "Local VDR (top)" : "Local VDR");
324
408
    XStoreName(this->display, this->window[1], this->stay_above ? "Local VDR (top)" : "Local VDR");
325
409
  }
 
410
 
326
411
  XUnlockDisplay(this->display);
327
412
}
328
413
 
347
432
  ev.xclient.display      = this->display;
348
433
  ev.xclient.window       = this->window[0];
349
434
  ev.xclient.format       = 32;
350
 
  ev.xclient.data.l[0]    = stay_above ? 1:0; /*this->atom_state_add : this->atom_state_del;*/
 
435
  ev.xclient.data.l[0]    = stay_above ? 1:0;
351
436
 
352
437
  /* _NET_WM_STATE_ABOVE */
353
438
  XLockDisplay(this->display);
477
562
      screen = 0;
478
563
    this->xinerama_x = screens[screen].x_org;
479
564
    this->xinerama_y = screens[screen].y_org;
480
 
    this->x.width    = screens[screen].width;
481
 
    this->x.height   = screens[screen].height;
 
565
    this->width      = screens[screen].width;
 
566
    this->height     = screens[screen].height;
482
567
 
483
568
    XFree(screens);
484
569
  }
493
578
 */
494
579
static void update_screen_size(sxfe_t *this)
495
580
{
496
 
  this->x.width = DisplayWidth(this->display, this->screen);
497
 
  this->x.height = DisplayHeight(this->display, this->screen);
 
581
  this->width = DisplayWidth(this->display, this->screen);
 
582
  this->height = DisplayHeight(this->display, this->screen);
498
583
  update_xinerama_info(this);
499
584
}
500
585
 
542
627
  xf.matrix[2][0] = 0; xf.matrix[2][1] = 0; xf.matrix[2][2] = XDoubleToFixed(1.0);
543
628
  XRenderSetPictureFilter(dpy, src->pic, smooth ? "bilinear" : "nearest", NULL, 0);
544
629
  XRenderSetPictureTransform(dpy, src->pic, &xf);
545
 
  x = (int)ceil((double)(x>0?x-1:0) * scale_x);
546
 
  y = (int)ceil((double)(y>0?y-1:0) * scale_y);
 
630
  x = (int)ceil((double)(x?x-1:0) * scale_x);
 
631
  y = (int)ceil((double)(y?y-1:0) * scale_y);
547
632
  w = (int)floor((double)(w+2) * scale_x);
548
633
  h = (int)floor((double)(h+2) * scale_y);
549
634
  XRenderComposite(dpy, PictOpSrc, src->pic, None, dst->pic, x, y, 0, 0, x, y, w, h);
667
752
      LOGDBG("HUD Set RLE");
668
753
      if (!(cmd->flags & OSDFLAG_TOP_LAYER))
669
754
        break;
670
 
#ifdef HAVE_XSHM
671
755
      if(this->completion_event != -1) {
672
756
        hud_fill_img_memory((uint32_t*)(this->hud_img->data), cmd);
673
757
        if(!cmd->scaling) {
690
774
                             cmd->x + cmd->dirty_area.x1, cmd->y + cmd->dirty_area.y1,
691
775
                             cmd->dirty_area.x2 - cmd->dirty_area.x1 + 1,
692
776
                             cmd->dirty_area.y2 - cmd->dirty_area.y1 + 1,
693
 
                             (XDouble)this->x.width / (XDouble)this->osd_width,
694
 
                             (XDouble)this->x.height / (XDouble)this->osd_height,
 
777
                             (XDouble)this->width / (XDouble)this->osd_width,
 
778
                             (XDouble)this->height / (XDouble)this->osd_height,
695
779
                             (cmd->scaling & 2)); // Note: HUD_SCALING_BILINEAR=2
696
780
        }
697
781
      }
698
782
      else
699
 
#endif
700
783
      {
701
784
        hud_fill_img_memory(this->hud_img_mem, cmd);
702
785
        if(!cmd->scaling) {
717
800
                             cmd->x + cmd->dirty_area.x1, cmd->y + cmd->dirty_area.y1,
718
801
                             cmd->dirty_area.x2 - cmd->dirty_area.x1 + 1,
719
802
                             cmd->dirty_area.y2 - cmd->dirty_area.y1 + 1,
720
 
                             (XDouble)this->x.width / (XDouble)this->osd_width,
721
 
                             (XDouble)this->x.height / (XDouble)this->osd_height,
 
803
                             (XDouble)this->width / (XDouble)this->osd_width,
 
804
                             (XDouble)this->height / (XDouble)this->osd_height,
722
805
                             (cmd->scaling & 2)); // Note: HUD_SCALING_BILINEAR=2
723
806
        }
724
807
      }
742
825
        break;
743
826
      XSetForeground(this->display, this->gc, 0x00000000);
744
827
      XFillRectangle(this->display, this->hud_window, this->gc,
745
 
                     0, 0, this->x.width, this->x.height);
 
828
                     0, 0, this->width, this->height);
746
829
      XFillRectangle(this->display, this->surf_img->draw, this->gc,
747
830
                     0, 0, this->osd_width+2, this->osd_height+2);
748
831
      XFlush(this->display);
794
877
    attributes.backing_store = Always;
795
878
 
796
879
    this->hud_window = XCreateWindow(this->display, DefaultRootWindow(this->display),
797
 
                                     this->x.xpos, this->x.ypos,
798
 
                                     this->x.width, this->x.height,
 
880
                                     this->xpos, this->ypos,
 
881
                                     this->width, this->height,
799
882
                                     0, 32, InputOutput, this->hud_vis,
800
883
                                     CWBackPixel | CWBorderPixel |
801
884
                                     CWOverrideRedirect | CWColormap,
811
894
    XStoreName(this->display, this->hud_window, "HUD");
812
895
    this->gc = XCreateGC(this->display, this->hud_window, 0, NULL);
813
896
 
814
 
#ifdef HAVE_XSHM
815
897
    if(this->completion_event != -1) {
816
898
      this->hud_img = XShmCreateImage(this->display, this->hud_vis, 32, ZPixmap, NULL, &(this->hud_shminfo),
817
899
                                      HUD_MAX_WIDTH, HUD_MAX_HEIGHT);
823
905
      this->hud_shminfo.readOnly = True;
824
906
 
825
907
      XShmAttach(this->display, &(this->hud_shminfo));
826
 
    }
827
 
    else
828
 
#endif
829
 
    {
 
908
    } else {
830
909
      /* Fall-back to traditional memory */
831
910
      LOGMSG("hud_osd_open: XShm not available, falling back to normal (slow) memory");
832
911
      this->hud_img_mem = malloc(4 * HUD_MAX_WIDTH * HUD_MAX_HEIGHT);
903
982
    XLockDisplay(this->display);
904
983
    LOGDBG("closing hud window...");
905
984
 
906
 
#ifdef HAVE_XSHM
907
985
    if(this->completion_event != -1) {
908
986
      XShmDetach(this->display, &(this->hud_shminfo));
909
987
      XDestroyImage(this->hud_img);
911
989
      shmctl(this->hud_shminfo.shmid, IPC_RMID, 0);
912
990
    }
913
991
    else
914
 
#endif
915
992
      XDestroyImage(this->hud_img);
916
993
 
917
994
    if(this->surf_img)
1020
1097
  XUnlockDisplay(this->display);
1021
1098
}
1022
1099
 
1023
 
/* 
 
1100
/*
1024
1101
 * detect_display_ratio
1025
1102
 *
1026
1103
 * Calculate display aspect ratio
1062
1139
  /* create and display our video window */
1063
1140
  this->window[0] = XCreateSimpleWindow (this->display,
1064
1141
                                         DefaultRootWindow(this->display),
1065
 
                                         this->x.xpos, this->x.ypos,
1066
 
                                         this->x.width, this->x.height,
 
1142
                                         this->xpos, this->ypos,
 
1143
                                         this->width, this->height,
1067
1144
                                         1, 0, 0);
1068
1145
  this->window[1] = XCreateSimpleWindow(this->display, XDefaultRootWindow(this->display),
1069
1146
                                        this->xinerama_x, this->xinerama_y,
1070
 
                                        this->x.width, this->x.height,
 
1147
                                        this->width, this->height,
1071
1148
                                        0, 0, 0);
1072
1149
 
1073
1150
  /* full-screen window */
1084
1161
  }
1085
1162
 
1086
1163
  /* Window name */
1087
 
  const char *initial_title = (!this->x.keypress) ? "Connecting to VDR ..." : "Local VDR";
 
1164
  const char *initial_title = (!this->keypress) ? "Connecting to VDR ..." : "Local VDR";
1088
1165
  XStoreName(this->display, this->window[0], initial_title);
1089
1166
  XStoreName(this->display, this->window[1], initial_title);
1090
1167
 
1112
1189
    this->fe.fe_display_close(this_gen);
1113
1190
 
1114
1191
  if(keyfunc) {
1115
 
    this->x.keypress = keyfunc;
1116
 
    this->x.keypress("XKeySym", ""); /* triggers learning mode */
 
1192
    this->keypress = keyfunc;
 
1193
    this->keypress("XKeySym", ""); /* triggers learning mode */
1117
1194
  }
1118
1195
 
1119
1196
  LOGDBG("sxfe_display_open(width=%d, height=%d, fullscreen=%d, display=%s)",
1130
1207
#endif
1131
1208
  }
1132
1209
 
1133
 
  this->x.xpos        = xpos;
1134
 
  this->x.ypos        = ypos;
1135
 
  this->x.width       = width;
1136
 
  this->x.height      = height;
1137
 
  this->x.aspect      = aspect;
1138
 
/*this->x.cropping    = 0;*/
1139
 
  this->x.overscan    = 0;
1140
 
  this->x.scale_video = scale_video;
1141
 
  this->x.field_order = field_order ? 1 : 0;
1142
 
  this->x.aspect_controller = aspect_controller ? strdup(aspect_controller) : NULL;
 
1210
  this->xpos            = xpos;
 
1211
  this->ypos            = ypos;
 
1212
  this->width           = width;
 
1213
  this->height          = height;
 
1214
  this->aspect          = aspect;
 
1215
  this->cropping        = 0;
 
1216
  this->overscan        = 0;
 
1217
  this->scale_video     = scale_video;
 
1218
  this->field_order     = field_order ? 1 : 0;
 
1219
  this->aspect_controller = aspect_controller ? strdup(aspect_controller) : NULL;
1143
1220
 
1144
 
  this->origxpos      = 0;
1145
 
  this->origypos      = 0;
 
1221
  this->origxpos      = xpos;
 
1222
  this->origypos      = ypos;
1146
1223
  this->origwidth     = width>0 ? width : OSD_DEF_WIDTH;
1147
1224
  this->origheight    = height>0 ? height : OSD_DEF_HEIGHT;
1148
1225
 
1154
1231
  this->fullscreen      = fullscreen;
1155
1232
/*this->vmode_switch    = modeswitch;*/
1156
1233
  this->fullscreen_state_forced = 0;
1157
 
/*this->modeline = strdup(modeline ?: "");*/
 
1234
/*strn0cpy(this->modeline, modeline ? : "", sizeof(this->modeline));*/
1158
1235
  this->window_id = window_id;
1159
1236
 
1160
1237
  this->xinerama_screen = -1;
1183
1260
 
1184
1261
  /* completion event */
1185
1262
  this->completion_event = -1;
1186
 
#ifdef HAVE_XSHM
1187
1263
  if (XShmQueryExtension (this->display) == True) {
1188
1264
    this->completion_event = XShmGetEventBase (this->display) + ShmCompletion;
1189
1265
  }
1190
 
#endif
1191
1266
 
1192
1267
  init_atoms(this);
1193
1268
 
1196
1271
 
1197
1272
  /* Output to existing window ? (embedded to another app) */
1198
1273
  if(this->window_id > 0) {
1199
 
    LOGMSG("sxfe_display_open(): Using X11 window %d for output", this->window_id);
 
1274
    LOGMSG("sxfe_diaplay_open(): Using X11 window %d for output", this->window_id);
1200
1275
    this->window[0] = this->window[1] = (Window)this->window_id;
1201
1276
    XUnmapWindow(this->display, this->window[0]);
1202
1277
  } else {
1219
1294
 
1220
1295
  /* Map current window */
1221
1296
  XMapRaised (this->display, this->window[this->fullscreen ? 1 : 0]);
1222
 
  XMoveWindow(this->display, this->window[0], this->x.xpos, this->x.ypos);
 
1297
  XMoveWindow(this->display, this->window[0], this->xpos, this->ypos);
1223
1298
 
1224
1299
  /* determine display aspect ratio */
1225
 
  this->x.display_ratio = detect_display_ratio(this->display, this->screen);
 
1300
  this->display_ratio = detect_display_ratio(this->display, this->screen);
1226
1301
 
1227
1302
  /* we want to get notified if user closes the window */
1228
1303
  XSetWMProtocols(this->display, this->window[this->fullscreen ? 1 : 0], &(this->xa_WM_DELETE_WINDOW), 1);
1243
1318
  gnome_screensaver_control(0);
1244
1319
#endif
1245
1320
 
1246
 
  /* setup xine visual type */
1247
 
  this->x.xine_visual_type         = XINE_VISUAL_TYPE_X11;
1248
 
  this->x.vis_x11.display          = this->display;
1249
 
  this->x.vis_x11.screen           = this->screen;
1250
 
  this->x.vis_x11.d                = this->window[this->fullscreen ? 1 : 0];
1251
 
  this->x.vis_x11.dest_size_cb     = sxfe_dest_size_cb;
1252
 
  this->x.vis_x11.frame_output_cb  = this->x.frame_output_handler;
1253
 
  this->x.vis_x11.user_data        = this;
 
1321
  this->xine_visual_type     = XINE_VISUAL_TYPE_X11;
 
1322
  this->vis.display          = this->display;
 
1323
  this->vis.screen           = this->screen;
 
1324
  this->vis.d                = this->window[this->fullscreen ? 1 : 0];
 
1325
  this->vis.dest_size_cb     = sxfe_dest_size_cb;
 
1326
  this->vis.frame_output_cb  = fe_frame_output_cb;
 
1327
  this->vis.user_data        = this;
1254
1328
 
1255
1329
  set_fullscreen_props(this);
1256
1330
 
1279
1353
  if(this->fullscreen_state_forced)
1280
1354
    fullscreen = this->fullscreen ? 1 : 0;
1281
1355
 
1282
 
  if(!fullscreen && (this->x.width != width || this->x.height != height)) {
1283
 
    this->x.width      = width;
1284
 
    this->x.height     = height;
 
1356
  if (xpos < 0) xpos = this->xpos;
 
1357
  if (ypos < 0) ypos = this->ypos;
 
1358
 
 
1359
  if ( !fullscreen &&
 
1360
       ( this->width != width || this->height != height ||
 
1361
         this->xpos  != xpos  || this->ypos   != ypos)) {
 
1362
    this->xpos       = xpos;
 
1363
    this->ypos       = ypos;
 
1364
    this->width      = width;
 
1365
    this->height     = height;
1285
1366
 
1286
1367
    XLockDisplay(this->display);
1287
 
    XResizeWindow(this->display, this->window[0], this->x.width, this->x.height);
 
1368
    XResizeWindow(this->display, this->window[0], this->width, this->height);
 
1369
    XMoveWindow(this->display, this->window[0], this->xpos, this->ypos);
1288
1370
    XUnlockDisplay(this->display);
1289
1371
    if(!fullscreen && !this->fullscreen)
1290
 
      xine_port_send_gui_data(this->x.video_port, XINE_GUI_SEND_DRAWABLE_CHANGED,
 
1372
      xine_port_send_gui_data(this->video_port, XINE_GUI_SEND_DRAWABLE_CHANGED,
1291
1373
                              (void*) this->window[0]);
1292
1374
  }
1293
1375
 
1306
1388
      set_above(this, this->stay_above);
1307
1389
    XMapRaised(this->display, this->window[this->fullscreen ? 1 : 0]);
1308
1390
    if(!fullscreen) {
1309
 
      XResizeWindow(this->display, this->window[0], this->x.width, this->x.height);
1310
 
      XMoveWindow(this->display, this->window[0], this->x.xpos, this->x.ypos);
 
1391
      XResizeWindow(this->display, this->window[0], this->width, this->height);
 
1392
      XMoveWindow(this->display, this->window[0], this->xpos, this->ypos);
1311
1393
      LOGDBG("sxfe_display_config: XMoveWindow called with x=%d and y=%d",
1312
 
             this->x.xpos, this->x.ypos);
 
1394
             this->xpos, this->ypos);
1313
1395
      this->check_move = 1;
1314
1396
      set_above(this, this->stay_above);
1315
1397
    } else {
1316
1398
      set_fullscreen_props(this);
1317
 
      XResizeWindow(this->display, this->window[1], this->x.width, this->x.height);
 
1399
      XResizeWindow(this->display, this->window[1], this->width, this->height);
1318
1400
      XMoveWindow(this->display, this->window[1], this->xinerama_x, this->xinerama_y);
1319
1401
    }
1320
1402
    XSync(this->display, False);
1321
1403
    if(XTranslateCoordinates(this->display, this->window[this->fullscreen ? 1 : 0],
1322
1404
                             DefaultRootWindow(this->display),
1323
1405
                             0, 0, &tmp_x, &tmp_y, &tmp_win)) {
1324
 
      this->x.xpos = tmp_x;
1325
 
      this->x.ypos = tmp_y;
 
1406
      this->xpos = tmp_x;
 
1407
      this->ypos = tmp_y;
1326
1408
    }
1327
1409
    XUnlockDisplay(this->display);
1328
 
    xine_port_send_gui_data(this->x.video_port, XINE_GUI_SEND_DRAWABLE_CHANGED,
 
1410
    xine_port_send_gui_data(this->video_port, XINE_GUI_SEND_DRAWABLE_CHANGED,
1329
1411
                            (void*) this->window[this->fullscreen ? 1 : 0]);
1330
1412
  }
1331
1413
 
1332
1414
#if 0
1333
1415
  if(!modeswitch && strcmp(modeline, this->modeline)) {
1334
 
    free(this->modeline);
1335
 
    this->modeline = strdup(modeline ?: "");
 
1416
    strn0cpy(this->modeline, modeline, sizeof(this->modeline));
1336
1417
    /* #warning TODO - switch vmode */
1337
1418
  }
1338
1419
#endif
1339
1420
 
1340
1421
/*this->vmode_switch = modeswitch;*/
1341
 
  this->x.aspect = aspect;
1342
 
  this->x.scale_video = scale_video;
1343
 
  this->x.field_order = field_order ? 1 : 0;
 
1422
  this->aspect = aspect;
 
1423
  this->scale_video = scale_video;
 
1424
  this->field_order = field_order ? 1 : 0;
1344
1425
 
1345
1426
  return 1;
1346
1427
}
1347
1428
 
1348
 
static void sxfe_toggle_fullscreen(fe_t *this_gen)
 
1429
static void sxfe_toggle_fullscreen(frontend_t *this_gen)
1349
1430
{
1350
1431
  sxfe_t *this = (sxfe_t*)this_gen;
1351
1432
 
1353
1434
  this->fullscreen_state_forced = 0;
1354
1435
 
1355
1436
  if(!this->fullscreen) {
1356
 
    this->origwidth  = this->x.width;
1357
 
    this->origheight = this->x.height;
1358
 
    this->origxpos = this->x.xpos;
1359
 
    this->origypos = this->x.ypos;
 
1437
    this->origwidth  = this->width;
 
1438
    this->origheight = this->height;
 
1439
    this->origxpos = this->xpos;
 
1440
    this->origypos = this->ypos;
1360
1441
  } else {
1361
 
    this->x.xpos = this->origxpos;
1362
 
    this->x.ypos = this->origypos;
 
1442
    this->xpos = this->origxpos;
 
1443
    this->ypos = this->origypos;
1363
1444
  }
1364
1445
 
1365
1446
  this->fe.fe_display_config((frontend_t*)this, -1, -1, this->origwidth, this->origheight,
1366
1447
                             this->fullscreen ? 0 : 1,
1367
1448
                             0/*this->vmode_switch*/, NULL/*this->modeline*/,
1368
 
                             this->x.aspect, this->x.scale_video, this->x.field_order);
 
1449
                             this->aspect, this->scale_video, this->field_order);
1369
1450
 
1370
1451
  this->fullscreen_state_forced = !force;
1371
1452
}
1427
1508
          fe_event = "TOGGLE_DEINTERLACE";
1428
1509
        break;
1429
1510
      case XK_Escape:
1430
 
        if (!this->x.keypress) /* ESC exits only in remote mode */
 
1511
        if (!this->keypress) { /* ESC exits only in remote mode */
1431
1512
          fe_event = "QUIT";
 
1513
        }
1432
1514
        break;
1433
1515
      default:;
1434
1516
    }
1435
1517
    if (fe_event)
1436
 
      this->x.fe.send_event((frontend_t*)this, fe_event);
 
1518
      this->fe.send_event((frontend_t*)this, fe_event);
1437
1519
    else if (!this->no_x_kbd)
1438
 
      this->x.fe.send_input_event((frontend_t*)this, "XKeySym", XKeysymToString(ks), 0, 0);
 
1520
      this->fe.send_input_event((frontend_t*)this, "XKeySym", XKeysymToString(ks), 0, 0);
1439
1521
  }
1440
1522
}
1441
1523
 
1451
1533
    hud_osd_resize(this, cev->window, cev->width, cev->height);
1452
1534
#endif
1453
1535
 
1454
 
  if (this->x.width != cev->width || this->x.height != cev->height) {
 
1536
  /* update video window size */
 
1537
  if (this->width != cev->width || this->height != cev->height) {
 
1538
    this->width  = cev->width;
 
1539
    this->height = cev->height;
 
1540
 
 
1541
    /* inform VDR about new size */
1455
1542
    char str[128];
1456
 
    snprintf(str, sizeof(str), "INFO WINDOW %dx%d", this->x.width, this->x.height);
1457
 
    this->x.fe.send_event((frontend_t*)this, str);
 
1543
    snprintf(str, sizeof(str), "INFO WINDOW %dx%d", this->width, this->height);
 
1544
    this->fe.send_event((frontend_t*)this, str);
1458
1545
  }
1459
1546
 
1460
 
  /* update video window size */
1461
 
  this->x.width  = cev->width;
1462
 
  this->x.height = cev->height;
1463
 
 
1464
1547
  if(this->window[0] == cev->window && this->check_move) {
1465
1548
    LOGDBG("ConfigureNotify reveived with x=%d, y=%d, check_move=%d",
1466
1549
           cev->x, cev->y, this->check_move);
1467
1550
    this->check_move = 0;
1468
 
    if(this->x.xpos != cev->x && this->x.ypos != cev->y) {
 
1551
    if(this->xpos != cev->x && this->ypos != cev->y) {
1469
1552
      XLockDisplay (this->display);
1470
1553
      XMoveWindow(this->display, this->window[0], cev->x, cev->y);
1471
1554
      XUnlockDisplay (this->display);
1480
1563
      if(XTranslateCoordinates(this->display, cev->window,
1481
1564
                               DefaultRootWindow(this->display),
1482
1565
                               0, 0, &tmp_x, &tmp_y, &tmp_win)) {
1483
 
        this->x.xpos = tmp_x;
1484
 
        this->x.ypos = tmp_y;
 
1566
        this->xpos = tmp_x;
 
1567
        this->ypos = tmp_y;
1485
1568
      }
1486
1569
      XUnlockDisplay(this->display);
1487
1570
    }
1488
1571
  } else {
1489
1572
    if(!this->fullscreen) {
1490
1573
      /* update video window position */
1491
 
      this->x.xpos = cev->x;
1492
 
      this->x.ypos = cev->y;
 
1574
      this->xpos = cev->x;
 
1575
      this->ypos = cev->y;
1493
1576
    }
1494
1577
  }
1495
1578
}
1515
1598
                          DefaultRootWindow(this->display),
1516
1599
                          0, 0, &xpos, &ypos, &tmp_win);
1517
1600
 
1518
 
    this->x.xpos = (xpos += mev->x_root - this->dragging_x);
1519
 
    this->x.ypos = (ypos += mev->y_root - this->dragging_y);
 
1601
    this->xpos = (xpos += mev->x_root - this->dragging_x);
 
1602
    this->ypos = (ypos += mev->y_root - this->dragging_y);
1520
1603
    this->dragging_x = mev->x_root;
1521
1604
    this->dragging_y = mev->y_root;
1522
1605
 
1542
1625
      /* Double-click toggles between fullscreen and windowed mode */
1543
1626
      if(bev->time - this->prev_click_time < DOUBLECLICK_TIME) {
1544
1627
        /* Toggle fullscreen */
1545
 
        sxfe_toggle_fullscreen((fe_t*)this);
 
1628
        this->toggle_fullscreen_cb((frontend_t*)this);
1546
1629
        this->prev_click_time = 0; /* don't react to third click ... */
1547
1630
      } else {
1548
1631
        this->prev_click_time = bev->time;
1608
1691
    switch (event.type) {
1609
1692
      case Expose:
1610
1693
        if (event.xexpose.count == 0)
1611
 
          xine_port_send_gui_data (this->x.video_port, XINE_GUI_SEND_EXPOSE_EVENT, &event);
 
1694
          xine_port_send_gui_data (this->video_port, XINE_GUI_SEND_EXPOSE_EVENT, &event);
1612
1695
        break;
1613
1696
 
1614
1697
      case ConfigureNotify:
1649
1732
          /* we got a window deletion message from out window manager.*/
1650
1733
          LOGDBG("ClientMessage: WM_DELETE_WINDOW");
1651
1734
 
1652
 
          this->x.fe.send_event((frontend_t*)this, "QUIT");
 
1735
          this->fe.send_event((frontend_t*)this, "QUIT");
1653
1736
        }
1654
1737
        break;
1655
1738
      }
1656
1739
    }
1657
1740
 
1658
1741
    if (event.type == this->completion_event)
1659
 
      xine_port_send_gui_data (this->x.video_port, XINE_GUI_SEND_COMPLETION_EVENT, &event);
 
1742
      xine_port_send_gui_data (this->video_port, XINE_GUI_SEND_COMPLETION_EVENT, &event);
1660
1743
  }
1661
1744
 
1662
 
  return !this->x.fe.xine_is_finished((frontend_t*)this, 0);
 
1745
  return !this->fe.xine_is_finished((frontend_t*)this, 0);
1663
1746
}
1664
1747
 
1665
1748
static void sxfe_display_close(frontend_t *this_gen)
1669
1752
  if(!this)
1670
1753
    return;
1671
1754
 
1672
 
  if(this->x.xine)
 
1755
  if(this->xine)
1673
1756
    this->fe.xine_exit(this_gen);
1674
1757
 
1675
1758
  if(this->display) {
1698
1781
    this->display = NULL;
1699
1782
  }
1700
1783
 
1701
 
  free(this->x.aspect_controller);
1702
 
  this->x.aspect_controller = NULL;
 
1784
  free(this->aspect_controller);
 
1785
  this->aspect_controller = NULL;
1703
1786
#if 0
1704
1787
  free(this->modeline);
1705
1788
  this->modeline = NULL;
1740
1823
  int result = this->fe_xine_play(this_gen);
1741
1824
 
1742
1825
#ifdef HAVE_XRENDER
1743
 
  if (result && this->x.input_plugin && this->hud) {
 
1826
  if (result && this->input_plugin && this->hud) {
1744
1827
    LOGDBG("sxfe_xine_play: Enabling HUD OSD");
1745
 
    this->x.input_plugin->f.fe_handle     = this_gen;
1746
 
    this->x.input_plugin->f.intercept_osd = hud_osd_command;
 
1828
    this->input_plugin->f.fe_handle     = this_gen;
 
1829
    this->input_plugin->f.intercept_osd = hud_osd_command;
1747
1830
  }
1748
1831
#endif /* HAVE_XRENDER */
1749
1832
 
1765
1848
  this->fe.fe_run       = sxfe_run;
1766
1849
  this->fe.fe_interrupt = sxfe_interrupt;
1767
1850
 
1768
 
  this->x.toggle_fullscreen_cb = sxfe_toggle_fullscreen;
 
1851
  this->toggle_fullscreen_cb = sxfe_toggle_fullscreen;
1769
1852
 
1770
1853
  /* override */
1771
1854