Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | Private Attributes
nsPluginNativeWindowGtk2 Class Reference

This file is the Gtk2 implementation of plugin native window. More...

Inheritance diagram for nsPluginNativeWindowGtk2:
Inheritance graph
[legend]
Collaboration diagram for nsPluginNativeWindowGtk2:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsPluginNativeWindowGtk2 ()
virtual ~nsPluginNativeWindowGtk2 ()
virtual nsresult CallSetWindow (nsCOMPtr< nsIPluginInstance > &aPluginInstance)
nsresult GetPluginInstance (nsCOMPtr< nsIPluginInstance > &aPluginInstance)
 !!! CAUTION !!!
nsresult GetPluginInstance (nsCOMPtr< nsIPluginInstance > &aPluginInstance)
 !!! CAUTION !!!
nsresult SetPluginInstance (nsIPluginInstance *aPluginInstance)
nsresult SetPluginInstance (nsIPluginInstance *aPluginInstance)
nsresult GetPluginWidget (nsIWidget **aWidget)
nsresult GetPluginWidget (nsIWidget **aWidget)
nsresult SetPluginWidget (nsIWidget *aWidget)
nsresult SetPluginWidget (nsIWidget *aWidget)

Public Attributes

nsPluginPort * window
PRInt32 x
PRInt32 y
PRUint32 width
PRUint32 height
nsPluginRect clipRect
nsPluginWindowType type

Protected Attributes

nsCOMPtr< nsIPluginInstancemPluginInstance
nsCOMPtr< nsIWidgetmWidget

Private Member Functions

nsresult CreateXEmbedWindow ()
void SetAllocation ()
PRBool CanGetValueFromPlugin (nsCOMPtr< nsIPluginInstance > &aPluginInstance)

Private Attributes

GtkWidget * mGtkSocket

Detailed Description

This file is the Gtk2 implementation of plugin native window.

Definition at line 59 of file nsPluginNativeWindowGtk2.cpp.


Constructor & Destructor Documentation

Definition at line 74 of file nsPluginNativeWindowGtk2.cpp.

                                                   : nsPluginNativeWindow()
{
  // initialize the struct fields
  window = nsnull; 
  x = 0; 
  y = 0; 
  width = 0; 
  height = 0; 
  memset(&clipRect, 0, sizeof(clipRect));
  ws_info = nsnull;
  type = nsPluginWindowType_Window;
  mGtkSocket = 0;
}

Here is the call graph for this function:

Definition at line 88 of file nsPluginNativeWindowGtk2.cpp.

{
  if(mGtkSocket) {
    gtk_widget_destroy(mGtkSocket);
    mGtkSocket = 0;
  }
}

Member Function Documentation

Reimplemented from nsPluginNativeWindow.

Definition at line 111 of file nsPluginNativeWindowGtk2.cpp.

{
  if(aPluginInstance) {
    nsresult rv;
    PRBool val = PR_FALSE;
    if(!mGtkSocket) {
      if (CanGetValueFromPlugin(aPluginInstance))
        rv = aPluginInstance->GetValue
               ((nsPluginInstanceVariable)NPPVpluginNeedsXEmbed, &val);
    }
#ifdef DEBUG
    printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", val);
#endif
    if(val) {
      CreateXEmbedWindow();
    }

    if(mGtkSocket) {
      // Make sure to resize and re-place the window if required
      SetAllocation();
      window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mGtkSocket));
    }
#ifdef DEBUG
    printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window);
#endif
    aPluginInstance->SetWindow(this);
  }
  else if (mPluginInstance)
    mPluginInstance->SetWindow(nsnull);

  SetPluginInstance(aPluginInstance);
  return NS_OK;
}

Here is the call graph for this function:

Definition at line 191 of file nsPluginNativeWindowGtk2.cpp.

{
#ifdef OJI
  if(aPluginInstance) {
    nsresult rv;
    nsCOMPtr<nsIPluginInstancePeer> peer;

    rv = aPluginInstance->GetPeer(getter_AddRefs(peer));
    if (NS_SUCCEEDED(rv) && peer) {
      const char *aMimeType = nsnull;

      peer->GetMIMEType((nsMIMEType*)&aMimeType);
      if (aMimeType &&
          (PL_strncasecmp(aMimeType, "application/x-java-vm", 21) == 0 ||
           PL_strncasecmp(aMimeType, "application/x-java-applet", 25) == 0)) {
        nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kPluginManagerCID, &rv);
        if (NS_SUCCEEDED(rv) && pluginHost) {
          nsIPlugin* pluginFactory = NULL;

          rv = pluginHost->GetPluginFactory("application/x-java-vm", &pluginFactory);
          if (NS_SUCCEEDED(rv) && pluginFactory) {
            const char * jpiDescription;

            pluginFactory->GetValue(nsPluginVariable_DescriptionString, (void*)&jpiDescription);
            if (PL_strncasecmp(jpiDescription, "Java(TM) Plug-in", 16) == 0) {
              // Java Plugin support Xembed from JRE 1.5
              if (PL_strcasecmp(jpiDescription + 17, "1.5") < 0)
                return PR_FALSE;
            }
            if (PL_strncasecmp(jpiDescription, "<a href=\"http://www.blackdown.org/java-linux.html\">", 51) == 0) {
              // Java Plugin support Xembed from JRE 1.5
              if (PL_strcasecmp(jpiDescription + 92, "1.5") < 0)
                return PR_FALSE;
            }
            if (PL_strncasecmp(jpiDescription, "IBM Java(TM) Plug-in", 20) == 0) {
              // Java Plugin support Xembed from JRE 1.5
              if (PL_strcasecmp(jpiDescription + 27, "1.5") < 0)
                return PR_FALSE;
            }
          }
        }
      }
    }
  }
