Example #1
0
void
_gdk_win32_window_tmp_unset_bg (GdkWindow *window,
				gboolean recurse)
{
  g_return_if_fail (GDK_IS_WINDOW (window));

  if (window->input_only || window->destroyed ||
      (window->window_type != GDK_WINDOW_ROOT &&
       !GDK_WINDOW_IS_MAPPED (window)))
    return;

  if (_gdk_window_has_impl (window) &&
      GDK_WINDOW_IS_WIN32 (window) &&
      window->window_type != GDK_WINDOW_ROOT &&
      window->window_type != GDK_WINDOW_FOREIGN)
    tmp_unset_bg (window);

  if (recurse)
    {
      GList *l;

      for (l = window->children; l != NULL; l = l->next)
	_gdk_win32_window_tmp_unset_bg (l->data, TRUE);
    }
}
Example #2
0
gboolean
_gdk_x11_window_simulate_button (GdkWindow      *window,
                                 gint            x,
                                 gint            y,
                                 guint           button, /*1..3*/
                                 GdkModifierType modifiers,
                                 GdkEventType    button_pressrelease)
{
    GdkScreen *screen;
    XButtonEvent xev = {
        0,  /* type */
        0,  /* serial */
        1,  /* send_event */
    };
    gboolean success;

    g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE);
    g_return_val_if_fail (window != NULL, FALSE);

    if (!GDK_WINDOW_IS_MAPPED (window))
        return FALSE;

    screen = gdk_window_get_screen (window);

    if (x < 0 && y < 0)
    {
        x = window->width / 2;
        y = window->height / 2;
    }

    /* Convert to impl coordinates */
    x = x + window->abs_x;
    y = y + window->abs_y;

    xev.type = button_pressrelease == GDK_BUTTON_PRESS ? ButtonPress : ButtonRelease;
    xev.display = GDK_WINDOW_XDISPLAY (window);
    xev.window = GDK_WINDOW_XID (window);
    xev.root = RootWindow (xev.display, GDK_X11_SCREEN (screen)->screen_num);
    xev.subwindow = 0;
    xev.time = 0;
    xev.x = x;
    xev.y = y;
    xev.x_root = 0;
    xev.y_root = 0;
    xev.state = modifiers;
    xev.button = button;
    gdk_x11_display_error_trap_push (GDK_WINDOW_DISPLAY (window));
    xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
                      xev.x, xev.y, &xev.x_root, &xev.y_root,
                      &xev.subwindow);
    if (!xev.subwindow)
        xev.subwindow = xev.window;
    success = xev.same_screen;
    success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
    success &= 0 != XSendEvent (xev.display, xev.window, True, button_pressrelease == GDK_BUTTON_PRESS ? ButtonPressMask : ButtonReleaseMask, (XEvent*) &xev);
    XSync (xev.display, False);
    success &= 0 == gdk_x11_display_error_trap_pop(GDK_WINDOW_DISPLAY (window));
    return success;
}
Example #3
0
gboolean
_gdk_broadway_window_simulate_button (GdkWindow      *window,
				      gint            x,
				      gint            y,
				      guint           button, /*1..3*/
				      GdkModifierType modifiers,
				      GdkEventType    button_pressrelease)
{
  g_return_val_if_fail (button_pressrelease == GDK_BUTTON_PRESS || button_pressrelease == GDK_BUTTON_RELEASE, FALSE);
  g_return_val_if_fail (window != NULL, FALSE);

  if (!GDK_WINDOW_IS_MAPPED (window))
    return FALSE;

  /* FIXME: Implement. */

  return FALSE;
}
Example #4
0
gboolean
_gdk_broadway_window_simulate_key (GdkWindow      *window,
				   gint            x,
				   gint            y,
				   guint           keyval,
				   GdkModifierType modifiers,
				   GdkEventType    key_pressrelease)
{
  g_return_val_if_fail (key_pressrelease == GDK_KEY_PRESS || key_pressrelease == GDK_KEY_RELEASE, FALSE);
  g_return_val_if_fail (window != NULL, FALSE);

  if (!GDK_WINDOW_IS_MAPPED (window))
    return FALSE;

  /* FIXME: Implement. */

  return FALSE;
}
Example #5
0
static void
gdk_window_postmove (GdkWindow          *window,
		     GdkWindowParentPos *parent_pos,
		     gboolean	         anti_scroll)
{
  GdkWindowImplWin32 *impl;
  GdkWindowObject *obj;
  GdkWin32PositionInfo new_info;
  GList *tmp_list;
  gint d_xoffset, d_yoffset;
  GdkWindowParentPos this_pos;
  GdkRegion *new_clip_region;

  obj = (GdkWindowObject *) window;
  impl = GDK_WINDOW_IMPL_WIN32 (obj->impl);
  
  gdk_window_compute_position (impl, parent_pos, &new_info);

  new_clip_region =
    gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);

  this_pos.x = parent_pos->x + obj->x;
  this_pos.y = parent_pos->y + obj->y;
  this_pos.win32_x = parent_pos->win32_x + new_info.x;
  this_pos.win32_y = parent_pos->win32_y + new_info.y;
  this_pos.clip_rect = new_info.clip_rect;

  if (impl->position_info.mapped && !new_info.mapped)
    ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);

  d_xoffset = new_info.x_offset - impl->position_info.x_offset;
  d_yoffset = new_info.y_offset - impl->position_info.y_offset;
  
  if (anti_scroll || (anti_scroll = d_xoffset != 0 || d_yoffset != 0))
    {
      GDK_NOTE (MISC, g_print ("gdk_window_postmove: %s@%+d%+d\n"
			       "... SetWindowPos(%p,NULL,%d,%d,0,0,"
			       "NOREDRAW|NOZORDER|NOACTIVATE|NOSIZE)\n",
			       _gdk_win32_drawable_description (window),
			       obj->x, obj->y,
			       GDK_WINDOW_HWND (window),
			       new_info.x, new_info.y));

      API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
			       new_info.x, new_info.y, 
			       0, 0,
			       SWP_NOREDRAW | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE));
    }

  if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj))
    ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA);

  if (impl->position_info.no_bg)
    gdk_window_tmp_reset_bg (window);

  impl->position_info = new_info;

  if (new_clip_region)
    gdk_window_post_scroll (window, new_clip_region);

  tmp_list = obj->children;
  while (tmp_list)
    {
      gdk_window_postmove (tmp_list->data, &this_pos, anti_scroll);
      tmp_list = tmp_list->next;
    }
}
Example #6
0
void
_gdk_window_move_resize_child (GdkWindow *window,
			       gint       x,
			       gint       y,
			       gint       width,
			       gint       height)
{
  GdkWindowImplWin32 *impl;
  GdkWindowObject *obj;
  GdkWin32PositionInfo new_info;
  GdkWindowParentPos parent_pos;
  GList *tmp_list;
  gint d_xoffset, d_yoffset;
  gint dx, dy;
  gboolean is_move;
  gboolean is_resize;
  GdkRegion *new_clip_region;
  
  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));

  dx = x - obj->x;
  dy = y - obj->y;
  
  is_move = dx != 0 || dy != 0;
  is_resize = impl->width != width || impl->height != height;

  if (!is_move && !is_resize)
    {
      GDK_NOTE (MISC, g_print ("... neither move or resize\n"));
      return;
    }
  
  GDK_NOTE (MISC, g_print ("... %s%s\n",
			   is_move ? "is_move " : "",
			   is_resize ? "is_resize" : ""));

  obj->x = x;
  obj->y = y;
  impl->width = width;
  impl->height = height;

  gdk_window_compute_parent_pos (impl, &parent_pos);
  gdk_window_compute_position (impl, &parent_pos, &new_info);

  new_clip_region =
    gdk_window_clip_changed (window, &impl->position_info.clip_rect, &new_info.clip_rect);

  parent_pos.x += obj->x;
  parent_pos.y += obj->y;
  parent_pos.win32_x += new_info.x;
  parent_pos.win32_y += new_info.y;
  parent_pos.clip_rect = new_info.clip_rect;

  d_xoffset = new_info.x_offset - impl->position_info.x_offset;
  d_yoffset = new_info.y_offset - impl->position_info.y_offset;
  
  if (d_xoffset != 0 || d_yoffset != 0)
    {
      GDK_NOTE (MISC, g_print ("... d_offset=%+d%+d\n", d_xoffset, d_yoffset));

      if (!ScrollWindowEx (GDK_WINDOW_HWND (window),
			   -d_xoffset, -d_yoffset, /* in: scroll offsets */
			   NULL, /* in: scroll rect, NULL == entire client area */
			   NULL, /* in: restrict to */
			   NULL, /* in: update region */
			   NULL, /* out: update rect */
			   SW_SCROLLCHILDREN))
	WIN32_API_FAILED ("ScrollWindowEx");

      if (dx != d_xoffset || dy != d_yoffset || is_resize)
	{
	  GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
				   "NOACTIVATE|NOZORDER%s%s)\n",
				   GDK_WINDOW_HWND (window),
				   new_info.x, new_info.y, 
				   new_info.width, new_info.height,
				   (is_move ? "" : "|NOMOVE"),
				   (is_resize ? "" : "|NOSIZE")));

	  API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
				   new_info.x, new_info.y, 
				   new_info.width, new_info.height,
				   SWP_NOACTIVATE | SWP_NOZORDER | 
				   (is_move ? 0 : SWP_NOMOVE) |
				   (is_resize ? 0 : SWP_NOSIZE)));
	}

      if (impl->position_info.no_bg)
	gdk_window_tmp_reset_bg (window);

      if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj))
	{
	  GDK_NOTE (MISC, g_print ("... ShowWindow(%p, SW_SHOWNA)\n",
				   GDK_WINDOW_HWND (window)));
	  ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA);
	}

      impl->position_info = new_info;
      
      tmp_list = obj->children;
      while (tmp_list)
	{
	  gdk_window_postmove (tmp_list->data, &parent_pos, FALSE);
	  tmp_list = tmp_list->next;
	}
    }
  else
    {
      if (impl->position_info.mapped && !new_info.mapped)
	{
	  GDK_NOTE (MISC, g_print ("... ShowWindow(%p, SW_HIDE)\n",
				   GDK_WINDOW_HWND (window)));
	  ShowWindow (GDK_WINDOW_HWND (window), SW_HIDE);
	}
      
      GDK_NOTE (MISC, g_print ("... SetWindowPos(%p,NULL,%d,%d,%d,%d,"
			       "NOACTIVATE|NOZORDER%s%s)\n",
			       GDK_WINDOW_HWND (window),
			       new_info.x, new_info.y, 
			       new_info.width, new_info.height,
			       (is_move ? "" : "|NOMOVE"),
			       (is_resize ? "" : "|NOSIZE")));

      API_CALL (SetWindowPos, (GDK_WINDOW_HWND (window), NULL,
			       new_info.x, new_info.y, 
			       new_info.width, new_info.height,
			       SWP_NOACTIVATE | SWP_NOZORDER | 
			       (is_move ? 0 : SWP_NOMOVE) |
			       (is_resize ? 0 : SWP_NOSIZE)));

      tmp_list = obj->children;
      while (tmp_list)
	{
	  gdk_window_postmove (tmp_list->data, &parent_pos, FALSE);
	  tmp_list = tmp_list->next;
	}

      if (impl->position_info.no_bg)
	gdk_window_tmp_reset_bg (window);

      if (!impl->position_info.mapped && new_info.mapped && GDK_WINDOW_IS_MAPPED (obj))
	{
	  GDK_NOTE (MISC, g_print ("... ShowWindow(%p, SW_SHOWNA)\n",
				   GDK_WINDOW_HWND (window)));
	  ShowWindow (GDK_WINDOW_HWND (window), SW_SHOWNA);
	}

      impl->position_info = new_info;
    }
  if (new_clip_region)
    gdk_window_post_scroll (window, new_clip_region);
}
Example #7
0
gboolean
_gdk_x11_window_simulate_key (GdkWindow      *window,
                              gint            x,
                              gint            y,
                              guint           keyval,
                              GdkModifierType modifiers,
                              GdkEventType    key_pressrelease)
{
    GdkScreen *screen;
    GdkKeymapKey *keys = NULL;
    gboolean success;
    gint n_keys = 0;
    XKeyEvent xev = {
        0,  /* type */
        0,  /* serial */
        1,  /* send_event */
    };
    g_return_val_if_fail (key_pressrelease == GDK_KEY_PRESS || key_pressrelease == GDK_KEY_RELEASE, FALSE);
    g_return_val_if_fail (window != NULL, FALSE);
    if (!GDK_WINDOW_IS_MAPPED (window))
        return FALSE;

    screen = gdk_window_get_screen (window);

    if (x < 0 && y < 0)
    {
        x = window->width / 2;
        y = window->height / 2;
    }

    /* Convert to impl coordinates */
    x = x + window->abs_x;
    y = y + window->abs_y;

    xev.type = key_pressrelease == GDK_KEY_PRESS ? KeyPress : KeyRelease;
    xev.display = GDK_WINDOW_XDISPLAY (window);
    xev.window = GDK_WINDOW_XID (window);
    xev.root = RootWindow (xev.display, GDK_X11_SCREEN (screen)->screen_num);
    xev.subwindow = 0;
    xev.time = 0;
    xev.x = MAX (x, 0);
    xev.y = MAX (y, 0);
    xev.x_root = 0;
    xev.y_root = 0;
    xev.state = modifiers;
    xev.keycode = 0;
    success = gdk_keymap_get_entries_for_keyval (gdk_keymap_get_for_display (gdk_window_get_display (window)), keyval, &keys, &n_keys);
    success &= n_keys > 0;
    if (success)
    {
        gint i;
        for (i = 0; i < n_keys; i++)
            if (keys[i].group == 0 && (keys[i].level == 0 || keys[i].level == 1))
            {
                xev.keycode = keys[i].keycode;
                if (keys[i].level == 1)
                {
                    /* Assume shift takes us to level 1 */
                    xev.state |= GDK_SHIFT_MASK;
                }
                break;
            }
        if (i >= n_keys) /* no match for group==0 and level==0 or 1 */
            xev.keycode = keys[0].keycode;
    }
    g_free (keys);
    if (!success)
        return FALSE;
    gdk_x11_display_error_trap_push (GDK_WINDOW_DISPLAY (window));
    xev.same_screen = XTranslateCoordinates (xev.display, xev.window, xev.root,
                      xev.x, xev.y, &xev.x_root, &xev.y_root,
                      &xev.subwindow);
    if (!xev.subwindow)
        xev.subwindow = xev.window;
    success &= xev.same_screen;
    if (x >= 0 && y >= 0)
        success &= 0 != XWarpPointer (xev.display, None, xev.window, 0, 0, 0, 0, xev.x, xev.y);
    success &= 0 != XSendEvent (xev.display, xev.window, True, key_pressrelease == GDK_KEY_PRESS ? KeyPressMask : KeyReleaseMask, (XEvent*) &xev);
    XSync (xev.display, False);
    success &= 0 == gdk_x11_display_error_trap_pop (GDK_WINDOW_DISPLAY (window));
    return success;
}