nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance) { 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; }
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance) { if(aPluginInstance) { if (type == nsPluginWindowType_Window) { nsresult rv; if(!mSocketWidget) { PRBool needXEmbed = PR_FALSE; if (CanGetValueFromPlugin(aPluginInstance)) { rv = aPluginInstance->GetValue ((nsPluginInstanceVariable)NPPVpluginNeedsXEmbed, &needXEmbed); #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed); #endif } nsresult rv; if(needXEmbed) { #ifdef MOZ_COMPOSITED_PLUGINS rv = CreateXCompositedWindow(); #else rv = CreateXEmbedWindow(); #endif } else { rv = CreateXtWindow(); } if(NS_FAILED(rv)) return NS_ERROR_FAILURE; } if(!mSocketWidget) return NS_ERROR_FAILURE; // Make sure to resize and re-place the window if required. // Need to reset "window" each time as nsObjectFrame::DidReflow sets it // to the ancestor window. if(GTK_IS_XTBIN(mSocketWidget)) { gtk_xtbin_resize(mSocketWidget, width, height); // Point the NPWindow structures window to the actual X window window = (nsPluginPort *)GTK_XTBIN(mSocketWidget)->xtwindow; } else { // XEmbed SetAllocation(); window = (nsPluginPort *)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif } // nsPluginWindowType_Window aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nsnull); SetPluginInstance(aPluginInstance); return NS_OK; }