MCPcopy Create free account
hub / github.com/DISTRHO/DPF / dpf_webview_start

Function dpf_webview_start

distrho/extra/WebViewImpl.cpp:1949–2055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1947}
1948
1949int dpf_webview_start(const int argc, char* argv[])
1950{
1951 if (argc != 3)
1952 {
1953 d_stderr("WebView entry point, nothing to see here! ;)");
1954 return 1;
1955 }
1956
1957 d_stdout("starting... %d '%s' '%s'", argc, argv[1], argv[2]);
1958
1959 uselocale(newlocale(LC_NUMERIC_MASK, "C", nullptr));
1960
1961 Display* const display = XOpenDisplay(nullptr);
1962 DISTRHO_SAFE_ASSERT_RETURN(display != nullptr, 1);
1963
1964 const char* const shmname = argv[2];
1965 const int shmfd = shm_open(shmname, O_RDWR, 0);
1966 if (shmfd < 0)
1967 {
1968 d_stderr("shm_open failed: %s", std::strerror(errno));
1969 return 1;
1970 }
1971
1972 WebViewRingBuffer* const shmptr = static_cast<WebViewRingBuffer*>(mmap(nullptr,
1973 sizeof(WebViewRingBuffer),
1974 PROT_READ|PROT_WRITE,
1975 MAP_SHARED,
1976 shmfd, 0));
1977 if (shmptr == nullptr || shmptr == nullptr)
1978 {
1979 d_stderr("mmap failed: %s", std::strerror(errno));
1980 close(shmfd);
1981 return 1;
1982 }
1983
1984 RingBufferControl<WebViewSharedBuffer> rbctrl;
1985 rbctrl.setRingBuffer(&shmptr->client, false);
1986
1987 // fetch initial data
1988 bool hasInitialData = false;
1989 Window winId = 0;
1990 uint width = 0, height = 0;
1991 double scaleFactor = 0;
1992 int x = 0, y = 0;
1993 char* url = nullptr;
1994 char* initJS = nullptr;
1995
1996 while (shmptr->valid && webview_timedwait(&shmptr->client.sem))
1997 {
1998 if (rbctrl.isDataAvailableForReading())
1999 {
2000 DISTRHO_SAFE_ASSERT_RETURN(rbctrl.readUInt() == kWebViewMessageInitData, 1);
2001
2002 hasInitialData = running = true;
2003 winId = rbctrl.readULong();
2004 width = rbctrl.readUInt();
2005 height = rbctrl.readUInt();
2006 scaleFactor = rbctrl.readDouble();

Callers 4

ApplicationMethod · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 7

d_stderrFunction · 0.85
d_stdoutFunction · 0.85
qtwebengineFunction · 0.85
gtk3Function · 0.85
closeFunction · 0.70
sigactionClass · 0.70

Tested by

no test coverage detected