static VALUE rg_handle(VALUE self) { HGDIOBJ handle; handle = gdk_win32_drawable_get_handle(_SELF(self)); return ULONG2NUM(GPOINTER_TO_UINT(handle)); }
void win32_init_win(GtkWidget *win) { HWND handle=(HWND)gdk_win32_drawable_get_handle(win->window); ShowWindow(handle, SW_HIDE); SetWindowLong(handle, GWL_EXSTYLE, WS_EX_NOACTIVATE|WS_EX_TOPMOST); SetWindowPos(handle, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED); // ShowWindow(handle, SW_SHOW); }
void set_win_pos_size(GtkWidget *win, int x, int y, int xl, int yl) { dbg("set_win_size %d,%d %d %d\n", x, y, xl, yl); HWND hwnd=(HWND)gdk_win32_drawable_get_handle(win->window); #if 1 SetWindowPos(hwnd, HWND_TOP, x + dpy_x_ofs, y + dpy_y_ofs, xl, yl, SWP_SHOWWINDOW); #else MoveWindow(hwnd, x, y, xl, yl, false); #endif }
gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpointer data) { gint fd, sock; gchar buf[BUFFER_LENGTH]; gchar *command = NULL; struct sockaddr_in caddr; socklen_t caddr_len = sizeof(caddr); GtkWidget *window = data; gboolean popup = FALSE; fd = g_io_channel_unix_get_fd(source); sock = accept(fd, (struct sockaddr *)&caddr, &caddr_len); /* first get the command */ while (socket_fd_gets(sock, buf, sizeof(buf)) != -1) { command = g_strdup(buf); geany_debug("Received IPC command from remote instance: %s", g_strstrip(command)); g_free(command); if (strncmp(buf, "open", 4) == 0) { cl_options.readonly = strncmp(buf+4, "ro", 2) == 0; /* open in readonly? */ while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.') { gsize buf_len = strlen(buf); /* remove trailing newline */ if (buf_len > 0 && buf[buf_len - 1] == '\n') buf[buf_len - 1] = '\0'; handle_input_filename(buf); } popup = TRUE; } else if (strncmp(buf, "doclist", 7) == 0) { gchar *doc_list = build_document_list(); if (!EMPTY(doc_list)) socket_fd_write_all(sock, doc_list, strlen(doc_list)); /* send ETX (end-of-text) so reader knows to stop reading */ socket_fd_write_all(sock, "\3", 1); g_free(doc_list); } else if (strncmp(buf, "line", 4) == 0) { while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.') { g_strstrip(buf); /* remove \n char */ /* on any error we get 0 which should be safe enough as fallback */ cl_options.goto_line = atoi(buf); } } else if (strncmp(buf, "column", 6) == 0) { while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.') { g_strstrip(buf); /* remove \n char */ /* on any error we get 0 which should be safe enough as fallback */ cl_options.goto_column = atoi(buf); } } #ifdef G_OS_WIN32 else if (strncmp(buf, "window", 6) == 0) { # if GTK_CHECK_VERSION(3, 0, 0) HWND hwnd = (HWND) gdk_win32_window_get_handle(gtk_widget_get_window(window)); # else HWND hwnd = (HWND) gdk_win32_drawable_get_handle( GDK_DRAWABLE(gtk_widget_get_window(window))); # endif socket_fd_write(sock, (gchar *)&hwnd, sizeof(hwnd)); } #endif } if (popup) { #ifdef GDK_WINDOWING_X11 GdkWindow *x11_window = gtk_widget_get_window(window); /* Set the proper interaction time on the window. This seems necessary to make * gtk_window_present() really bring the main window into the foreground on some * window managers like Gnome's metacity. * Code taken from Gedit. */ # if GTK_CHECK_VERSION(3, 0, 0) if (GDK_IS_X11_WINDOW(x11_window)) # endif { gdk_x11_window_set_user_time(x11_window, gdk_x11_get_server_time(x11_window)); } #endif gtk_window_present(GTK_WINDOW(window)); #ifdef G_OS_WIN32 gdk_window_show(gtk_widget_get_window(window)); #endif } socket_fd_close(sock); return TRUE; }
gboolean socket_lock_input_cb(GIOChannel *source, GIOCondition condition, gpointer data) { gint fd, sock; gchar buf[BUFFER_LENGTH]; struct sockaddr_in caddr; socklen_t caddr_len = sizeof(caddr); GtkWidget *window = data; gboolean popup = FALSE; fd = g_io_channel_unix_get_fd(source); sock = accept(fd, (struct sockaddr *)&caddr, &caddr_len); /* first get the command */ while (socket_fd_gets(sock, buf, sizeof(buf)) != -1) { if (strncmp(buf, "open", 4) == 0) { cl_options.readonly = strncmp(buf+4, "ro", 2) == 0; /* open in readonly? */ while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.') { handle_input_filename(g_strstrip(buf)); } popup = TRUE; } else if (strncmp(buf, "doclist", 7) == 0) { gchar *doc_list = build_document_list(); if (NZV(doc_list)) socket_fd_write_all(sock, doc_list, strlen(doc_list)); else /* send ETX (end-of-text) in case we have no open files, we must send anything * otherwise the client would hang on reading */ socket_fd_write_all(sock, "\3", 1); g_free(doc_list); } else if (strncmp(buf, "line", 4) == 0) { while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.') { g_strstrip(buf); /* remove \n char */ /* on any error we get 0 which should be safe enough as fallback */ cl_options.goto_line = atoi(buf); } } else if (strncmp(buf, "column", 6) == 0) { while (socket_fd_gets(sock, buf, sizeof(buf)) != -1 && *buf != '.') { g_strstrip(buf); /* remove \n char */ /* on any error we get 0 which should be safe enough as fallback */ cl_options.goto_column = atoi(buf); } } #ifdef G_OS_WIN32 else if (strncmp(buf, "window", 6) == 0) { HWND hwnd = (HWND) gdk_win32_drawable_get_handle( GDK_DRAWABLE(gtk_widget_get_window(window))); socket_fd_write(sock, (gchar *)&hwnd, sizeof(hwnd)); } #endif } if (popup) { #ifdef GDK_WINDOWING_X11 /* Set the proper interaction time on the window. This seems necessary to make * gtk_window_present() really bring the main window into the foreground on some * window managers like Gnome's metacity. * Code taken from Gedit. */ gdk_x11_window_set_user_time(gtk_widget_get_window(window), gdk_x11_get_server_time(gtk_widget_get_window(window))); #endif gtk_window_present(GTK_WINDOW(window)); #ifdef G_OS_WIN32 gdk_window_show(gtk_widget_get_window(window)); #endif } socket_fd_close(sock); return TRUE; }
/* * attrib_list is currently unused. This must be set to NULL or empty * (first attribute of None). See GLX 1.3 spec. */ GdkGLPixmap * gdk_gl_pixmap_new (GdkGLConfig *glconfig, GdkPixmap *pixmap, const int *attrib_list) { GdkGLPixmap *glpixmap; GdkGLPixmapImplWin32 *impl; gint width, height; gint depth; GdkPixmap *pixmap_gl = NULL; HBITMAP hbitmap_gl; HDC hdc_gl = NULL; PIXELFORMATDESCRIPTOR pfd; int pixel_format; HBITMAP hbitmap_gdk; HDC hdc_gdk = NULL; GDK_GL_NOTE_FUNC (); g_return_val_if_fail (GDK_IS_GL_CONFIG_IMPL_WIN32 (glconfig), NULL); g_return_val_if_fail (GDK_IS_PIXMAP (pixmap), NULL); /* * Create offscreen rendering area. */ gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &width, &height); depth = gdk_drawable_get_depth (GDK_DRAWABLE (pixmap)); pixmap_gl = gdk_pixmap_new (NULL, width, height, depth); if (pixmap_gl == NULL) goto FAIL; /* * Source (OpenGL) DIB */ hbitmap_gl = (HBITMAP) gdk_win32_drawable_get_handle (GDK_DRAWABLE (pixmap_gl)); /* Create a memory DC. */ hdc_gl = CreateCompatibleDC (NULL); if (hdc_gl == NULL) { g_warning ("cannot create a memory DC"); goto FAIL; } /* Select the bitmap. */ if (SelectObject (hdc_gl, hbitmap_gl) == NULL) { g_warning ("cannot select DIB"); goto FAIL; } /* * Choose pixel format. */ pfd = *(GDK_GL_CONFIG_PFD (glconfig)); /* Draw to bitmap */ pfd.dwFlags &= ~PFD_DRAW_TO_WINDOW; pfd.dwFlags |= PFD_DRAW_TO_BITMAP; /* Request pfd.cColorBits should exclude alpha bitplanes. */ pfd.cColorBits = pfd.cRedBits + pfd.cGreenBits + pfd.cBlueBits; GDK_GL_NOTE_FUNC_IMPL ("ChoosePixelFormat"); pixel_format = ChoosePixelFormat (hdc_gl, &pfd); if (pixel_format == 0) { g_warning ("cannot choose pixel format"); goto FAIL; } /* * Set pixel format. */ GDK_GL_NOTE_FUNC_IMPL ("SetPixelFormat"); if (!SetPixelFormat (hdc_gl, pixel_format, &pfd)) { g_warning ("cannot set pixel format"); goto FAIL; } DescribePixelFormat (hdc_gl, pixel_format, sizeof (pfd), &pfd); GDK_GL_NOTE (MISC, g_message (" -- impl->pixel_format = 0x%x", pixel_format)); GDK_GL_NOTE (MISC, _gdk_win32_gl_print_pfd (&pfd)); /* * Destination (GDK) DIB */ hbitmap_gdk = (HBITMAP) gdk_win32_drawable_get_handle (GDK_DRAWABLE (pixmap)); /* Create a memory DC. */ hdc_gdk = CreateCompatibleDC (hdc_gl); if (hdc_gdk == NULL) { g_warning ("cannot create a memory DC"); goto FAIL; } /* * Instantiate the GdkGLPixmapImplWin32 object. */ glpixmap = g_object_new (GDK_TYPE_GL_PIXMAP_IMPL_WIN32, NULL); impl = GDK_GL_PIXMAP_IMPL_WIN32 (glpixmap); glpixmap->drawable = GDK_DRAWABLE (pixmap); g_object_add_weak_pointer (G_OBJECT (glpixmap->drawable), (gpointer *) &(glpixmap->drawable)); impl->pixmap_gl = pixmap_gl; impl->width = width; impl->height = height; impl->pfd = pfd; impl->pixel_format = pixel_format; impl->glconfig = glconfig; g_object_ref (G_OBJECT (impl->glconfig)); impl->hdc_gl = hdc_gl; impl->hdc_gdk = hdc_gdk; impl->hbitmap_gdk = hbitmap_gdk; impl->is_destroyed = FALSE; return glpixmap; FAIL: if (hdc_gdk != NULL) DeleteDC (hdc_gdk); if (hdc_gl != NULL) DeleteDC (hdc_gl); if (pixmap_gl != NULL) g_object_unref (G_OBJECT (pixmap_gl)); return NULL; }
HICON pixmap_to_hicon (GdkPixmap *pixmap, GdkBitmap *mask) { ICONINFO ii; HICON hIcon; gint w = 0, h = 0; HANDLE hpixmap = NULL; HBITMAP hbitmap = NULL; /* Create Drawing Context */ HDC hdc1 = NULL; HBITMAP hbitmaptmp1 = NULL; if (!pixmap) { return NULL; } gdk_drawable_get_size (GDK_DRAWABLE (pixmap), &w, &h); hpixmap = gdk_win32_drawable_get_handle (pixmap); /* we need the inverted mask for the XOR op */ hdc1 = CreateCompatibleDC (NULL); hbitmap = CreateCompatibleBitmap (hdc1, w, h); hbitmaptmp1 = SelectObject (hdc1, hbitmap); if (mask) { HANDLE hmask = NULL; HDC hdc2 = NULL; HBITMAP hbitmaptmp2 = NULL; hmask = gdk_win32_drawable_get_handle (mask); hdc2 = CreateCompatibleDC (NULL); hbitmaptmp2 = SelectObject (hdc2, hmask); BitBlt (hdc1, 0,0,w,h, hdc2, 0,0, NOTSRCCOPY); SelectObject (hdc2, hbitmaptmp2); DeleteDC (hdc2); } else { RECT rect; GetClipBox (hdc1, &rect); FillRect (hdc1, &rect, GetStockObject (WHITE_BRUSH)); } SelectObject (hdc1, hbitmaptmp1); DeleteDC (hdc1); ii.fIcon = TRUE; ii.xHotspot = ii.yHotspot = 0; /* ignored for icons */ ii.hbmMask = hbitmap; ii.hbmColor = hpixmap; hIcon = CreateIconIndirect (&ii); if (!hIcon) { return NULL; } DeleteObject (hbitmap); return hIcon; }
/***f* socket/staticFuncs/socketFunc * AUTHOR * PGB * SOURCE */ static int socketFunc ( ClientData data, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) { const char *cmds[] = { "delete", "configure", "getID", "getPlugID", NULL }; enum cmdIdx { DeleteIdx, ConfigureIdx, GetIDIdx, GetPlugIDIdx }; int idx; GtkSocket *socket = GTK_SOCKET ( data ); if ( objc < 2 ) { Tcl_WrongNumArgs ( interp, 1, objv, "command" ); return TCL_ERROR; } if ( Tcl_GetIndexFromObj ( interp, objv[1], cmds, "command", TCL_EXACT, &idx ) != TCL_OK ) return TCL_ERROR; switch ( idx ) { case DeleteIdx: return gnoclDelete ( interp, GTK_WIDGET ( socket ), objc, objv ); case ConfigureIdx: { int ret = TCL_ERROR; if ( gnoclParseAndSetOptions ( interp, objc - 1, objv + 1, socketOptions, G_OBJECT ( socket ) ) == TCL_OK ) { ret = configure ( interp, socket, socketOptions ); } gnoclClearOptions ( socketOptions ); return ret; } break; case GetIDIdx: { long xid; Tcl_Obj *val; if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } #ifdef WIN32 xid = gtk_socket_get_id(socket); #else xid = GDK_WINDOW_XWINDOW ( GTK_WIDGET ( socket )->window ); #endif val = Tcl_NewLongObj ( xid ); Tcl_SetObjResult ( interp, val ); } break; case GetPlugIDIdx: { long xid = 0; Tcl_Obj *val; if ( objc != 2 ) { Tcl_WrongNumArgs ( interp, 2, objv, NULL ); return TCL_ERROR; } if ( socket->plug_window ) #ifdef WIN32 xid = gdk_win32_drawable_get_handle( socket->plug_window ); #else xid = GDK_WINDOW_XWINDOW ( socket->plug_window ); #endif val = Tcl_NewLongObj ( xid ); Tcl_SetObjResult ( interp, val ); } break; } return TCL_OK; }