| 391 | | /* Sets basic window manager hints for a window. */ |
|---|
| 392 | | void InputWindowXWin::setHints(Window window, char* window_name, |
|---|
| 393 | | char* icon_name, char* class_name, |
|---|
| 394 | | char* class_type) |
|---|
| 395 | | { |
|---|
| 396 | | XTextProperty w_name; |
|---|
| 397 | | XTextProperty i_name; |
|---|
| 398 | | XSizeHints sizehints; |
|---|
| 399 | | XWMHints wmhints; |
|---|
| 400 | | XClassHint classhints; |
|---|
| 401 | | int status; |
|---|
| 402 | | |
|---|
| 403 | | /* |
|---|
| 404 | | * Generate window and icon names. |
|---|
| 405 | | */ |
|---|
| | 391 | void InputWindowXWin::setHints(Window window, const std::string& windowName, |
|---|
| | 392 | const std::string& iconName, |
|---|
| | 393 | const std::string& className, |
|---|
| | 394 | const std::string& classType) |
|---|
| | 395 | { |
|---|
| | 396 | // NOTE: Below, the char* held by each of the std::string parameters to |
|---|
| | 397 | // this method is assigned to a value in an X structure. This is done |
|---|
| | 398 | // without copying the bytes; rather the pointer value is simply assigned. |
|---|
| | 399 | // This is safe because the X functions that receive the structures make |
|---|
| | 400 | // copies of char* input. |
|---|
| | 401 | |
|---|
| | 402 | XTextProperty w_name; |
|---|
| | 403 | XTextProperty i_name; |
|---|
| | 404 | int status; |
|---|
| | 405 | |
|---|
| | 406 | // Generate window and icon names. |
|---|
| | 407 | char* window_name = const_cast<char*>(windowName.c_str()); |
|---|
| 419 | | << "Error allocating XString\n" << vprDEBUG_FLUSH; |
|---|
| 420 | | } |
|---|
| 421 | | |
|---|
| 422 | | sizehints.width = mWidth; /* -- Obsolete in R4 */ |
|---|
| 423 | | sizehints.height = mHeight; /* -- Obsolete in R4 */ |
|---|
| 424 | | sizehints.base_width = mWidth; /* -- New in R4 */ |
|---|
| 425 | | sizehints.base_height = mHeight; /* -- New in R4 */ |
|---|
| 426 | | |
|---|
| 427 | | /* Set up flags for all the fields we've filled in. */ |
|---|
| 428 | | sizehints.flags = USPosition | USSize | PBaseSize; |
|---|
| 429 | | |
|---|
| 430 | | /* assume the window starts in "normal" (rather than |
|---|
| 431 | | * iconic) state and wants keyboard input. |
|---|
| 432 | | */ |
|---|
| 433 | | wmhints.initial_state = NormalState; |
|---|
| 434 | | wmhints.input = True; |
|---|
| 435 | | wmhints.flags = StateHint | InputHint; |
|---|
| | 423 | << "Error allocating TextProperty for icon name (" << iconName |
|---|
| | 424 | << ")\n" << vprDEBUG_FLUSH; |
|---|
| | 425 | } |
|---|
| | 426 | |
|---|
| | 427 | XSizeHints size_hints; |
|---|
| | 428 | size_hints.width = mWidth; // -- Obsolete in R4 |
|---|
| | 429 | size_hints.height = mHeight; // -- Obsolete in R4 |
|---|
| | 430 | size_hints.base_width = mWidth; // -- New in R4 |
|---|
| | 431 | size_hints.base_height = mHeight; // -- New in R4 |
|---|
| | 432 | |
|---|
| | 433 | // Set up flags for all the fields we've filled in. |
|---|
| | 434 | size_hints.flags = USPosition | USSize | PBaseSize; |
|---|
| | 435 | |
|---|
| | 436 | // Assume that the window starts in "normal" (rather than iconic) state and |
|---|
| | 437 | // wants keyboard input. |
|---|
| | 438 | XWMHints wm_hints; |
|---|
| | 439 | wm_hints.initial_state = NormalState; |
|---|
| | 440 | wm_hints.input = True; |
|---|
| | 441 | wm_hints.flags = StateHint | InputHint; |
|---|
| 438 | | classhints.res_name = class_name; |
|---|
| 439 | | classhints.res_class = class_type; |
|---|
| 440 | | |
|---|
| 441 | | XSetWMProperties(mXDisplay, window, &w_name, &i_name, |
|---|
| 442 | | //argv, argc, /* Note reversed order. */ |
|---|
| 443 | | NULL, 0, |
|---|
| 444 | | &sizehints, &wmhints, &classhints); |
|---|
| | 444 | XClassHint class_hints; |
|---|
| | 445 | class_hints.res_name = const_cast<char*>(className.c_str()); |
|---|
| | 446 | class_hints.res_class = const_cast<char*>(classType.c_str()); |
|---|
| | 447 | |
|---|
| | 448 | char** argv(NULL); |
|---|
| | 449 | int argc(0); |
|---|
| | 450 | XSetWMProperties(mXDisplay, window, &w_name, &i_name, argv, argc, |
|---|
| | 451 | &size_hints, &wm_hints, &class_hints); |
|---|