Home | History | Annotate | Download | only in browser
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/platform_util.h"
      6 
      7 #include <gtk/gtk.h>
      8 
      9 namespace platform_util {
     10 
     11 gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
     12   // A detached widget won't have a toplevel window as an ancestor, so we can't
     13   // assume that the query for toplevel will return a window.
     14   GtkWidget* toplevel = gtk_widget_get_ancestor(view, GTK_TYPE_WINDOW);
     15   return GTK_IS_WINDOW(toplevel) ? GTK_WINDOW(toplevel) : NULL;
     16 }
     17 
     18 gfx::NativeView GetParent(gfx::NativeView view) {
     19   return gtk_widget_get_parent(view);
     20 }
     21 
     22 bool IsWindowActive(gfx::NativeWindow window) {
     23   return gtk_window_is_active(window);
     24 }
     25 
     26 void ActivateWindow(gfx::NativeWindow window) {
     27   gtk_window_present(window);
     28 }
     29 
     30 bool IsVisible(gfx::NativeView view) {
     31   return gtk_widget_get_visible(view);
     32 }
     33 
     34 }  // namespace platform_util
     35