#endif

  return PR_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 145 of file nsPluginNativeWindowGtk2.cpp.

                                                      {
  if(!mGtkSocket) {
    GdkWindow *win = gdk_window_lookup((XID)window);
    mGtkSocket = gtk_socket_new();

    //attach the socket to the container widget
    gtk_widget_set_parent_window(mGtkSocket, win);

    // Make sure to handle the plug_removed signal.  If we don't the
    // socket will automatically be destroyed when the plug is
    // removed, which means we're destroying it more than once.
    // SYNTAX ERROR.
    g_signal_connect(mGtkSocket, "plug_removed",
                     G_CALLBACK(plug_removed_cb), NULL);

    gpointer user_data = NULL;
    gdk_window_get_user_data(win, &user_data);

    GtkContainer *container = GTK_CONTAINER(user_data);
    gtk_container_add(container, mGtkSocket);
    gtk_widget_realize(mGtkSocket);

    // Resize before we show
    SetAllocation();

    gtk_widget_show(mGtkSocket);

    gdk_flush();
    window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mGtkSocket));
  }

  return NS_OK;
}

Here is the call graph for this function:

Here is the caller graph for this function:

nsresult nsPluginNativeWindow::GetPluginInstance ( nsCOMPtr< nsIPluginInstance > &  aPluginInstance) [inline, inherited]

!!! CAUTION !!!

The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h, thus it does not have a destructor of its own. One should never attempt to delete |nsPluginNativeWindow| object instance (or derivatives) using a pointer of |nsPluginWindow *| type. Should such necessity occur it must be properly casted first.

Definition at line 70 of file nsPIPluginHost.idl.

Here is the caller graph for this function:

nsresult nsPluginNativeWindow::GetPluginInstance ( nsCOMPtr< nsIPluginInstance > &  aPluginInstance) [inline, inherited]

!!! CAUTION !!!

The base class |nsPluginWindow| is defined as a struct in nsplugindefs.h, thus it does not have a destructor of its own. One should never attempt to delete |nsPluginNativeWindow| object instance (or derivatives) using a pointer of |nsPluginWindow *| type. Should such necessity occur it must be properly casted first.

Definition at line 70 of file nsPluginNativeWindow.h.

                                                                           { 
    aPluginInstance = mPluginInstance;
    return NS_OK;
  }
nsresult nsPluginNativeWindow::GetPluginWidget ( nsIWidget **  aWidget) [inline, inherited]

Definition at line 80 of file nsPIPluginHost.idl.

Here is the caller graph for this function:

nsresult nsPluginNativeWindow::GetPluginWidget ( nsIWidget **  aWidget) [inline, inherited]

Definition at line 80 of file nsPluginNativeWindow.h.

                                                {
    NS_IF_ADDREF(*aWidget = mWidget);
    return NS_OK;
  }

Definition at line 179 of file nsPluginNativeWindowGtk2.cpp.

                                             {
  if (!mGtkSocket)
    return;

  GtkAllocation new_allocation;
  new_allocation.x = 0;
  new_allocation.y = 0;
  new_allocation.width = width;
  new_allocation.height = height;
  gtk_widget_size_allocate(mGtkSocket, &new_allocation);
}

Here is the caller graph for this function:

nsresult nsPluginNativeWindow::SetPluginInstance ( nsIPluginInstance aPluginInstance) [inline, inherited]

Definition at line 74 of file nsPIPluginHost.idl.

Here is the caller graph for this function:

nsresult nsPluginNativeWindow::SetPluginInstance ( nsIPluginInstance aPluginInstance) [inline, inherited]

Definition at line 74 of file nsPluginNativeWindow.h.

                                                                 { 
    if (mPluginInstance != aPluginInstance)
      mPluginInstance = aPluginInstance;
    return NS_OK;
  }
nsresult nsPluginNativeWindow::SetPluginWidget ( nsIWidget aWidget) [inline, inherited]

Definition at line 84 of file nsPluginNativeWindow.h.

                                               { 
    mWidget = aWidget;
    return NS_OK;
  }
nsresult nsPluginNativeWindow::SetPluginWidget ( nsIWidget aWidget) [inline, inherited]

Definition at line 84 of file nsPIPluginHost.idl.

Here is the caller graph for this function:


Member Data Documentation

Definition at line 274 of file nsIClassicPluginFactory.idl.

Definition at line 273 of file nsIClassicPluginFactory.idl.

Definition at line 66 of file nsPluginNativeWindowGtk2.cpp.

Definition at line 102 of file nsPIPluginHost.idl.

Definition at line 103 of file nsPIPluginHost.idl.

Definition at line 279 of file nsIClassicPluginFactory.idl.

Definition at line 272 of file nsIClassicPluginFactory.idl.

nsPluginPort * nsPluginWindow::window [inherited]

Definition at line 267 of file nsIClassicPluginFactory.idl.

Definition at line 270 of file nsIClassicPluginFactory.idl.

Definition at line 271 of file nsIClassicPluginFactory.idl.


The documentation for this class was generated from the following file: