fix double click problem that is a wrong solution !
author"Luc Saillard <luc@saillard.org>"
Wed Jun 11 18:33:06 2008 +0200 (2 months ago)
changeset 380e0b51e04f5d8
parent 37956d5c3dcacdd
child 3815d72766e41eb
fix double click problem that is a wrong solution !
fix i think uniconify problem
easy3d/application.cpp
easy3d/easy3d_planet.cpp
--- a/easy3d/application.cpp Wed Jun 11 14:47:14 2008 +0200
+++ b/easy3d/application.cpp Wed Jun 11 18:33:06 2008 +0200
@@ -129,6 +129,8 @@ error_show_error:
#endif
#if defined(SDL_VIDEO_DRIVER_X11)
+static void show_window_properties(void);
+
static void net_wm_change_state(Display *display, Window xwindow, bool add, Atom state1, Atom state2)
{
XEvent xev;
@@ -193,6 +195,13 @@ static void net_wm_set_window_type(Displ
}
+static void net_wm_window_type_normal(Display *display, Window xwindow)
+{
+
+
+
+}
+
/* Remove the input focus from the application */
static void net_wm_set_hints(Display *display, Window xwindow)
{
@@ -226,6 +235,9 @@ void net_wm_iconify_window(void)
XSync(display, False);
sdl_info.info.x11.unlock_func();
+
+ trace("\n");
+ show_window_properties();
}
void net_wm_deiconify_window(void)
@@ -252,9 +264,86 @@ void net_wm_deiconify_window(void)
XLowerWindow(display, window);
XSync(display, False);
+
+
+
+
+ net_wm_set_hints(display, window);
+ //net_wm_set_window_type(display, window);
+ /* Normally this settings is done by net_wm_set_window_type() but if the wm doesn't support it ... */
+ net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_SKIP_TASKBAR", False), 0);
+ net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_SKIP_PAGER", False), 0);
+ net_wm_change_state(display, window, True, XInternAtom(display, "_NET_WM_STATE_BELOW", False), 0);
+ net_wm_change_state(display, window, False, XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False), 0);
+ #define ALL_WORKSPACES (0xFFFFFFFF)
+ net_wm_change_workspace(display, window, ALL_WORKSPACES);
+
+ XLowerWindow(display, window);
+ XSync(display, False);
+
+
sdl_info.info.x11.unlock_func();
-}
-
+
+
+ trace("\n");
+ show_window_properties();
+}
+
+static int
+ignore_errors(Display *display, XErrorEvent *event)
+{
+ display=display;
+ event=event;
+ return 0;
+}
+
+
+static void
+show_window_properties(void)
+{
+ SDL_SysWMinfo sdl_info;
+
+ SDL_VERSION(&sdl_info.version);
+ if (SDL_GetWMInfo(&sdl_info) != 1)
+ return;
+ if (sdl_info.subsystem != SDL_SYSWM_X11)
+ return;
+
+ sdl_info.info.x11.lock_func();
+
+ trace("\n");
+
+ Atom *atoms;
+ int i, num_prop_return;
+
+ Window window = sdl_info.info.x11.wmwindow;
+ Display *display = sdl_info.info.x11.display;
+
+ atoms = XListProperties(display, window, &num_prop_return);
+ for (i = 0; i < num_prop_return; i++)
+ {
+ char *name;
+ XErrorHandler handler;
+
+ handler = XSetErrorHandler(ignore_errors);
+ name = XGetAtomName(display, atoms[i]);
+ XSetErrorHandler(handler);
+
+ if (name == NULL)
+ {
+ trace("undefined atom # 0x%lx", atoms[i]);
+ }
+ else
+ {
+ trace("atom # 0x%lx => %s\n", atoms[i], name);
+ XFree(name);
+ }
+
+ }
+
+
+ sdl_info.info.x11.unlock_func();
+}
#endif
--- a/easy3d/easy3d_planet.cpp Wed Jun 11 14:47:14 2008 +0200
+++ b/easy3d/easy3d_planet.cpp Wed Jun 11 18:33:06 2008 +0200
@@ -339,6 +339,16 @@ void ScenePlanet::manageClick()
int focus = mPicker.getFocusItem();
if (focus == -1)
return;
+
+ /* we have a precision of one second (should be enough to start application) */
+ time_t current_time = time(NULL);
+ static time_t last_click_time = 0;
+
+ trace("last_click_time=%u current_time=%u\n", last_click_time, current_time);
+ if (current_time < last_click_time+5)
+ return;
+ last_click_time = current_time;
+
Planet* plt = LoadUniverse::instance()->galaxyVector[mGalaxyId]->planetVector[mPlanetId];
EASY3D_ASSERT(focus >=0 && focus < (int)plt->satelliteVector.size());
@@ -351,7 +361,6 @@ void ScenePlanet::manageClick()
void ScenePlanet::handleEvent(std::vector<SDL_Event>& _events)
{
- static time_t last_click_time = 0;
bool clicked = false;
for (std::vector<SDL_Event>::iterator it=_events.begin(); it != _events.end(); it++) {
@@ -365,12 +374,7 @@ void ScenePlanet::handleEvent(std::vecto
}
if (clicked)
- { /* we have a precision of two seconds (should be enough to start application) */
- time_t current_time = time(NULL);
- if (current_time > last_click_time+5)
- manageClick();
- last_click_time = time(NULL);
- }
+ manageClick();
easy3d::Controller::handleEvent(_events);
}