Merge remote-tracking branch 'wm4/window_title'

This commit is contained in:
Uoti Urpala
2011-12-07 00:13:51 +02:00
15 changed files with 107 additions and 62 deletions
+2 -3
View File
@@ -321,9 +321,8 @@ int mpcodecs_config_vo2(sh_video_t *sh, int w, int h,
// Time to config libvo!
mp_msg(MSGT_CPLAYER, MSGL_V,
"VO Config (%dx%d->%dx%d,flags=%d,'%s',0x%X)\n", sh->disp_w,
sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, "MPlayer",
out_fmt);
"VO Config (%dx%d->%dx%d,flags=%d,0x%X)\n", sh->disp_w,
sh->disp_h, screen_size_x, screen_size_y, vocfg_flags, out_fmt);
vf->w = sh->disp_w;
vf->h = sh->disp_h;
+1 -1
View File
@@ -79,7 +79,7 @@ static int config(struct vf_instance *vf,
vf->default_caps=query_format(vf,outfmt);
vf->draw_slice = (vf->default_caps & VOCAP_NOSLICES) ? NULL : draw_slice;
if (vo_config(video_out, width, height, d_width, d_height, flags, "MPlayer", outfmt))
if (vo_config(video_out, width, height, d_width, d_height, flags, outfmt))
return 0;
#ifdef CONFIG_ASS
+1 -2
View File
@@ -10,8 +10,7 @@ void vo_cocoa_update_xinerama_info(struct vo *vo);
int vo_cocoa_change_attributes(struct MPGLContext *ctx);
int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags,
const char *title);
uint32_t d_height, uint32_t flags);
void vo_cocoa_swap_buffers(void);
int vo_cocoa_check_events(struct vo *vo);
+2 -16
View File
@@ -64,7 +64,6 @@ struct vo *l_vo;
// local function definitions
struct vo_cocoa_state *vo_cocoa_init_state(void);
void update_screen_info(void);
const char *title_from_vo_and_title(struct vo *vo, const char *title);
void resize_window(struct vo *vo);
void create_menu(void);
@@ -136,19 +135,6 @@ int vo_cocoa_change_attributes(struct MPGLContext *ctx)
return SET_WINDOW_OK;
}
// this function exists because vf_vo.c calls config with title = "MPlayer"
// and from the vo it will come down to the backend (ignoring --use-filename-title)
const char *title_from_vo_and_title(struct vo *vo, const char *title)
{
if (vo->opts->vo_wintitle) {
return vo->opts->vo_wintitle;
} else if (title) {
return title;
} else {
return "mplayer2";
}
}
void resize_window(struct vo *vo)
{
vo->dwidth = [[s->window contentView] frame].size.width;
@@ -157,7 +143,7 @@ void resize_window(struct vo *vo)
}
int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags, const char *title)
uint32_t d_height, uint32_t flags)
{
if (s->current_video_size.width > 0 || s->current_video_size.height > 0)
s->previous_video_size = s->current_video_size;
@@ -222,7 +208,7 @@ int vo_cocoa_create_window(struct MPGLContext *ctx, uint32_t d_width,
if (s->window_title)
[s->window_title release];
s->window_title = [[NSString alloc] initWithUTF8String:title_from_vo_and_title(ctx->vo,title)];
s->window_title = [[NSString alloc] initWithUTF8String:vo_get_window_title(ctx->vo)];
[s->window setTitle: s->window_title];
return SET_WINDOW_OK;
+7 -11
View File
@@ -1613,10 +1613,9 @@ void glDrawTex(GL *gl, GLfloat x, GLfloat y, GLfloat w, GLfloat h,
#ifdef CONFIG_GL_COCOA
#include "cocoa_common.h"
static int create_window_cocoa(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags,
const char *title)
uint32_t d_height, uint32_t flags)
{
return vo_cocoa_create_window(ctx, d_width, d_height, flags, title);
return vo_cocoa_create_window(ctx, d_width, d_height, flags);
}
static int setGlWindow_cocoa(MPGLContext *ctx)
{
@@ -1654,8 +1653,7 @@ static void cocoa_fullscreen(struct vo *vo)
#include "w32_common.h"
static int create_window_w32(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags,
const char *title)
uint32_t d_height, uint32_t flags)
{
if (!vo_w32_config(d_width, d_height, flags))
return -1;
@@ -1771,8 +1769,7 @@ static void new_w32_update_xinerama_info(struct vo *vo) { w32_update_xinerama_in
#include "x11_common.h"
static int create_window_x11(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags,
const char *title)
uint32_t d_height, uint32_t flags)
{
struct vo *vo = ctx->vo;
@@ -1805,7 +1802,7 @@ static int create_window_x11(struct MPGLContext *ctx, uint32_t d_width,
Colormap colormap = XCreateColormap(vo->x11->display, vo->x11->rootwin,
vinfo->visual, AllocNone);
vo_x11_create_vo_window(vo, vinfo, vo->dx, vo->dy, d_width, d_height,
flags, colormap, "gl", title);
flags, colormap, "gl");
return 0;
}
@@ -1968,10 +1965,9 @@ static void swapGlBuffers_x11(MPGLContext *ctx)
#include "sdl_common.h"
static int create_window_sdl(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags,
const char *title)
uint32_t d_height, uint32_t flags)
{
SDL_WM_SetCaption(title, NULL);
SDL_WM_SetCaption(vo_get_window_title(ctx->vo), NULL);
ctx->vo->dwidth = d_width;
ctx->vo->dheight = d_height;
return 0;
+1 -1
View File
@@ -387,7 +387,7 @@ typedef struct MPGLContext {
#endif
} context;
int (*create_window)(struct MPGLContext *ctx, uint32_t d_width,
uint32_t d_height, uint32_t flags, const char *title);
uint32_t d_height, uint32_t flags);
int (*setGlWindow)(struct MPGLContext *);
void (*releaseGlContext)(struct MPGLContext *);
void (*swapGlBuffers)(struct MPGLContext *);
+3 -2
View File
@@ -34,10 +34,11 @@ int old_vo_preinit(struct vo *vo, const char *arg)
int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height,
uint32_t flags, char *title, uint32_t format)
uint32_t flags, uint32_t format)
{
return vo->driver->old_functions->config(width, height, d_width,
d_height, flags, title, format);
d_height, flags, "MPlayer",
format);
}
+1 -1
View File
@@ -10,7 +10,7 @@ extern struct osd_state *global_osd;
int old_vo_preinit(struct vo *vo, const char *);
int old_vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height,
uint32_t flags, char *title, uint32_t format);
uint32_t flags, uint32_t format);
int old_vo_control(struct vo *vo, uint32_t request, void *data);
int old_vo_draw_frame(struct vo *vo, uint8_t *src[]);
int old_vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[],
+14 -2
View File
@@ -470,7 +470,7 @@ static int event_fd_callback(void *ctx, int fd)
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format)
uint32_t format)
{
struct MPOpts *opts = vo->opts;
panscan_init(vo);
@@ -491,7 +491,7 @@ int vo_config(struct vo *vo, uint32_t width, uint32_t height,
}
int ret = vo->driver->config(vo, width, height, d_width, d_height, flags,
title, format);
format);
vo->config_ok = (ret == 0);
vo->config_count += vo->config_ok;
if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) {
@@ -588,6 +588,18 @@ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
dst->height = dst->bottom - dst->top;
}
// Return the window title the VO should set. Always returns a null terminated
// string. The string is valid until frontend code is invoked again. Copy it if
// you need to keep the string for an extended period of time.
const char *vo_get_window_title(struct vo *vo)
{
if (vo->opts->vo_wintitle) {
return vo->opts->vo_wintitle;
} else {
return "mplayer2";
}
}
/**
* Generates a mouse movement message if those are enable and sends it
* to the "main" MPlayer.
+3 -2
View File
@@ -190,7 +190,7 @@ struct vo_driver {
*/
int (*config)(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
char *title, uint32_t format);
uint32_t format);
/*
* Control interface
@@ -303,7 +303,7 @@ struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
struct input_ctx *input_ctx);
int vo_config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format);
uint32_t format);
void list_video_out(void);
int vo_control(struct vo *vo, uint32_t request, void *data);
@@ -320,6 +320,7 @@ void vo_check_events(struct vo *vo);
void vo_seek_reset(struct vo *vo);
void vo_destroy(struct vo *vo);
const char *vo_get_window_title(struct vo *vo);
// NULL terminated array of all drivers
extern const struct vo_driver *video_out_drivers[];
+5 -5
View File
@@ -643,19 +643,19 @@ static int initGl(struct vo *vo, uint32_t d_width, uint32_t d_height)
}
static int create_window(struct vo *vo, uint32_t d_width, uint32_t d_height,
uint32_t flags, const char *title)
uint32_t flags)
{
struct gl_priv *p = vo->priv;
if (p->stereo_mode == GL_3D_QUADBUFFER)
flags |= VOFLAG_STEREO;
return p->glctx->create_window(p->glctx, d_width, d_height, flags, title);
return p->glctx->create_window(p->glctx, d_width, d_height, flags);
}
static int config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format)
uint32_t format)
{
struct gl_priv *p = vo->priv;
@@ -672,7 +672,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
p->vo_flipped = !!(flags & VOFLAG_FLIPPING);
if (create_window(vo, d_width, d_height, flags, title) < 0)
if (create_window(vo, d_width, d_height, flags) < 0)
return -1;
if (vo->config_count)
@@ -1371,7 +1371,7 @@ static int preinit_internal(struct vo *vo, const char *arg, int allow_sw,
}
if (p->use_yuv == -1 || !allow_sw) {
if (create_window(vo, 320, 200, VOFLAG_HIDDEN, NULL) < 0)
if (create_window(vo, 320, 200, VOFLAG_HIDDEN) < 0)
goto err_out;
if (p->glctx->setGlWindow(p->glctx) == SET_WINDOW_FAILED)
goto err_out;
+2 -2
View File
@@ -863,7 +863,7 @@ static int handle_preemption(struct vo *vo)
*/
static int config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format)
uint32_t format)
{
struct vdpctx *vc = vo->priv;
struct vo_x11_state *x11 = vo->x11;
@@ -911,7 +911,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
xswamask = CWBorderPixel;
vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, d_width, d_height,
flags, CopyFromParent, "vdpau", title);
flags, CopyFromParent, "vdpau");
XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa);
#ifdef CONFIG_XF86VM
+2 -3
View File
@@ -198,7 +198,7 @@ static void resize(struct vo *vo)
*/
static int config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
char *title, uint32_t format)
uint32_t format)
{
struct vo_x11_state *x11 = vo->x11;
XVisualInfo vinfo;
@@ -262,8 +262,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
}
vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, vo->dwidth,
vo->dheight, flags, CopyFromParent, "xv",
title);
vo->dheight, flags, CopyFromParent, "xv");
XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa);
#ifdef CONFIG_XF86VM
+57 -9
View File
@@ -327,11 +327,14 @@ static void init_atoms(struct vo_x11_state *x11)
XA_INIT(_NET_WM_STATE_STAYS_ON_TOP);
XA_INIT(_NET_WM_STATE_BELOW);
XA_INIT(_NET_WM_PID);
XA_INIT(_NET_WM_NAME);
XA_INIT(_NET_WM_ICON_NAME);
XA_INIT(_WIN_PROTOCOLS);
XA_INIT(_WIN_LAYER);
XA_INIT(_WIN_HINTS);
XA_INIT(WM_PROTOCOLS);
XA_INIT(WM_DELETE_WINDOW);
XA_INIT(UTF8_STRING);
}
void update_xinerama_info(struct vo *vo) {
@@ -712,7 +715,7 @@ void vo_x11_classhint(struct vo *vo, Window window, const char *name)
pid_t pid = getpid();
wmClass.res_name = opts->vo_winname ? opts->vo_winname : (char *)name;
wmClass.res_class = "MPlayer";
wmClass.res_class = "mplayer2";
XSetClassHint(x11->display, window, &wmClass);
XChangeProperty(x11->display, window, x11->XA_NET_WM_PID, XA_CARDINAL,
32, PropModeReplace, (unsigned char *) &pid, 1);
@@ -990,6 +993,56 @@ static int vo_x11_get_gnome_layer(struct vo_x11_state *x11, Window win)
return WIN_LAYER_NORMAL;
}
// set a X text property that expects a STRING type
static void vo_x11_set_property_string(struct vo *vo, Atom name, const char *t)
{
struct vo_x11_state *x11 = vo->x11;
XTextProperty prop = {0};
int success;
success = Xutf8TextListToTextProperty(x11->display, (char **)&t, 1,
XStringStyle, &prop);
// The call can fail if the string uses characters not in the STRING
// encoding (which is latin-1 as far as I can tell). Try COMPOUND_TEXT
// instead. (It is possible that COMPOUND_TEXT always works, but since the
// difference in the type used for the property is visible to the Window
// manager and the ICCCM seems to specify STRING, we're trying to be careful
// and try STRING first.)
// GTK seems to follow about the same fallback mechanism.
if (success != Success) {
XFree(prop.value);
prop.value = NULL;
success = Xutf8TextListToTextProperty(x11->display, (char **)&t, 1,
XCompoundTextStyle, &prop);
}
if (success == Success)
XSetTextProperty(x11->display, x11->window, &prop, name);
XFree(prop.value);
}
// set a X text property that expects a UTF8_STRING type
static void vo_x11_set_property_utf8(struct vo *vo, Atom name, const char *t)
{
struct vo_x11_state *x11 = vo->x11;
XChangeProperty(x11->display, x11->window, name, x11->XAUTF8_STRING, 8,
PropModeReplace, t, strlen(t));
}
static void vo_x11_update_window_title(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
const char *title = vo_get_window_title(vo);
vo_x11_set_property_string(vo, XA_WM_NAME, title);
vo_x11_set_property_string(vo, XA_WM_ICON_NAME, title);
vo_x11_set_property_utf8(vo, x11->XA_NET_WM_NAME, title);
vo_x11_set_property_utf8(vo, x11->XA_NET_WM_ICON_NAME, title);
}
//
static Window vo_x11_create_smooth_window(struct vo_x11_state *x11, Window mRoot,
Visual * vis, int x, int y,
@@ -1032,15 +1085,13 @@ static Window vo_x11_create_smooth_window(struct vo_x11_state *x11, Window mRoot
* Only VOFLAG_FULLSCREEN is supported so far.
* \param col_map Colourmap for window or CopyFromParent if a specific colormap isn't needed
* \param classname name to use for the classhint
* \param title title for the window
*
* This also does the grunt-work like setting Window Manager hints etc.
* If vo_window is already set it just moves and resizes it.
*/
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
unsigned int width, unsigned int height, int flags,
Colormap col_map,
const char *classname, const char *title)
Colormap col_map, const char *classname)
{
struct MPOpts *opts = vo->opts;
struct vo_x11_state *x11 = vo->x11;
@@ -1083,7 +1134,6 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
XSizeHints hint;
x11->window_state &= ~VOFLAG_HIDDEN;
vo_x11_classhint(vo, x11->window, classname);
XStoreName(mDisplay, x11->window, title);
vo_hidecursor(mDisplay, x11->window);
XSelectInput(mDisplay, x11->window, StructureNotifyMask);
hint.x = x; hint.y = y;
@@ -1091,7 +1141,7 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
hint.flags = PSize;
if (geometry_xy_changed)
hint.flags |= PPosition;
XSetStandardProperties(mDisplay, x11->window, title, title, None, NULL, 0, &hint);
XSetWMNormalHints(mDisplay, x11->window, &hint);
if (!vo_border) vo_x11_decoration(vo, 0);
// map window
XSelectInput(mDisplay, x11->window, NoEventMask);
@@ -1101,6 +1151,7 @@ void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis, int x, int y,
XMapWindow(mDisplay, x11->window);
vo_x11_clearwindow(vo, x11->window);
}
vo_x11_update_window_title(vo);
if (opts->vo_ontop) vo_x11_setlayer(vo, x11->window, opts->vo_ontop);
vo_x11_update_geometry(vo, !geometry_xy_changed);
vo_x11_nofs_sizepos(vo, vo->dx, vo->dy, width, height);
@@ -1305,7 +1356,6 @@ static int vo_x11_get_fs_type(int supported)
*/
int vo_x11_update_geometry(struct vo *vo, bool update_pos)
{
struct MPOpts *opts = vo->opts;
struct vo_x11_state *x11 = vo->x11;
unsigned depth, w, h;
int dummy_int;
@@ -1319,8 +1369,6 @@ int vo_x11_update_geometry(struct vo *vo, bool update_pos)
if (update_pos)
XTranslateCoordinates(x11->display, x11->window, x11->rootwin, 0, 0,
&vo->dx, &vo->dy, &dummy_win);
if (opts->vo_wintitle)
XStoreName(x11->display, x11->window, opts->vo_wintitle);
return depth <= INT_MAX ? depth : 0;
}
+6 -2
View File
@@ -85,11 +85,14 @@ struct vo_x11_state {
Atom XA_NET_WM_STATE_STAYS_ON_TOP;
Atom XA_NET_WM_STATE_BELOW;
Atom XA_NET_WM_PID;
Atom XA_NET_WM_NAME;
Atom XA_NET_WM_ICON_NAME;
Atom XA_WIN_PROTOCOLS;
Atom XA_WIN_LAYER;
Atom XA_WIN_HINTS;
Atom XAWM_PROTOCOLS;
Atom XAWM_DELETE_WINDOW;
Atom XAUTF8_STRING;
};
#if defined(CONFIG_GL) || defined(CONFIG_X11) || defined(CONFIG_XV)
@@ -135,7 +138,7 @@ uint32_t vo_x11_get_equalizer(const char *name, int *value);
void fstype_help(void);
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
int x, int y, unsigned int width, unsigned int height, int flags,
Colormap col_map, const char *classname, const char *title);
Colormap col_map, const char *classname);
void vo_x11_clearwindow_part(struct vo *vo, Window vo_window,
int img_width, int img_height);
void vo_x11_clearwindow(struct vo *vo, Window vo_window);
@@ -184,7 +187,8 @@ void xscreensaver_heartbeat(struct vo_x11_state *x11);
// Old VOs use incompatible function calls, translate them to new
// prototypes
#ifdef IS_OLD_VO
#define vo_x11_create_vo_window(...) vo_x11_create_vo_window(global_vo, __VA_ARGS__)
#define vo_x11_create_vo_window(vis, x, y, width, height, flags, col_map, classname, title) \
vo_x11_create_vo_window(global_vo, vis, x, y, width, height, flags, col_map, classname)
#define vo_x11_fullscreen() vo_x11_fullscreen(global_vo)
#define vo_x11_update_geometry() vo_x11_update_geometry(global_vo, 1)
#define vo_x11_ontop() vo_x11_ontop(global_vo)