mirror of
https://github.com/albfan/miraclecast.git
synced 2025-03-09 23:38:56 +00:00
demo/miracle-wfdctl: fix some build issues for GDK version older then
3.22
This commit is contained in:
parent
3b95b6078c
commit
1e374b0a49
2 changed files with 60 additions and 14 deletions
|
@ -8,10 +8,21 @@ if(NOT VALA_DBUS_BINDING_TOOL)
|
|||
message(FATAL_ERROR "vala-dbus-binding-tool not found")
|
||||
endif()
|
||||
|
||||
find_program(GLIB_COMPILE_RESOURCES glib-compile-resources)
|
||||
if(NOT GLIB_COMPILE_RESOURCES)
|
||||
message(FATAL_ERROR "glib-compile-resources not found")
|
||||
endif()
|
||||
|
||||
find_library(READLINE REQUIRED)
|
||||
pkg_check_modules(GIO2 REQUIRED gio-2.0)
|
||||
pkg_check_modules(GDK3 REQUIRED gdk-3.0)
|
||||
|
||||
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --atleast-version 3.22 gdk-3.0
|
||||
RESULT_VARIABLE GDK_VERSION_NEWER_THEN_3_22)
|
||||
if(NOT GDK_VERSION_NEWER_THEN_3_22)
|
||||
set(VALA_EXTRA_OPTIONS -D GDK_VERSION_NEWER_THEN_3_22)
|
||||
endif()
|
||||
|
||||
set(RES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/res)
|
||||
set(DBUS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dbus)
|
||||
|
||||
|
@ -41,6 +52,7 @@ add_custom_command(OUTPUT wfdctl.c
|
|||
org-freedesktop-networkmanager.vala
|
||||
org-freedesktop-miracle-wifi.vala
|
||||
org-freedesktop-miracle-wfd.vala
|
||||
${VALA_EXTRA_OPTIONS}
|
||||
DEPENDS wfdctl.vala
|
||||
${CMAKE_CURRENT_BINARY_DIR}/org-freedesktop-networkmanager.vala
|
||||
${CMAKE_CURRENT_BINARY_DIR}/org-freedesktop-miracle-wifi.vala
|
||||
|
@ -49,8 +61,9 @@ add_custom_command(OUTPUT wfdctl.c
|
|||
|
||||
add_custom_command(OUTPUT wfdctl-res.c
|
||||
COMMAND ${GLIB_COMPILE_RESOURCES}
|
||||
--generate-source
|
||||
--target=${CMAKE_CURRENT_BINARY_DIR}/wfdctl-res.c
|
||||
--generate-source ${RES_DIR}/wfdctl-res.xml
|
||||
${RES_DIR}/wfdctl-res.xml
|
||||
DEPENDS ${RES_DIR}/wfdctl.ui
|
||||
${RES_DIR}/wfdctl-res.xml
|
||||
WORKING_DIRECTORY ${RES_DIR})
|
||||
|
|
|
@ -330,25 +330,53 @@ private class WfdCtl : GLib.Application
|
|||
info("P2P group formed");
|
||||
}
|
||||
|
||||
#if GDK_VERSION_NEWER_THEN_3_22
|
||||
private void get_monitor_geometry(out Gdk.Rectangle g) throws Error
|
||||
{
|
||||
Gdk.Monitor m;
|
||||
if(-1 == opt_monitor_num) {
|
||||
m = display.get_primary_monitor();
|
||||
}
|
||||
else {
|
||||
m = display.get_monitor(opt_monitor_num);
|
||||
}
|
||||
|
||||
if(null == m) {
|
||||
throw new WfdCtlError.MONITOR_GONE("specified monitor disappeared");
|
||||
}
|
||||
|
||||
g = m.geometry;
|
||||
}
|
||||
#else
|
||||
private void get_monitor_geometry(out Gdk.Rectangle g) throws Error
|
||||
{
|
||||
var s = display.get_default_screen();
|
||||
int m = (-1 == opt_monitor_num)
|
||||
? s.get_primary_monitor()
|
||||
: opt_monitor_num;
|
||||
|
||||
if(s.get_n_monitors() <= m) {
|
||||
throw new WfdCtlError.MONITOR_GONE("specified monitor disappeared");
|
||||
}
|
||||
|
||||
s.get_monitor_geometry(m, out g);
|
||||
}
|
||||
#endif
|
||||
|
||||
private async void establish_session() throws Error
|
||||
{
|
||||
weak Gdk.Monitor m = (-1 == opt_monitor_num)
|
||||
? display.get_primary_monitor()
|
||||
: display.get_monitor(opt_monitor_num);
|
||||
if(null == m) {
|
||||
throw new WfdCtlError.MONITOR_GONE("monitor %d gone",
|
||||
opt_monitor_num);
|
||||
}
|
||||
Gdk.Rectangle g;
|
||||
get_monitor_geometry(out g);
|
||||
|
||||
info("establishing display session...");
|
||||
|
||||
Sink sink = find_sink_by_mac(opt_peer_mac);
|
||||
sink.start_session(opt_authority,
|
||||
@"x://$(opt_display)",
|
||||
m.geometry.x,
|
||||
m.geometry.y,
|
||||
m.geometry.width,
|
||||
m.geometry.height,
|
||||
g.x,
|
||||
g.y,
|
||||
g.width,
|
||||
g.height,
|
||||
null == opt_audio_device ? "" : opt_audio_device);
|
||||
}
|
||||
|
||||
|
@ -412,8 +440,13 @@ private class WfdCtl : GLib.Application
|
|||
return false;
|
||||
}
|
||||
|
||||
if(-1 != opt_monitor_num &&
|
||||
null == display.get_monitor(opt_monitor_num)) {
|
||||
int n_monitors;
|
||||
#if GDK_VERSION_NEWER_THEN_3_22
|
||||
n_monitors = display.get_n_monitors();
|
||||
#else
|
||||
n_monitors = display.get_default_screen().get_n_monitors();
|
||||
#endif
|
||||
if(-1 > opt_monitor_num || opt_monitor_num >= n_monitors) {
|
||||
print("invalid screen number option: %d", opt_monitor_num);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue