/* FlashWindowEx is only supported by Win98+ and WinNT5+. If its not supported we do it our own way */ void wgaim_conv_im_blink(GtkWidget *window) { if(!blink_turned_on) return; if(MyFlashWindowEx) { FLASHWINFO info; if(GetForegroundWindow() == GDK_WINDOW_HWND(window->window)) return; memset(&info, 0, sizeof(FLASHWINFO)); info.cbSize = sizeof(FLASHWINFO); info.hwnd = GDK_WINDOW_HWND(window->window); info.dwFlags = FLASHW_ALL | FLASHW_TIMER; info.dwTimeout = 0; MyFlashWindowEx(&info); /* Stop flashing when window receives focus */ g_signal_connect(G_OBJECT(window), "focus-in-event", G_CALLBACK(halt_flash_filter), info.hwnd); } else { WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1); /* Start Flashing window */ finfo->t_handle = gaim_timeout_add(1000, flash_window_cb, GDK_WINDOW_HWND(window->window)); finfo->sig_handler = g_signal_connect(G_OBJECT(window), "focus-in-event", G_CALLBACK(halt_flash_filter), finfo); } }
static gboolean realize_cb_cb(PidginMediaRealizeData *data) { PidginMediaPrivate *priv = data->gtkmedia->priv; gulong window_id; #ifdef _WIN32 if (data->participant == NULL) window_id = GDK_WINDOW_HWND(priv->local_video->window); else window_id = GDK_WINDOW_HWND(priv->remote_video->window); #elif defined(HAVE_X11) if (data->participant == NULL) window_id = GDK_WINDOW_XWINDOW(priv->local_video->window); else window_id = GDK_WINDOW_XWINDOW(priv->remote_video->window); #else # error "Unsupported windowing system" #endif purple_media_set_output_window(priv->media, data->session_id, data->participant, window_id); g_free(data->session_id); g_free(data->participant); g_free(data); return FALSE; }
/** * @todo Only from a gtk drawing area ? */ glc_drawable_t * glc_gtk_drawable_create( GtkDrawingArea * drawingArea ) { assert( drawingArea != 0 && "Calls glc_gtk_drawable_create() with an null drawing area." ); // Retrieves the window of the drawing area GdkWindow *gdkWindow = GTK_WIDGET(drawingArea)->window; if( gdkWindow == 0 ) { return 0; } // gdk_window_ensure_native() available from 2.18.0 #if GTKMM_VERSION >= 2180 else { // Ensure the gdk window is a window-system native window const gboolean isNative = gdk_window_ensure_native( gdkWindow ); if ( isNative == FALSE ) { assert( false && "Unable to ensure a window-sytem native window" ); return 0; } else { #ifdef WIN32 EnableWindow( (GLC_WINDOW_HANDLE) GDK_WINDOW_HWND( gdkWindow ), FALSE ); #endif } } #endif glc_drawable_t *drawable = (glc_drawable_t*) malloc( sizeof(glc_drawable_t) ); assert( drawable != 0 && "Unable to allocate glc_drawable_t." ); // Turns off the double buffering of the widget // So clearing to the background color or pixmap will no more happen automatically. gtk_widget_set_double_buffered( GTK_WIDGET(drawingArea), FALSE ); // Initializes the drawable #ifdef WIN32 drawable->window = (GLC_WINDOW_HANDLE) GDK_WINDOW_HWND( gdkWindow ); drawable->dc = GetDC( drawable->window ); #else #error "Non win32 platform not yet supported." #endif drawable->backend = (drawable_backend_t*) malloc( sizeof(drawable_backend_t) ); drawable->backend->destroy = &glc_gtk_drawable_destroy; _glc_drawable_initialize( drawable ); // @todo glc_gtk_drawable_status() assert( drawable->window != 0 ); assert( drawable->dc != 0 ); assert( drawable->backend != 0 ); return drawable; }
gboolean xp_theme_draw (GdkWindow *win, XpThemeElement element, GtkStyle *style, int x, int y, int width, int height, GtkStateType state_type, GdkRectangle *area) { HTHEME theme; RECT rect, clip, *pClip; HDC dc; XpDCInfo dc_info; int part_state; if (!xp_theme_is_drawable (element)) return FALSE; theme = xp_theme_get_handle_by_element (element); if (!theme) return FALSE; /* FIXME: Recheck its function */ if (GDK_IS_WINDOW (win) && gdk_win32_window_is_win32 (win)) enable_theme_dialog_texture_func (GDK_WINDOW_HWND (win), ETDT_ENABLETAB); dc = get_window_dc (style, win, state_type, &dc_info, x, y, width, height, &rect); if (!dc) return FALSE; if (area) { clip.left = area->x - dc_info.x_offset; clip.top = area->y - dc_info.y_offset; clip.right = clip.left + area->width; clip.bottom = clip.top + area->height; pClip = &clip; } else { pClip = NULL; } part_state = xp_theme_map_gtk_state (element, state_type); /* Support transparency */ if (is_theme_partially_transparent_func (theme, element_part_map[element], part_state)) draw_theme_parent_background_func (GDK_WINDOW_HWND (win), dc, pClip); draw_theme_background_func (theme, dc, element_part_map[element], part_state, &rect, pClip); release_window_dc (&dc_info); return TRUE; }
void _gdk_window_move_resize_child (GdkWindow *window, gint x, gint y, gint width, gint height) { GdkWindowImplWin32 *impl; GdkWindowObject *obj; g_return_if_fail (window != NULL); g_return_if_fail (GDK_IS_WINDOW (window)); obj = GDK_WINDOW_OBJECT (window); impl = GDK_WINDOW_IMPL_WIN32 (obj->impl); GDK_NOTE (MISC, g_print ("_gdk_window_move_resize_child: %s@%+d%+d %dx%d@%+d%+d\n", _gdk_win32_drawable_description (window), obj->x, obj->y, width, height, x, y)); if (width > 65535 || height > 65535) { g_warning ("Native children wider or taller than 65535 pixels are not supported."); if (width > 65535) width = 65535; if (height > 65535) height = 65535; } obj->x = x; obj->y = y; obj->width = width; obj->height = height; _gdk_win32_window_tmp_unset_parent_bg (window); _gdk_win32_window_tmp_unset_bg (window, TRUE); GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d," "NOACTIVATE|NOZORDER)\n", GDK_WINDOW_HWND (window), obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y, width, height)); API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL, obj->x + obj->parent->abs_x, obj->y + obj->parent->abs_y, width, height, SWP_NOACTIVATE | SWP_NOZORDER)); //_gdk_win32_window_tmp_reset_parent_bg (window); _gdk_win32_window_tmp_reset_bg (window, TRUE); }
/* This function exists because GDK retrieves client coordinates, not window ones. (Kevin: GDK uses GetClientRect and ClientToScreen). We need that to save and restore windows position. */ void window_get_rect(GtkWidget *widget, GdkRect *rect) { gtk_window_get_size(GTK_WINDOW(widget), &rect->w, &rect->h); #ifdef __WIN32__ { BOOL bResult; HWND hWnd = GDK_WINDOW_HWND(widget->window); RECT lpRect; GdkRectangle gdkRect; bResult = GetWindowRect(hWnd, &lpRect); rect->x = lpRect.left; rect->y = lpRect.top; // Now obtain and add the offset between GDK and Win32 coordinates // (in the multi-screen case). gdk_screen_get_monitor_geometry(gdk_screen_get_default(), 0, &gdkRect); rect->x += gdkRect.x; rect->y += gdkRect.y; } #else gdk_window_get_position(widget->window, &rect->x, &rect->y); #endif }
void auto_lookup_start() { if(selection_mode == SELECTION_DO_NOTHING) return; #ifdef __WIN32__ if(registered == FALSE) { if(OrgWndProc == NULL){ hidden_hwnd = GDK_WINDOW_HWND (hidden_window->window); OrgWndProc = (WNDPROC)GetWindowLong(hidden_hwnd, GWL_WNDPROC); SetWindowLong(hidden_hwnd, GWL_WNDPROC, (LONG)HiddenWndProc); } next_hwnd = SetClipboardViewer(hidden_hwnd); } registered = TRUE; #else if(tag_timeout != 0) gtk_timeout_remove(tag_timeout); tag_timeout = gtk_timeout_add(auto_interval, copy_clipboard_x, NULL); #endif auto_lookup_suspended = FALSE; }
/* Set window transparency level */ static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled, gboolean always_on_top) { if (MySetLayeredWindowAttributes) { HWND hWnd = GDK_WINDOW_HWND(window->window); LONG style = GetWindowLong(hWnd, GWL_EXSTYLE); if (enabled) { style |= WS_EX_LAYERED; } else { style &= ~WS_EX_LAYERED; } SetWindowLong(hWnd, GWL_EXSTYLE, style); if (enabled) { SetWindowPos(hWnd, always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); MySetLayeredWindowAttributes(hWnd, 0, alpha, LWA_ALPHA); } else { /* Ask the window and its children to repaint */ SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); RedrawWindow(hWnd, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN); } } }
void Sys_GetCursorPos(GtkWindow* window, int *x, int *y) { POINT pos; GetCursorPos(&pos); ScreenToClient((HWND)GDK_WINDOW_HWND(GTK_WIDGET(window)->window), &pos); *x = pos.x; *y = pos.y; }
/** \brief Retrieve info from window, needed for accel layer */ void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo) { GdkWindow *win; GtkWidget *widget=(GtkWidget *)draw; win = gtk_widget_get_parent_window(widget); #ifdef __WIN32 xinfo->display = (void*)GDK_WINDOW_HWND(widget->window); #elif defined(__APPLE__) int windowWidth, windowHeight; int x, y; gdk_drawable_get_size(win, &windowWidth, &windowHeight); gdk_window_get_position(widget->window, &x, &y); xinfo->display = 0; xinfo->window = getMainNSWindow(); xinfo->x = x; xinfo->y = windowHeight - (y + lastH); xinfo->width = lastW; xinfo->height = lastH; #else xinfo->window = GDK_WINDOW_XWINDOW(widget->window); xinfo->display = GDK_WINDOW_XDISPLAY(win); #endif }
void bring_to_top(GtkWidget *win){ #ifdef __WIN32__ HWND hWnd; int nTargetID, nForegroundID; BOOL res; hWnd = GDK_WINDOW_HWND (win->window); /* From http://techtips.belution.com/ja/vc/0012/ */ nForegroundID = GetWindowThreadProcessId(GetForegroundWindow(), NULL); nTargetID = GetWindowThreadProcessId(hWnd, NULL ); AttachThreadInput(nTargetID, nForegroundID, TRUE ); // SPI_GETFOREGROUNDLOCKTIMEOUT will be undefined. Why ? /* SystemParametersInfo( SPI_GETFOREGROUNDLOCKTIMEOUT,0,&sp_time,0); SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT,0,(LPVOID)0,0); SetForegroundWindow(hWnd); SystemParametersInfo( SPI_SETFOREGROUNDLOCKTIMEOUT,0,sp_time,0); */ res = SetForegroundWindow(hWnd); AttachThreadInput(nTargetID, nForegroundID, FALSE); if(!res){ SetFocus(hWnd); } #else gdk_window_show(GTK_WIDGET(win)->window); gdk_window_focus(GTK_WIDGET(win)->window, gtk_get_current_event_time()); #endif }
/** \brief Retrieve info from window, needed for accel layer */ void UI_getWindowInfo(void *draw, GUI_WindowInfo *xinfo) { GdkWindow *win, *parentWin; GtkWidget *widget=(GtkWidget *)draw; win = gtk_widget_get_window(widget); parentWin = gtk_widget_get_parent_window(widget); #ifdef _WIN32 xinfo->display = (void*)GDK_WINDOW_HWND(win); #elif defined(__APPLE__) xinfo->display = 0; xinfo->window = getMainNSWindow(); #else xinfo->systemWindowId = GDK_WINDOW_XID(win); xinfo->display = GDK_WINDOW_XDISPLAY(parentWin); #endif int windowWidth, windowHeight; int x, y; windowWidth = gdk_window_get_width(parentWin); windowHeight = gdk_window_get_height(parentWin); gdk_window_get_position(win, &x, &y); xinfo->x = x; xinfo->y = windowHeight - (y + lastH); xinfo->width = lastW; xinfo->height = lastH; }
static VkResult gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context, VkSurfaceKHR *surface) { GdkWindow *window = gdk_draw_context_get_window (GDK_DRAW_CONTEXT (context)); GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context)); VkWin32SurfaceCreateInfoKHR info; info.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; info.pNext = NULL; info.flags = 0; info.hinstance = _gdk_dll_hinstance; info.hwnd = GDK_WINDOW_HWND (window); /* This is necessary so that Vulkan sees the Window. * Usually, vkCreateWin32SurfaceKHR() will not cause a problem to happen as * it just creates resources, but futher calls with the resulting surface * do cause issues. */ gdk_display_sync (display); return GDK_VK_CHECK (vkCreateWin32SurfaceKHR, gdk_vulkan_context_get_instance (context), &info, NULL, surface); }
void Sys_SetCursorPos(GtkWindow* window, int x, int y) { POINT pos; pos.x = x; pos.y = y; ClientToScreen((HWND)GDK_WINDOW_HWND(GTK_WIDGET(window)->window), &pos); SetCursorPos(pos.x, pos.y); }
gboolean _gdk_windowing_window_queue_antiexpose (GdkWindow *window, GdkRegion *area) { HRGN hrgn = _gdk_win32_gdkregion_to_hrgn (area, 0, 0); GDK_NOTE (EVENTS, g_print ("_gdk_windowing_window_queue_antiexpose: ValidateRgn %p %s\n", GDK_WINDOW_HWND (window), _gdk_win32_gdkregion_to_string (area))); ValidateRgn (GDK_WINDOW_HWND (window), hrgn); DeleteObject (hrgn); return FALSE; }
guint32 create_child_plug (guint32 xid, gboolean local) { GtkWidget *window; GtkWidget *content; window = gtk_plug_new (xid); g_signal_connect (window, "destroy", local ? G_CALLBACK (local_destroy) : G_CALLBACK (remote_destroy), NULL); gtk_container_set_border_width (GTK_CONTAINER (window), 0); content = create_content (GTK_WINDOW (window), local); gtk_container_add (GTK_CONTAINER (window), content); gtk_widget_show_all (window); if (GTK_WIDGET_REALIZED (window)) #if defined (GDK_WINDOWING_X11) return GDK_WINDOW_XID (window->window); #elif defined (GDK_WINDOWING_WIN32) return (guint32) GDK_WINDOW_HWND (window->window); #endif else return 0;
char* iupgtkGetNativeWindowHandle(Ihandle* ih) { GdkWindow* window = ih->handle->window; if (window) return (char*)GDK_WINDOW_HWND(window); else return NULL; }
static void widget_on_realize(GtkWidget *widget, gpointer user_data) { GtkVlcPlayer *player = GTK_VLC_PLAYER(user_data); GdkWindow *window = gtk_widget_get_window(widget); libvlc_media_player_set_hwnd(player->priv->media_player, GDK_WINDOW_HWND(window)); }
void GdkWinSetAlpha(GdkWindow *win){ HWND hWnd; DWORD dwExStyle; hWnd = GDK_WINDOW_HWND(win); dwExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); if(!(dwExStyle&WS_EX_LAYERED)){ SetWindowLong(hWnd, GWL_EXSTYLE, dwExStyle|WS_EX_LAYERED); } }
static unsigned long get_native_handle(GdkWindow *gdkw) { #ifdef GDK_WINDOWING_X11 return (unsigned long)GDK_WINDOW_XID(gdkw); #elif defined(WIN32) return (unsigned long)GDK_WINDOW_HWND(gdkw); #elif defined(__APPLE__) return (unsigned long)gdk_quartz_window_get_nsview(gdkw); #endif g_warning("No way to get the native handle from gdk window"); return 0; }
void show_help(const gchar *section) { #ifdef _WIN32 // You may translate it as "%s\\help\\stardict-zh_CN.chm" when this file available. gchar *filename = g_strdup_printf(_("%s\\help\\stardict.chm"), gStarDictDataDir.c_str()); ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->window->window)), "OPEN", filename, NULL, NULL, SW_SHOWNORMAL); g_free(filename); #elif defined(CONFIG_GNOME) gnome_help_display ("stardict.xml", section, NULL); #endif }
/** * @brief Callback for polling the availability of a libVLC event window. * * If found, it is disabled and the polling stops. This results in mouse click * events being delivered to the GtkDrawingArea widget. * * @param data User data (\e GtkVlcPlayer widget) * @return \c TRUE to continue polling, \c FALSE to stop */ static gboolean poll_vlc_event_window_cb(gpointer data) { GtkWidget *drawing_area = gtk_bin_get_child(GTK_BIN(data)); GdkWindow *window = gtk_widget_get_window(drawing_area); gboolean ret = TRUE; EnumChildWindows(GDK_WINDOW_HWND(window), enumerate_vlc_windows_cb, (LPARAM)&ret); return ret; }
static void gtkFileDlgPreviewRealize(GtkWidget *widget, Ihandle *ih) { iupAttribSetStr(ih, "PREVIEWDC", iupgtkGetNativeGraphicsContext(widget)); iupAttribSetStr(ih, "WID", (char*)widget); #ifdef WIN32 iupAttribSetStr(ih, "HWND", (char*)GDK_WINDOW_HWND(widget->window)); #else iupAttribSetStr(ih, "XWINDOW", (char*)GDK_WINDOW_XID(widget->window)); iupAttribSetStr(ih, "XDISPLAY", (char*)iupdrvGetDisplay()); #endif gtkFileDlgUpdatePreviewGLCanvas(ih); }
static GdkGrabStatus gdk_device_win32_grab (GdkDevice *device, GdkWindow *window, gboolean owner_events, GdkEventMask event_mask, GdkWindow *confine_to, GdkCursor *cursor, guint32 time_) { if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD) SetCapture (GDK_WINDOW_HWND (window)); return GDK_GRAB_SUCCESS; }
/***************************************************** * Hack ahead !!! * * Problems here have to do with focus handling, i.e. * sharing and passing keyboard focus back and forth from * the gecko window to the rest of the app. The gecko * wants us to turn focus on and off when we receive the * WM_ACTIVATE message for our window; Gtk+ does not give * us an opportunity to act on this message (TODO: patch * gtk+ to do so and run tests). * * Also tried to turn on and off focus near when activate * messages come (i.e. focus in/out of the toplevel window) * with no luck (works to get started, but the gecko * will never relinquish focus afterwords). * * The current hack/workaround: * We are using a native toplevel window, that we reposition * to follow the widget hierarchy on toplevel configure events, * this way we handle the WM_ACTIVATE messages and focus handleing * works, on the other hand accelerators keys tied into the higher * level window wont trigger when the gecko has focus (is that * already the case ?) and the apps toplevel will be painted as * an inactive window. */ static HWND create_native_window(GtkWidget *widget) { static ATOM klass = 0; HWND window_handle, parent_handle; DWORD dwStyle, dwExStyle; if (!klass) { static WNDCLASSEXW wcl; wcl.cbSize = sizeof(WNDCLASSEX); wcl.style = 0; /* DON'T set CS_<H,V>REDRAW. It causes total redraw * on WM_SIZE and WM_MOVE. Flicker, Performance! */ wcl.lpfnWndProc = (WNDPROC)window_procedure; wcl.cbClsExtra = 0; wcl.cbWndExtra = 0; wcl.hInstance = GetModuleHandle(NULL); wcl.hIcon = 0; wcl.hIconSm = 0; wcl.lpszMenuName = NULL; wcl.hIcon = NULL; wcl.hIconSm = NULL; wcl.hbrBackground = NULL; wcl.hCursor = LoadCursor(NULL, IDC_ARROW); wcl.lpszClassName = L"MozWindow"; klass = RegisterClassExW(&wcl); } dwExStyle = WS_EX_TOOLWINDOW; // for popup windows dwStyle = WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; // popup window parent_handle = (HWND)GDK_WINDOW_HWND(gtk_widget_get_parent_window(widget)); window_handle = CreateWindowExW(dwExStyle, MAKEINTRESOURCEW(klass), L"", dwStyle, 0, 0, 1, 1, parent_handle, NULL, GetModuleHandle(NULL), NULL); SetProp(window_handle, "moz-view-widget", (HANDLE)widget); return window_handle; }
void GdkWinChangeAlphaFG(GdkWindow *win, GdkColor *col){ HWND hWnd; DWORD dwExStyle; hWnd = GDK_WINDOW_HWND(win); dwExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); if(!(dwExStyle&WS_EX_LAYERED)){ SetWindowLong(hWnd, GWL_EXSTYLE, dwExStyle|WS_EX_LAYERED); } SetLayeredWindowAttributes(hWnd, RGB(col->red/0x100,col->green/0x100,col->blue/0x100), 0, LWA_COLORKEY); }
guintptr gst_get_window_handle(GdkWindow *window) { guintptr window_handle; /* Retrieve window handler from GDK */ #if defined (GDK_WINDOWING_WIN32) window_handle = (guintptr)GDK_WINDOW_HWND (window); #elif defined (GDK_WINDOWING_QUARTZ) window_handle = gdk_quartz_window_get_nsview (window); #elif defined (GDK_WINDOWING_X11) window_handle = GDK_WINDOW_XID (window); #endif return window_handle; }
void show_url(const char *url) { if (!url) return; #ifdef _WIN32 ShellExecute((HWND)(GDK_WINDOW_HWND(gpAppFrame->window->window)), "OPEN", url, NULL, NULL, SW_SHOWNORMAL); #elif defined(CONFIG_GNOME) gnome_url_show(url, NULL); #elif defined(CONFIG_GPE) gchar *command = g_strdup_printf("gpe-mini-browser %s", url); system(command); g_free(command); #else spawn_command("firefox", url); #endif }
/* This function is called when the GUI toolkit creates the physical window that will hold the video. * At this point we can retrieve its handler (which has a different meaning depending on the windowing system) * and pass it to GStreamer through the XOverlay interface. */ static void realize_cb (GtkWidget *widget, CustomData *data) { GdkWindow *window = gtk_widget_get_window (widget); guintptr window_handle; if (!gdk_window_ensure_native (window)) g_error ("Couldn't create native window needed for GstXOverlay!"); /* Retrieve window handler from GDK */ #if defined (GDK_WINDOWING_WIN32) window_handle = (guintptr)GDK_WINDOW_HWND (window); #elif defined (GDK_WINDOWING_QUARTZ) window_handle = gdk_quartz_window_get_nsview (window); #elif defined (GDK_WINDOWING_X11) window_handle = GDK_WINDOW_XID (window); #endif /* Pass it to playbin, which implements XOverlay and will forward it to the video sink */ gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (data->playbin), window_handle); }
void auto_lookup_stop() { #ifdef __WIN32__ if(registered == TRUE) { hidden_hwnd = GDK_WINDOW_HWND (hidden_window->window); ChangeClipboardChain(hidden_hwnd, next_hwnd); next_hwnd = NULL; registered = FALSE; } #else if(tag_timeout != 0) gtk_timeout_remove(tag_timeout); tag_timeout = 0; #endif auto_lookup_suspended = FALSE; }