| 170 | }; |
| 171 | |
| 172 | void browser::open_devtools(cef_browser_t *browser) |
| 173 | { |
| 174 | if (!config::options::use_devtools()) |
| 175 | return; |
| 176 | |
| 177 | int browser_id = browser->get_identifier(browser); |
| 178 | const auto &it = devtools_map_.find(browser_id); |
| 179 | |
| 180 | // Found existing devtools window. |
| 181 | if (it != devtools_map_.end()) |
| 182 | { |
| 183 | window::make_foreground(it->second); |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | auto host = browser->get_host(browser); |
| 188 | auto hview = host->get_window_handle(host); |
| 189 | |
| 190 | cef_window_info_t wi{}; |
| 191 | #if OS_WIN |
| 192 | wi.ex_style = WS_EX_APPWINDOW; |
| 193 | wi.style = WS_OVERLAPPEDWINDOW |
| 194 | | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE; |
| 195 | #endif |
| 196 | |
| 197 | cef_rect_t *wrect; |
| 198 | #if CEF_VERSION_MAJOR >= 108 |
| 199 | wrect = &wi.bounds; |
| 200 | #else |
| 201 | wrect = (cef_rect_t *)&wi.x; |
| 202 | #endif |
| 203 | |
| 204 | // position next to the client window |
| 205 | window::get_rect(hview, &wrect->x, &wrect->y, &wrect->width, &wrect->height); |
| 206 | wrect->x += 100; |
| 207 | wrect->y += 100; |
| 208 | |
| 209 | char caption[512]; |
| 210 | strcpy(caption, "League Client DevTools - "); |
| 211 | auto frame = browser->get_focused_frame(browser); |
| 212 | CefScopedStr url{ frame->get_url(frame) }; |
| 213 | |
| 214 | if (!url.empty()) |
| 215 | strcat(caption, url.to_utf8().c_str()); |
| 216 | else |
| 217 | strcat(caption, "about:blank"); |
| 218 | wi.window_name = CefStr(caption, strlen(caption)).forward(); |
| 219 | |
| 220 | cef_browser_settings_t settings{}; |
| 221 | host->show_dev_tools(host, &wi, new DevToolsClient(browser_id), &settings, nullptr); |
| 222 | // ^--- We use new client to keep DevTools |
| 223 | // from being scaled by League Client (e.g 0.8, 1.6). |
| 224 | |
| 225 | frame->base.release(&frame->base); |
| 226 | host->base.release(&host->base); |
| 227 | } |
| 228 | } |
nothing calls this directly
no test coverage detected