Linux: Fix browser window position in cefclient when using integrated window menu bar (issue #1388).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1851 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
4fe21a31d8
commit
25ed4dfefc
|
@ -38,6 +38,9 @@ char szWorkingDir[512]; // The current working directory
|
||||||
// Height of the buttons at the top of the GTK window.
|
// Height of the buttons at the top of the GTK window.
|
||||||
int g_toolbar_height = 0;
|
int g_toolbar_height = 0;
|
||||||
|
|
||||||
|
// Height of the integrated menu bar (if any) at the top of the GTK window.
|
||||||
|
int g_menubar_height = 0;
|
||||||
|
|
||||||
class MainBrowserProvider : public OSRBrowserProvider {
|
class MainBrowserProvider : public OSRBrowserProvider {
|
||||||
virtual CefRefPtr<CefBrowser> GetBrowser() {
|
virtual CefRefPtr<CefBrowser> GetBrowser() {
|
||||||
if (g_handler.get())
|
if (g_handler.get())
|
||||||
|
@ -100,8 +103,10 @@ void VboxSizeAllocated(GtkWidget *widget,
|
||||||
::Window xwindow = browser->GetHost()->GetWindowHandle();
|
::Window xwindow = browser->GetHost()->GetWindowHandle();
|
||||||
XWindowChanges changes = {0};
|
XWindowChanges changes = {0};
|
||||||
changes.width = allocation->width;
|
changes.width = allocation->width;
|
||||||
changes.height = allocation->height - g_toolbar_height;
|
changes.height = allocation->height -
|
||||||
XConfigureWindow(xdisplay, xwindow, CWHeight | CWWidth, &changes);
|
(g_toolbar_height + g_menubar_height);
|
||||||
|
changes.y = g_toolbar_height + g_menubar_height;
|
||||||
|
XConfigureWindow(xdisplay, xwindow, CWHeight | CWWidth | CWY, &changes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,6 +117,12 @@ void ToolbarSizeAllocated(GtkWidget *widget,
|
||||||
g_toolbar_height = allocation->height;
|
g_toolbar_height = allocation->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenubarSizeAllocated(GtkWidget* widget,
|
||||||
|
GtkAllocation* allocation,
|
||||||
|
void* data) {
|
||||||
|
g_menubar_height = allocation->height;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean WindowFocusIn(GtkWidget* widget,
|
gboolean WindowFocusIn(GtkWidget* widget,
|
||||||
GdkEventFocus* event,
|
GdkEventFocus* event,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
|
@ -450,6 +461,8 @@ int main(int argc, char* argv[]) {
|
||||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||||
|
|
||||||
GtkWidget* menu_bar = CreateMenuBar();
|
GtkWidget* menu_bar = CreateMenuBar();
|
||||||
|
g_signal_connect(menu_bar, "size-allocate",
|
||||||
|
G_CALLBACK(MenubarSizeAllocated), NULL);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(vbox), menu_bar, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue