Details

[Home]

Issue of the Implementation # D0138

Brief

The function gdk_selection_owner_set_for_display() does not behave like it is described in standaet LSB 3.2

Detailed Description

According to GDK-2.8.2 documentation, the function gdk_selection_owner_set_for_display() should send a SelectionClear event when the send_event parameter is true and the new owner is different from the current owner, but it doesn't. The problem is that the parameter send_event is unused in the code of the function.

Problem location(s) in the standard

Linux Standard Base Desktop Specification 3.2. Chapter 15. Libraries. 15.21.1.1. Interfaces for GTK Drawing toolkit that refers http://www.gtk.org/api/2.6/gdk/gdk-Selections.html#gdk-selection-owner-set-for-display

Example

#include <gdk/gdk.h>
#include <glib.h>
#include <stdio.h>

#define SELECTION GDK_SELECTION_PRIMARY

int main (int argc, char **argv)
{
	GdkWindow *first_owner = NULL;
	GdkWindowAttr first_owner_attr;
	GdkWindow *second_owner = NULL;
	GdkWindowAttr second_owner_attr;
	GdkDisplay *display = NULL;
	GdkEvent *event = NULL;
	gboolean sel_clear_event = FALSE;
	
	gdk_init(&argc, &argv);
	
	display = gdk_display_get_default();
	if(display == NULL)
	{
		printf("The gdk_display_get_default function returned NULL, unable to create GdkDisplay.\n");
		return 0;
	}
	
	first_owner_attr.title = "FIRST_OWNER";
	first_owner_attr.x = 3;
	first_owner_attr.y = 3;
	first_owner_attr.width = 500;
	first_owner_attr.height = 600;
	first_owner_attr.wclass = GDK_INPUT_OUTPUT;
	first_owner_attr.window_type = GDK_WINDOW_TOPLEVEL;
	first_owner_attr.event_mask = GDK_ALL_EVENTS_MASK;
		
	first_owner = gdk_window_new(NULL, &first_owner_attr, GDK_WA_X | GDK_WA_Y |GDK_WA_TITLE);
	if(first_owner == NULL)
	{
		printf("The gdk_window_new function returned NULL, unable to create GdkWindow.\n");
		return 0;
	}
	
	second_owner_attr.title = "SECOND_OWNER";
	second_owner_attr.x = 3;
	second_owner_attr.y = 3;
	second_owner_attr.width = 500;
	second_owner_attr.height = 600;
	second_owner_attr.wclass = GDK_INPUT_OUTPUT;
	second_owner_attr.window_type = GDK_WINDOW_TOPLEVEL;
	second_owner_attr.event_mask = GDK_ALL_EVENTS_MASK;
	
	second_owner = gdk_window_new(NULL, &second_owner_attr, GDK_WA_X | GDK_WA_Y |GDK_WA_TITLE);
	if(second_owner == NULL)
	{
		printf("The gdk_window_new function returned NULL, unable to create GdkWindow.\n");
		return 0;
	}
	
	gdk_window_show(first_owner);
	gdk_window_show(second_owner);
	
	gdk_selection_owner_set_for_display(display, first_owner, SELECTION, 
										GDK_CURRENT_TIME, FALSE);
	
	gdk_selection_owner_set_for_display(display, second_owner, SELECTION, 
										GDK_CURRENT_TIME, TRUE);
	
	sleep(1);
	while((event = gdk_event_get()) != NULL)
	{
		if(event->type == GDK_SELECTION_CLEAR)
		{
			sel_clear_event = TRUE;
			break;
		}
	}

	if(sel_clear_event == FALSE)
	{
		printf("The function should send the GDK_SELECTION_CLEAR evenrt, but it doesn't");
	}
	
	if(first_owner != NULL)
	{
		gdk_window_destroy(first_owner);
	}

	if(second_owner != NULL)
	{
		gdk_window_destroy(second_owner);
	}
	
	if(event != NULL)
	{
		gdk_event_free(event);
	}
	
	if(display != NULL)
	{
		gdk_display_close(display);
	}
	
return 0;
}

Component

gtk+ 2.17.10 or early

Accepted

Gnome Bugzilla, 593653

[Home]