1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
7 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include <vlc_common.h>
27 #include "vout_internal.h"
31 * It should be converted to something like input_thread_t:
32 * one intf-event can be grabbed by a callback, all others
33 * variable only var_Change
35 * Maybe a intf-mouse can be used too (don't like it).
37 * (Some case may infinite loop otherwise here)
40 static inline void vout_SendEventClose(vout_thread_t
*vout
)
42 #warning FIXME: implement video close event
43 /* FIXME: this code is disabled as it breaks the non-playlist cases */
44 //playlist_Stop(pl_Get(vout));
47 static inline void vout_SendEventKey(vout_thread_t
*vout
, int key
)
49 var_SetInteger(vout
->obj
.libvlc
, "key-pressed", key
);
51 static inline void vout_SendEventMouseMoved(vout_thread_t
*vout
, int x
, int y
)
53 var_SetCoords(vout
, "mouse-moved", x
, y
);
55 static inline void vout_SendEventViewpointMoved(vout_thread_t
*vout
,
56 const vlc_viewpoint_t
*p_viewpoint
)
58 var_SetAddress(vout
, "viewpoint-moved", (void *) p_viewpoint
);
59 /* This variable can only be read from callbacks */
60 var_Change(vout
, "viewpoint-moved", VLC_VAR_SETVALUE
,
61 &(vlc_value_t
) { .p_address
= NULL
}, NULL
);
63 static inline void vout_SendEventMousePressed(vout_thread_t
*vout
, int button
)
66 var_OrInteger(vout
, "mouse-button-down", 1 << button
);
70 case MOUSE_BUTTON_LEFT
:
74 var_GetCoords(vout
, "mouse-moved", &x
, &y
);
75 var_SetCoords(vout
, "mouse-clicked", x
, y
);
76 var_SetBool(vout
->obj
.libvlc
, "intf-popupmenu", false);
79 case MOUSE_BUTTON_CENTER
:
80 var_ToggleBool(vout
->obj
.libvlc
, "intf-toggle-fscontrol");
82 case MOUSE_BUTTON_RIGHT
:
84 var_SetBool(vout
->obj
.libvlc
, "intf-popupmenu", true);
87 case MOUSE_BUTTON_WHEEL_UP
: key
= KEY_MOUSEWHEELUP
; break;
88 case MOUSE_BUTTON_WHEEL_DOWN
: key
= KEY_MOUSEWHEELDOWN
; break;
89 case MOUSE_BUTTON_WHEEL_LEFT
: key
= KEY_MOUSEWHEELLEFT
; break;
90 case MOUSE_BUTTON_WHEEL_RIGHT
: key
= KEY_MOUSEWHEELRIGHT
; break;
92 vout_SendEventKey(vout
, key
);
94 static inline void vout_SendEventMouseReleased(vout_thread_t
*vout
, int button
)
96 var_NAndInteger(vout
, "mouse-button-down", 1 << button
);
100 case MOUSE_BUTTON_RIGHT
:
101 var_SetBool(vout
->obj
.libvlc
, "intf-popupmenu", true);
106 static inline void vout_SendEventMouseDoubleClick(vout_thread_t
*vout
)
108 //vout_ControlSetFullscreen(vout, !var_GetBool(vout, "fullscreen"));
109 var_ToggleBool(vout
, "fullscreen");
111 static inline void vout_SendEventViewpointChangeable(vout_thread_t
*vout
,
114 var_SetBool(vout
, "viewpoint-changeable", b_can_change
);
118 static inline void vout_SendEventSnapshot(vout_thread_t
*vout
, const char *filename
)
120 /* signal creation of a new snapshot file */
121 var_SetString(vout
->obj
.libvlc
, "snapshot-file", filename
);
124 #warning "FIXME clean up postproc event"
126 extern void vout_InstallDeprecatedPostProcessing(vout_thread_t
*);
127 extern void vout_UninstallDeprecatedPostProcessing(vout_thread_t
*);
129 static inline void vout_SendEventPostProcessing(vout_thread_t
*vout
, bool is_available
)
132 vout_InstallDeprecatedPostProcessing(vout
);
134 vout_UninstallDeprecatedPostProcessing(vout
);
137 static inline void vout_SendEventFilters(vout_thread_t
*vout
)
139 vout_filter_t
**filter
;
142 vout_ControlGetFilters(vout
, &filter
, &filter_count
);
144 char *list
= strdup("");
145 for (int i
= 0; i
< filter_count
; i
++) {
148 if (asprintf(&psz
, "%s%s%s",
149 list
, i
> 0 ? ":" : "", filter
[i
]->name
) < 0) {
160 val
.psz_string
= list
;
161 var_Change(vout
, "video-filter", VLC_VAR_SETVALUE
, &val
, NULL
);
165 for (int i
= 0; i
< filter_count
; i
++)
166 vout_filter_Delete(filter
[i
]);