nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { if (aPluginInstance) { if (type == NPWindowTypeWindow) { if (!mSocketWidget) { nsresult rv; PRBool needXEmbed = PR_FALSE; rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed); // If the call returned an error code make sure we still use our default value. if (NS_FAILED(rv)) { needXEmbed = PR_FALSE; } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed); #endif if (needXEmbed) { rv = CreateXEmbedWindow(); } 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 = (void*)GTK_XTBIN(mSocketWidget)->xtwindow; } else { // XEmbed SetAllocation(); window = (void*)gtk_socket_get_id(GTK_SOCKET(mSocketWidget)); } #ifdef DEBUG printf("nsPluginNativeWindowGtk2: call SetWindow with xid=%p\n", (void *)window); #endif } // NPWindowTypeWindow 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; }
nsresult nsPluginNativeWindowGtk::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance) { if (aPluginInstance) { if (type == NPWindowTypeWindow) { if (!mSocketWidget) { nsresult rv; // The documentation on the types for many variables in NP(N|P)_GetValue // is vague. Often boolean values are NPBool (1 byte), but // https://developer.mozilla.org/en/XEmbed_Extension_for_Mozilla_Plugins // treats NPPVpluginNeedsXEmbed as PRBool (int), and // on x86/32-bit, flash stores to this using |movl 0x1,&needsXEmbed|. // thus we can't use NPBool for needsXEmbed, or the three bytes above // it on the stack would get clobbered. so protect with the larger bool. int needsXEmbed = 0; rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needsXEmbed); // If the call returned an error code make sure we still use our default value. if (NS_FAILED(rv)) { needsXEmbed = 0; } #ifdef DEBUG printf("nsPluginNativeWindowGtk: NPPVpluginNeedsXEmbed=%d\n", needsXEmbed); #endif bool isOOPPlugin = aPluginInstance->GetPlugin()->GetLibrary()->IsOOP(); if (needsXEmbed || isOOPPlugin) { bool enableXtFocus = !needsXEmbed; rv = CreateXEmbedWindow(enableXtFocus); } else { #if (MOZ_WIDGET_GTK == 2) rv = CreateXtWindow(); #else return NS_ERROR_FAILURE; #endif } 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. SetAllocation(); // Need to reset "window" each time as nsPluginFrame::DidReflow sets it // to the ancestor window. #if (MOZ_WIDGET_GTK == 2) if (GTK_IS_XTBIN(mSocketWidget)) { // Point the NPWindow structures window to the actual X window SetWindow(GTK_XTBIN(mSocketWidget)->xtwindow); } else { // XEmbed or OOP&Xt SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget))); } #else // Gtk3 supports only OOP by GtkSocket SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget))); #endif #ifdef DEBUG printf("nsPluginNativeWindowGtk: call SetWindow with xid=%p\n", (void *)window); #endif } // NPWindowTypeWindow aPluginInstance->SetWindow(this); } else if (mPluginInstance) mPluginInstance->SetWindow(nullptr); SetPluginInstance(aPluginInstance); return NS_OK; }