Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
35698185
Commit
35698185
authored
Dec 10, 2009
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
XCB: code factorization
parent
76da073c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
52 deletions
+74
-52
modules/video_output/xcb/common.c
modules/video_output/xcb/common.c
+51
-52
modules/video_output/xcb/events.c
modules/video_output/xcb/events.c
+22
-0
modules/video_output/xcb/xcb_vlc.h
modules/video_output/xcb/xcb_vlc.h
+1
-0
No files found.
modules/video_output/xcb/common.c
View file @
35698185
...
@@ -65,6 +65,51 @@ static xcb_connection_t *Connect (vlc_object_t *obj, const char *display)
...
@@ -65,6 +65,51 @@ static xcb_connection_t *Connect (vlc_object_t *obj, const char *display)
return
conn
;
return
conn
;
}
}
/**
* Find screen matching a given root window.
*/
static
const
xcb_screen_t
*
FindScreen
(
vlc_object_t
*
obj
,
xcb_connection_t
*
conn
,
xcb_window_t
root
)
{
/* Find the selected screen */
const
xcb_setup_t
*
setup
=
xcb_get_setup
(
conn
);
const
xcb_screen_t
*
screen
=
NULL
;
for
(
xcb_screen_iterator_t
i
=
xcb_setup_roots_iterator
(
setup
);
i
.
rem
>
0
&&
screen
==
NULL
;
xcb_screen_next
(
&
i
))
{
if
(
i
.
data
->
root
==
root
)
screen
=
i
.
data
;
}
if
(
screen
==
NULL
)
{
msg_Err
(
obj
,
"parent window screen not found"
);
return
NULL
;
}
msg_Dbg
(
obj
,
"using screen 0x%"
PRIx32
,
root
);
return
screen
;
}
static
const
xcb_screen_t
*
FindWindow
(
vlc_object_t
*
obj
,
xcb_connection_t
*
conn
,
xcb_window_t
xid
,
uint8_t
*
restrict
pdepth
)
{
xcb_get_geometry_reply_t
*
geo
=
xcb_get_geometry_reply
(
conn
,
xcb_get_geometry
(
conn
,
xid
),
NULL
);
if
(
geo
==
NULL
)
{
msg_Err
(
obj
,
"parent window not valid"
);
return
NULL
;
}
const
xcb_screen_t
*
screen
=
FindScreen
(
obj
,
conn
,
geo
->
root
);
*
pdepth
=
geo
->
depth
;
free
(
geo
);
return
screen
;
}
/**
/**
* Create a VLC video X window object, connect to the corresponding X server,
* Create a VLC video X window object, connect to the corresponding X server,
...
@@ -76,7 +121,6 @@ vout_window_t *GetWindow (vout_display_t *vd,
...
@@ -76,7 +121,6 @@ vout_window_t *GetWindow (vout_display_t *vd,
uint8_t
*
restrict
pdepth
)
uint8_t
*
restrict
pdepth
)
{
{
/* Get window */
/* Get window */
xcb_window_t
root
;
vout_window_cfg_t
wnd_cfg
;
vout_window_cfg_t
wnd_cfg
;
memset
(
&
wnd_cfg
,
0
,
sizeof
(
wnd_cfg
)
);
memset
(
&
wnd_cfg
,
0
,
sizeof
(
wnd_cfg
)
);
...
@@ -93,65 +137,20 @@ vout_window_t *GetWindow (vout_display_t *vd,
...
@@ -93,65 +137,20 @@ vout_window_t *GetWindow (vout_display_t *vd,
xcb_connection_t
*
conn
=
Connect
(
VLC_OBJECT
(
vd
),
wnd
->
x11_display
);
xcb_connection_t
*
conn
=
Connect
(
VLC_OBJECT
(
vd
),
wnd
->
x11_display
);
if
(
conn
==
NULL
)
if
(
conn
==
NULL
)
{
vout_display_DeleteWindow
(
vd
,
wnd
);
return
NULL
;
}
else
{
xcb_get_geometry_reply_t
*
geo
;
xcb_get_geometry_cookie_t
ck
;
ck
=
xcb_get_geometry
(
conn
,
wnd
->
xid
);
geo
=
xcb_get_geometry_reply
(
conn
,
ck
,
NULL
);
if
(
geo
==
NULL
)
{
msg_Err
(
vd
,
"parent window not valid"
);
goto
error
;
goto
error
;
}
*
pconn
=
conn
;
root
=
geo
->
root
;
*
pdepth
=
geo
->
depth
;
free
(
geo
);
/* Subscribe to parent window resize events */
uint32_t
value
=
XCB_EVENT_MASK_POINTER_MOTION
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY
;
xcb_change_window_attributes
(
conn
,
wnd
->
xid
,
XCB_CW_EVENT_MASK
,
&
value
);
/* Try to subscribe to click events */
/* (only one X11 client can get them, so might not work) */
if
(
var_CreateGetBool
(
vd
,
"mouse-events"
))
{
value
|=
XCB_EVENT_MASK_BUTTON_PRESS
|
XCB_EVENT_MASK_BUTTON_RELEASE
;
xcb_change_window_attributes
(
conn
,
wnd
->
xid
,
XCB_CW_EVENT_MASK
,
&
value
);
}
}
/* Find the selected screen */
const
xcb_setup_t
*
setup
=
xcb_get_setup
(
conn
);
const
xcb_screen_t
*
screen
=
NULL
;
for
(
xcb_screen_iterator_t
i
=
xcb_setup_roots_iterator
(
setup
);
i
.
rem
>
0
&&
screen
==
NULL
;
xcb_screen_next
(
&
i
))
{
if
(
i
.
data
->
root
==
root
)
screen
=
i
.
data
;
}
if
(
screen
==
NULL
)
*
pscreen
=
FindWindow
(
VLC_OBJECT
(
vd
),
conn
,
wnd
->
xid
,
pdepth
);
if
(
*
pscreen
==
NULL
)
{
{
msg_Err
(
vd
,
"parent window screen not found"
);
xcb_disconnect
(
conn
);
goto
error
;
goto
error
;
}
}
msg_Dbg
(
vd
,
"using screen 0x%"
PRIx32
,
root
);
*
pconn
=
conn
;
RegisterMouseEvents
(
VLC_OBJECT
(
vd
),
conn
,
wnd
->
xid
);
*
pscreen
=
screen
;
return
wnd
;
return
wnd
;
error:
error:
xcb_disconnect
(
conn
);
vout_display_DeleteWindow
(
vd
,
wnd
);
vout_display_DeleteWindow
(
vd
,
wnd
);
return
NULL
;
return
NULL
;
}
}
...
...
modules/video_output/xcb/events.c
View file @
35698185
...
@@ -91,6 +91,28 @@ xcb_cursor_t CreateBlankCursor (xcb_connection_t *conn,
...
@@ -91,6 +91,28 @@ xcb_cursor_t CreateBlankCursor (xcb_connection_t *conn,
return
cur
;
return
cur
;
}
}
/**
* (Try to) register to mouse events on a window if needed.
*/
void
RegisterMouseEvents
(
vlc_object_t
*
obj
,
xcb_connection_t
*
conn
,
xcb_window_t
wnd
)
{
/* Subscribe to parent window resize events */
uint32_t
value
=
XCB_EVENT_MASK_POINTER_MOTION
|
XCB_EVENT_MASK_STRUCTURE_NOTIFY
;
xcb_change_window_attributes
(
conn
,
wnd
,
XCB_CW_EVENT_MASK
,
&
value
);
/* Try to subscribe to click events */
/* (only one X11 client can get them, so might not work) */
if
(
var_CreateGetBool
(
obj
,
"mouse-events"
))
{
value
|=
XCB_EVENT_MASK_BUTTON_PRESS
|
XCB_EVENT_MASK_BUTTON_RELEASE
;
xcb_change_window_attributes
(
conn
,
wnd
,
XCB_CW_EVENT_MASK
,
&
value
);
}
var_Destroy
(
obj
,
"mouse-events"
);
}
/* NOTE: we assume no other thread will be _setting_ our video output events
/* NOTE: we assume no other thread will be _setting_ our video output events
* variables. Afterall, only this plugin is supposed to know when these occur.
* variables. Afterall, only this plugin is supposed to know when these occur.
* Otherwise, we'd var_OrInteger() and var_NandInteger() functions...
* Otherwise, we'd var_OrInteger() and var_NandInteger() functions...
...
...
modules/video_output/xcb/xcb_vlc.h
View file @
35698185
...
@@ -46,6 +46,7 @@ int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn,
...
@@ -46,6 +46,7 @@ int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn,
unsigned
*
restrict
width
,
unsigned
*
restrict
height
);
unsigned
*
restrict
width
,
unsigned
*
restrict
height
);
void
CheckSHM
(
vlc_object_t
*
obj
,
xcb_connection_t
*
conn
,
bool
*
restrict
pshm
);
void
CheckSHM
(
vlc_object_t
*
obj
,
xcb_connection_t
*
conn
,
bool
*
restrict
pshm
);
xcb_cursor_t
CreateBlankCursor
(
xcb_connection_t
*
,
const
xcb_screen_t
*
);
xcb_cursor_t
CreateBlankCursor
(
xcb_connection_t
*
,
const
xcb_screen_t
*
);
void
RegisterMouseEvents
(
vlc_object_t
*
,
xcb_connection_t
*
,
xcb_window_t
);
int
CheckError
(
vout_display_t
*
,
xcb_connection_t
*
conn
,
int
CheckError
(
vout_display_t
*
,
xcb_connection_t
*
conn
,
const
char
*
str
,
xcb_void_cookie_t
);
const
char
*
str
,
xcb_void_cookie_t
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment